diff --git a/README.md b/README.md index 87d6330..acc905f 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@

-**scaf-talos-template** provides DevOps engineers and infrastructure teams with a complete blueprint for deploying production-ready Talos Linux Kubernetes clusters on AWS. +**talos-template** provides DevOps engineers and infrastructure teams with a complete blueprint for deploying production-ready Talos Linux Kubernetes clusters on AWS. This template generates infrastructure-as-code for a secure, immutable Kubernetes cluster using Talos Linux. A new project contains the following: @@ -37,10 +37,10 @@ Run the following command to create a new project: ```bash # If you have the template checked out locally: -scaf myproject ./scaf-talos-template +scaf myproject ./talos-template # Or use the GitHub URL directly: -scaf myproject https://github.com/getscaf/scaf-talos-template.git +scaf myproject https://github.com/getscaf/talos-template.git ``` Answer all the questions, and you'll have your new Talos cluster infrastructure project! @@ -123,6 +123,10 @@ cd ../../bootstrap-cluster/sandbox # or staging, production rm -f talosconfig kubeconfig controlplane.yaml # 3. (Optional) Remove secrets from AWS Secrets Manager +# You can use the task command: +task talos:delete_all_secrets + +# Or manually delete them: aws secretsmanager delete-secret --secret-id sandbox_talos_controlplane_yaml --force-delete-without-recovery aws secretsmanager delete-secret --secret-id sandbox_kubeconfig --force-delete-without-recovery aws secretsmanager delete-secret --secret-id sandbox_talosconfig_yaml --force-delete-without-recovery diff --git a/copier.yml b/copier.yml index 0daa5a1..f4093c0 100644 --- a/copier.yml +++ b/copier.yml @@ -132,6 +132,12 @@ copier__aws_account_id: "AWS account ID cannot be empty." {% endif %} +copier__terraform_state_name: + type: str + default: "{{ copier__project_dash }}-tfstate-{{ copier__aws_account_id[-8:] }}" + help: "The name for S3 bucket and DynamoDB table for Terraform state." + when: false + copier__talos_version: type: str default: "1.12.1" diff --git a/package-lock.json b/package-lock.json index 00d52cd..457fd6a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,11 +1,11 @@ { - "name": "scaf-talos-template", + "name": "talos-template", "version": "1.11.1", "lockfileVersion": 3, "requires": true, "packages": { "": { - "name": "scaf-talos-template", + "name": "talos-template", "version": "1.11.1", "devDependencies": { "@semantic-release/changelog": "^6.0.3", diff --git a/package.json b/package.json index e3f3f1e..f750230 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,5 @@ { - "name": "scaf-talos-template", + "name": "talos-template", "version": "1.11.1", "devDependencies": { "@semantic-release/changelog": "^6.0.3", diff --git a/template/docs/deployment.md b/template/docs/deployment.md index fb3f9f0..5c1605a 100644 --- a/template/docs/deployment.md +++ b/template/docs/deployment.md @@ -521,7 +521,13 @@ rm -f talosconfig kubeconfig controlplane.yaml ### Step 3 (Optional): Remove Secrets from AWS Secrets Manager -If you want to remove the stored credentials: +If you want to remove the stored credentials, you can use the task command: + +```bash +task talos:delete_all_secrets +``` + +Or manually delete them: ```bash aws secretsmanager delete-secret --secret-id sandbox_talosconfig_yaml --force-delete-without-recovery diff --git a/template/terraform/bootstrap/init.tf b/template/terraform/bootstrap/init.tf index fde4e2e..37bb7b2 100644 --- a/template/terraform/bootstrap/init.tf +++ b/template/terraform/bootstrap/init.tf @@ -18,7 +18,7 @@ terraform { } resource "aws_s3_bucket" "terraform_state" { - bucket = "${module.global_variables.application}-terraform-state" + bucket = "{{ copier__terraform_state_name }}" # Allows deleting the bucket even if it contains objects. # This is useful for teardown environments. @@ -37,7 +37,7 @@ resource "aws_s3_bucket_versioning" "tf_state_versioning" { } resource "aws_dynamodb_table" "terraform_state" { - name = "${module.global_variables.application}-terraform-state" + name = "{{ copier__terraform_state_name }}" read_capacity = 5 write_capacity = 5 hash_key = "LockID" diff --git a/template/terraform/modules/global_variables/main.tf b/template/terraform/modules/global_variables/main.tf index b4af246..4ed1b55 100644 --- a/template/terraform/modules/global_variables/main.tf +++ b/template/terraform/modules/global_variables/main.tf @@ -29,3 +29,8 @@ output "existing_hosted_zone" { description = "Existing hosted zone name" value = "{{ copier__existing_hosted_zone }}" } + +output "terraform_state_name" { + description = "Name for S3 bucket and DynamoDB table for Terraform state" + value = "{{ copier__terraform_state_name }}" +} diff --git a/template/terraform/production/backend.tf b/template/terraform/production/backend.tf index f585f43..16b2f3c 100644 --- a/template/terraform/production/backend.tf +++ b/template/terraform/production/backend.tf @@ -2,10 +2,10 @@ terraform { required_version = ">= 1.4" backend "s3" { region = "{{ copier__aws_region }}" - bucket = "{{ copier__project_dash }}-terraform-state" + bucket = "{{ copier__terraform_state_name }}" key = "{{ copier__project_slug }}.prod.json" encrypt = true - dynamodb_table = "{{ copier__project_dash }}-terraform-state" + dynamodb_table = "{{ copier__terraform_state_name }}" } } diff --git a/template/terraform/sandbox/backend.tf b/template/terraform/sandbox/backend.tf index 592c6d1..662fd5a 100644 --- a/template/terraform/sandbox/backend.tf +++ b/template/terraform/sandbox/backend.tf @@ -2,10 +2,10 @@ terraform { required_version = ">= 1.4" backend "s3" { region = "{{ copier__aws_region }}" - bucket = "{{ copier__project_dash }}-terraform-state" + bucket = "{{ copier__terraform_state_name }}" key = "{{ copier__project_slug }}.sandbox.json" encrypt = true - dynamodb_table = "{{ copier__project_dash }}-terraform-state" + dynamodb_table = "{{ copier__terraform_state_name }}" } } diff --git a/template/terraform/staging/backend.tf b/template/terraform/staging/backend.tf index c17a439..a09a288 100644 --- a/template/terraform/staging/backend.tf +++ b/template/terraform/staging/backend.tf @@ -2,10 +2,10 @@ terraform { required_version = ">= 1.4" backend "s3" { region = "{{ copier__aws_region }}" - bucket = "{{ copier__project_dash }}-terraform-state" + bucket = "{{ copier__terraform_state_name }}" key = "{{ copier__project_dash }}.staging.json" encrypt = true - dynamodb_table = "{{ copier__project_dash }}-terraform-state" + dynamodb_table = "{{ copier__terraform_state_name }}" } }