From 8b9298c35792241a2abfcdff4c3deed08fb2575f Mon Sep 17 00:00:00 2001 From: meatware <114529342+darkpandarts@users.noreply.github.com> Date: Sun, 1 Oct 2023 16:37:37 +0100 Subject: [PATCH] 2023 refactor 2 --- .gitignore | 4 ++++ .../01_sls_deployment_bucket/README.md | 2 +- .../01_sls_deployment_bucket/variables.tf | 1 + terraform_v1/02_DEV/README.md | 2 +- terraform_v1/02_DEV/variables.tf | 1 + terraform_v1/03_PROD/README.md | 2 +- terraform_v1/03_PROD/variables.tf | 1 + .../modules/exif_ripper_buckets/README.md | 2 +- .../modules/exif_ripper_buckets/variables.tf | 1 + .../00_setup_remote_s3_backend_dev/README.md | 6 ++--- .../ini_create_s3_and_dyndb_backend.tf | 15 ------------ .../variables.tf | 16 +++++++++++++ .../00_setup_remote_s3_backend_prod/README.md | 6 ++--- .../create_s3_and_dyndb_backend.tf | 13 ++++++---- .../exifripper_buckets_and_iam_role/README.md | 2 +- .../variables.tf | 1 + .../{local_policies.tf => vlocal_policies.tf} | 0 .../sls_deployment_bucket/README.md | 2 +- .../sls_deployment_bucket/variables.tf | 1 + .../modules/exif_ripper_buckets/README.md | 2 +- .../modules/exif_ripper_buckets/variables.tf | 1 + ...terraform-docs.sh => xxx_terraform_docs.sh | 24 ++++++++++++++++++- 22 files changed, 71 insertions(+), 34 deletions(-) create mode 100644 terraform_v2/00_setup_remote_s3_backend_dev/variables.tf rename terraform_v2/entrypoints/exifripper_buckets_and_iam_role/{local_policies.tf => vlocal_policies.tf} (100%) rename xxx_terraform-docs.sh => xxx_terraform_docs.sh (55%) diff --git a/.gitignore b/.gitignore index ee4da86..ea0fa55 100644 --- a/.gitignore +++ b/.gitignore @@ -129,3 +129,7 @@ dmypy.json .pyre/ serverless/exif-ripper/*.output append_these_perms_to_aws_credentials_file.secrets + + +*/**/.pluralith +*/**/.vscode diff --git a/terraform_v1/01_sls_deployment_bucket/README.md b/terraform_v1/01_sls_deployment_bucket/README.md index 05a59f1..2752c19 100644 --- a/terraform_v1/01_sls_deployment_bucket/README.md +++ b/terraform_v1/01_sls_deployment_bucket/README.md @@ -25,7 +25,7 @@ No resources. | Name | Description | Type | Default | Required | |------|-------------|------|---------|:--------:| | [env](#input\_env) | Deployment environment. e.g. dev, uat, prod | `string` | `"dev"` | no | -| [random\_string](#input\_random\_string) | A random string to ensure that different people can create globally unique s3 resources | `string` | n/a | yes | +| [random\_string](#input\_random\_string) | A random string to ensure that different people can create globally unique s3 resources | `string` | `"defaultNotRandom"` | no | ## Outputs diff --git a/terraform_v1/01_sls_deployment_bucket/variables.tf b/terraform_v1/01_sls_deployment_bucket/variables.tf index b1ef3a0..2c64801 100644 --- a/terraform_v1/01_sls_deployment_bucket/variables.tf +++ b/terraform_v1/01_sls_deployment_bucket/variables.tf @@ -7,4 +7,5 @@ variable "env" { variable "random_string" { description = "A random string to ensure that different people can create globally unique s3 resources" type = string + default = "defaultNotRandom" } diff --git a/terraform_v1/02_DEV/README.md b/terraform_v1/02_DEV/README.md index 47efd37..b60b2f3 100644 --- a/terraform_v1/02_DEV/README.md +++ b/terraform_v1/02_DEV/README.md @@ -27,7 +27,7 @@ No resources. | Name | Description | Type | Default | Required | |------|-------------|------|---------|:--------:| | [env](#input\_env) | Deployment environment. e.g. dev, uat, prod | `string` | `"dev"` | no | -| [random\_string](#input\_random\_string) | A random string to ensure that different people can create globally unique s3 resources | `string` | n/a | yes | +| [random\_string](#input\_random\_string) | A random string to ensure that different people can create globally unique s3 resources | `string` | `"defaultNotRandom"` | no | | [ssm\_root\_prefix](#input\_ssm\_root\_prefix) | SSM root prefix used to construct the key path | `string` | `"/stablecaps/exifripper"` | no | ## Outputs diff --git a/terraform_v1/02_DEV/variables.tf b/terraform_v1/02_DEV/variables.tf index 4835bb9..415763c 100644 --- a/terraform_v1/02_DEV/variables.tf +++ b/terraform_v1/02_DEV/variables.tf @@ -7,6 +7,7 @@ variable "env" { variable "random_string" { description = "A random string to ensure that different people can create globally unique s3 resources" type = string + default = "defaultNotRandom" } variable "ssm_root_prefix" { diff --git a/terraform_v1/03_PROD/README.md b/terraform_v1/03_PROD/README.md index 04a4f5c..b7af106 100644 --- a/terraform_v1/03_PROD/README.md +++ b/terraform_v1/03_PROD/README.md @@ -26,7 +26,7 @@ No resources. | Name | Description | Type | Default | Required | |------|-------------|------|---------|:--------:| | [env](#input\_env) | Deployment environment. e.g. dev, uat, prod | `string` | `"prod"` | no | -| [random\_string](#input\_random\_string) | A random string to ensure that different people can create globally unique s3 resources | `string` | n/a | yes | +| [random\_string](#input\_random\_string) | A random string to ensure that different people can create globally unique s3 resources | `string` | `"defaultNotRandom"` | no | | [ssm\_root\_prefix](#input\_ssm\_root\_prefix) | SSM root prefix used to construct the key path | `string` | `"/stablecaps/exifripper"` | no | ## Outputs diff --git a/terraform_v1/03_PROD/variables.tf b/terraform_v1/03_PROD/variables.tf index 5aee797..7b8bdc5 100644 --- a/terraform_v1/03_PROD/variables.tf +++ b/terraform_v1/03_PROD/variables.tf @@ -7,6 +7,7 @@ variable "env" { variable "random_string" { description = "A random string to ensure that different people can create globally unique s3 resources" type = string + default = "defaultNotRandom" } variable "ssm_root_prefix" { diff --git a/terraform_v1/modules/exif_ripper_buckets/README.md b/terraform_v1/modules/exif_ripper_buckets/README.md index c3ede61..48ab670 100644 --- a/terraform_v1/modules/exif_ripper_buckets/README.md +++ b/terraform_v1/modules/exif_ripper_buckets/README.md @@ -30,7 +30,7 @@ No requirements. | [bucket\_dest](#input\_bucket\_dest) | Exif-ripper destination bucket that sanitised files are copied to | `string` | n/a | yes | | [bucket\_source](#input\_bucket\_source) | Exif-ripper source bucket that is monitored for new files | `string` | n/a | yes | | [env](#input\_env) | Deployment environment. e.g. dev, uat, prod | `string` | n/a | yes | -| [random\_string](#input\_random\_string) | A random string to ensure that different people can create globally unique s3 resources | `string` | n/a | yes | +| [random\_string](#input\_random\_string) | A random string to ensure that different people can create globally unique s3 resources | `string` | `"defaultNotRandom"` | no | | [ssm\_root\_prefix](#input\_ssm\_root\_prefix) | SSM root prefix used to construct the key path | `string` | n/a | yes | | [tags](#input\_tags) | A map that is used to apply tags to resources created by terraform | `map(string)` | n/a | yes | diff --git a/terraform_v1/modules/exif_ripper_buckets/variables.tf b/terraform_v1/modules/exif_ripper_buckets/variables.tf index 1e4cdee..39e132d 100644 --- a/terraform_v1/modules/exif_ripper_buckets/variables.tf +++ b/terraform_v1/modules/exif_ripper_buckets/variables.tf @@ -6,6 +6,7 @@ variable "env" { variable "random_string" { description = "A random string to ensure that different people can create globally unique s3 resources" type = string + default = "defaultNotRandom" } diff --git a/terraform_v2/00_setup_remote_s3_backend_dev/README.md b/terraform_v2/00_setup_remote_s3_backend_dev/README.md index 6e05ca6..4e73c60 100644 --- a/terraform_v2/00_setup_remote_s3_backend_dev/README.md +++ b/terraform_v2/00_setup_remote_s3_backend_dev/README.md @@ -24,9 +24,9 @@ No resources. | Name | Description | Type | Default | Required | |------|-------------|------|---------|:--------:| -| [env](#input\_env) | n/a | `string` | `"dev"` | no | -| [random\_string](#input\_random\_string) | n/a | `string` | n/a | yes | -| [terraform\_backend\_config\_file\_path](#input\_terraform\_backend\_config\_file\_path) | n/a | `string` | `"."` | no | +| [env](#input\_env) | Deployment environment. e.g. dev, uat, prod | `string` | n/a | yes | +| [random\_string](#input\_random\_string) | A random string to ensure that different people can create globally unique s3 resources | `string` | `"defaultNotRandom"` | no | +| [terraform\_backend\_config\_file\_path](#input\_terraform\_backend\_config\_file\_path) | Path to Terraform backend config file | `string` | `"."` | no | ## Outputs diff --git a/terraform_v2/00_setup_remote_s3_backend_dev/ini_create_s3_and_dyndb_backend.tf b/terraform_v2/00_setup_remote_s3_backend_dev/ini_create_s3_and_dyndb_backend.tf index 2000d54..432c151 100644 --- a/terraform_v2/00_setup_remote_s3_backend_dev/ini_create_s3_and_dyndb_backend.tf +++ b/terraform_v2/00_setup_remote_s3_backend_dev/ini_create_s3_and_dyndb_backend.tf @@ -3,21 +3,6 @@ # be bootstrapped according to the simple yet essential procedure in # https://github.com/cloudposse/terraform-aws-tfstate-backend#usage -variable "env" { - type = string - default = "dev" -} - -variable "random_string" { - type = string -} - -variable "terraform_backend_config_file_path" { - type = string - default = "." -} - - module "terraform_state_backend" { source = "cloudposse/tfstate-backend/aws" diff --git a/terraform_v2/00_setup_remote_s3_backend_dev/variables.tf b/terraform_v2/00_setup_remote_s3_backend_dev/variables.tf new file mode 100644 index 0000000..fd68e51 --- /dev/null +++ b/terraform_v2/00_setup_remote_s3_backend_dev/variables.tf @@ -0,0 +1,16 @@ +variable "env" { + description = "Deployment environment. e.g. dev, uat, prod" + type = string +} + +variable "random_string" { + description = "A random string to ensure that different people can create globally unique s3 resources" + type = string + default = "defaultNotRandom" +} + +variable "terraform_backend_config_file_path" { + description = "Path to Terraform backend config file" + type = string + default = "." +} diff --git a/terraform_v2/00_setup_remote_s3_backend_prod/README.md b/terraform_v2/00_setup_remote_s3_backend_prod/README.md index f3079b3..a5296c9 100644 --- a/terraform_v2/00_setup_remote_s3_backend_prod/README.md +++ b/terraform_v2/00_setup_remote_s3_backend_prod/README.md @@ -25,9 +25,9 @@ No resources. | Name | Description | Type | Default | Required | |------|-------------|------|---------|:--------:| -| [env](#input\_env) | n/a | `string` | `"prod"` | no | -| [random\_string](#input\_random\_string) | n/a | `string` | n/a | yes | -| [terraform\_backend\_config\_file\_path](#input\_terraform\_backend\_config\_file\_path) | n/a | `string` | `"."` | no | +| [env](#input\_env) | Deployment environment. e.g. dev, uat, prod | `string` | n/a | yes | +| [random\_string](#input\_random\_string) | A random string to ensure that different people can create globally unique s3 resources | `string` | `"defaultNotRandom"` | no | +| [terraform\_backend\_config\_file\_path](#input\_terraform\_backend\_config\_file\_path) | Path to Terraform backend config file | `string` | `"."` | no | ## Outputs diff --git a/terraform_v2/00_setup_remote_s3_backend_prod/create_s3_and_dyndb_backend.tf b/terraform_v2/00_setup_remote_s3_backend_prod/create_s3_and_dyndb_backend.tf index e3c4c30..6157db0 100644 --- a/terraform_v2/00_setup_remote_s3_backend_prod/create_s3_and_dyndb_backend.tf +++ b/terraform_v2/00_setup_remote_s3_backend_prod/create_s3_and_dyndb_backend.tf @@ -4,17 +4,20 @@ # https://github.com/cloudposse/terraform-aws-tfstate-backend#usage variable "env" { - type = string - default = "prod" + description = "Deployment environment. e.g. dev, uat, prod" + type = string } variable "random_string" { - type = string + description = "A random string to ensure that different people can create globally unique s3 resources" + type = string + default = "defaultNotRandom" } variable "terraform_backend_config_file_path" { - type = string - default = "." + description = "Path to Terraform backend config file" + type = string + default = "." } diff --git a/terraform_v2/entrypoints/exifripper_buckets_and_iam_role/README.md b/terraform_v2/entrypoints/exifripper_buckets_and_iam_role/README.md index ce30140..b29f170 100644 --- a/terraform_v2/entrypoints/exifripper_buckets_and_iam_role/README.md +++ b/terraform_v2/entrypoints/exifripper_buckets_and_iam_role/README.md @@ -26,7 +26,7 @@ No resources. | Name | Description | Type | Default | Required | |------|-------------|------|---------|:--------:| | [env](#input\_env) | Deployment environment. e.g. dev, uat, prod | `string` | n/a | yes | -| [random\_string](#input\_random\_string) | A random string to ensure that different people can create globally unique s3 resources | `string` | n/a | yes | +| [random\_string](#input\_random\_string) | A random string to ensure that different people can create globally unique s3 resources | `string` | `"defaultNotRandom"` | no | | [ssm\_root\_prefix](#input\_ssm\_root\_prefix) | SSM root prefix used to construct the key path | `string` | n/a | yes | ## Outputs diff --git a/terraform_v2/entrypoints/exifripper_buckets_and_iam_role/variables.tf b/terraform_v2/entrypoints/exifripper_buckets_and_iam_role/variables.tf index d735540..999792c 100644 --- a/terraform_v2/entrypoints/exifripper_buckets_and_iam_role/variables.tf +++ b/terraform_v2/entrypoints/exifripper_buckets_and_iam_role/variables.tf @@ -6,6 +6,7 @@ variable "env" { variable "random_string" { description = "A random string to ensure that different people can create globally unique s3 resources" type = string + default = "defaultNotRandom" } variable "ssm_root_prefix" { diff --git a/terraform_v2/entrypoints/exifripper_buckets_and_iam_role/local_policies.tf b/terraform_v2/entrypoints/exifripper_buckets_and_iam_role/vlocal_policies.tf similarity index 100% rename from terraform_v2/entrypoints/exifripper_buckets_and_iam_role/local_policies.tf rename to terraform_v2/entrypoints/exifripper_buckets_and_iam_role/vlocal_policies.tf diff --git a/terraform_v2/entrypoints/sls_deployment_bucket/README.md b/terraform_v2/entrypoints/sls_deployment_bucket/README.md index 05a59f1..2752c19 100644 --- a/terraform_v2/entrypoints/sls_deployment_bucket/README.md +++ b/terraform_v2/entrypoints/sls_deployment_bucket/README.md @@ -25,7 +25,7 @@ No resources. | Name | Description | Type | Default | Required | |------|-------------|------|---------|:--------:| | [env](#input\_env) | Deployment environment. e.g. dev, uat, prod | `string` | `"dev"` | no | -| [random\_string](#input\_random\_string) | A random string to ensure that different people can create globally unique s3 resources | `string` | n/a | yes | +| [random\_string](#input\_random\_string) | A random string to ensure that different people can create globally unique s3 resources | `string` | `"defaultNotRandom"` | no | ## Outputs diff --git a/terraform_v2/entrypoints/sls_deployment_bucket/variables.tf b/terraform_v2/entrypoints/sls_deployment_bucket/variables.tf index b1ef3a0..2c64801 100644 --- a/terraform_v2/entrypoints/sls_deployment_bucket/variables.tf +++ b/terraform_v2/entrypoints/sls_deployment_bucket/variables.tf @@ -7,4 +7,5 @@ variable "env" { variable "random_string" { description = "A random string to ensure that different people can create globally unique s3 resources" type = string + default = "defaultNotRandom" } diff --git a/terraform_v2/modules/exif_ripper_buckets/README.md b/terraform_v2/modules/exif_ripper_buckets/README.md index c3ede61..48ab670 100644 --- a/terraform_v2/modules/exif_ripper_buckets/README.md +++ b/terraform_v2/modules/exif_ripper_buckets/README.md @@ -30,7 +30,7 @@ No requirements. | [bucket\_dest](#input\_bucket\_dest) | Exif-ripper destination bucket that sanitised files are copied to | `string` | n/a | yes | | [bucket\_source](#input\_bucket\_source) | Exif-ripper source bucket that is monitored for new files | `string` | n/a | yes | | [env](#input\_env) | Deployment environment. e.g. dev, uat, prod | `string` | n/a | yes | -| [random\_string](#input\_random\_string) | A random string to ensure that different people can create globally unique s3 resources | `string` | n/a | yes | +| [random\_string](#input\_random\_string) | A random string to ensure that different people can create globally unique s3 resources | `string` | `"defaultNotRandom"` | no | | [ssm\_root\_prefix](#input\_ssm\_root\_prefix) | SSM root prefix used to construct the key path | `string` | n/a | yes | | [tags](#input\_tags) | A map that is used to apply tags to resources created by terraform | `map(string)` | n/a | yes | diff --git a/terraform_v2/modules/exif_ripper_buckets/variables.tf b/terraform_v2/modules/exif_ripper_buckets/variables.tf index 1e4cdee..39e132d 100644 --- a/terraform_v2/modules/exif_ripper_buckets/variables.tf +++ b/terraform_v2/modules/exif_ripper_buckets/variables.tf @@ -6,6 +6,7 @@ variable "env" { variable "random_string" { description = "A random string to ensure that different people can create globally unique s3 resources" type = string + default = "defaultNotRandom" } diff --git a/xxx_terraform-docs.sh b/xxx_terraform_docs.sh similarity index 55% rename from xxx_terraform-docs.sh rename to xxx_terraform_docs.sh index e028b36..4864c22 100755 --- a/xxx_terraform-docs.sh +++ b/xxx_terraform_docs.sh @@ -11,7 +11,7 @@ fi if [ "$#" -ne 1 ]; then echo "USAGE: ./xxx_terraform-docs.sh \${YOUR_TERRAFORM_EXEC}" - echo "e.g > ./xxx_terraform-docs.sh terraform_v1.0.6" + echo "e.g > ./xxx_terraform-docs.sh terraform_v1.5.1" exit 0 fi @@ -24,7 +24,29 @@ unique_tf_dirs=$(find ./ -not -path "*/\.*" -not -path "*venv/*" -not -path "*no for tf_dirs in $unique_tf_dirs; do cd $tf_dirs + echo "" + pwd # TODO: customise this further to enrich READMEs and create links to them from root directory terraform-docs markdown table --output-file README.md --output-mode inject . + + IMAGE_FILE="./images/terraform_infra.png" + if [ -f "$IMAGE_FILE" ]; then + echo "Adding infra image" + ### rm previous additions + + sed -i "s|images/terraform_infra.png||g" README.md + mv -f README.md README.temp + + + MDIMG_LINK="![terraform_infra](${IMAGE_FILE})" + echo "$MDIMG_LINK" > README.md + echo "" >> README.md + echo "" >> README.md + cat README.temp >> README.md + rm README.temp + + else + echo "nofindo" + fi cd - done \ No newline at end of file