From 2a5a20ba5e059239d7f79d767b7f8c442835cb65 Mon Sep 17 00:00:00 2001 From: meatware <114529342+darkpandarts@users.noreply.github.com> Date: Sun, 1 Oct 2023 13:45:29 +0100 Subject: [PATCH] 2023 refactor --- .../00_test_upload_image_2_s3_source.sh | 4 +- serverless/exif-ripper/config/dev.yml | 2 +- serverless/exif-ripper/config/prod.yml | 2 +- .../01_sls_deployment_bucket/README.md | 2 +- ..._holder.tf => ini_s3_serverless_holder.tf} | 11 - .../01_sls_deployment_bucket/provider.tf | 2 - .../01_sls_deployment_bucket/variables.tf | 2 +- .../01_sls_deployment_bucket/vlocals.tf | 10 + .../{outputs.tf => voutputs.tf} | 0 terraform_v1/02_DEV/README.md | 4 +- .../02_DEV/{setup_dev.tf => ini_setup_dev.tf} | 13 +- terraform_v1/02_DEV/provider.tf | 1 - terraform_v1/02_DEV/variables.tf | 4 +- terraform_v1/02_DEV/vlocals.tf | 8 + .../02_DEV/{outputs.tf => voutputs.tf} | 0 terraform_v1/03_PROD/README.md | 4 +- terraform_v1/03_PROD/ini_setup_prod.tf | 25 ++ terraform_v1/03_PROD/outputs.tf | 40 -- terraform_v1/03_PROD/provider.tf | 1 - terraform_v1/03_PROD/setup_prod.tf | 48 --- terraform_v1/03_PROD/variables.tf | 4 +- terraform_v1/03_PROD/vlocals.tf | 8 + terraform_v1/03_PROD/voutputs.tf | 16 + .../modules/exif_ripper_buckets/README.md | 2 +- .../modules/exif_ripper_buckets/variables.tf | 4 +- .../exif_ripper_buckets/{data.tf => vdata.tf} | 0 .../{outputs.tf => voutputs.tf} | 0 .../{outputs.tf => voutputs.tf} | 0 .../gen_iam_role.tf | 4 - .../lambda_iam_role_and_policies/vlocals.tf | 3 + .../{outputs.tf => voutputs.tf} | 0 .../dev.backend.hcl | 4 +- .../errored.tfstate | 392 ------------------ ....tf => ini_create_s3_and_dyndb_backend.tf} | 7 +- .../create_s3_and_dyndb_backend.tf | 6 +- .../{backend_prod.tf => ini_backend_prod.tf} | 4 +- .../prod.backend.hcl | 4 +- .../exifripper_buckets_and_iam_role/README.md | 2 +- ...ain.tf => ini_create_buckets_and_perms.tf} | 16 +- .../variables.tf | 2 +- .../vlocals.tf | 11 + .../{outputs.tf => voutputs.tf} | 0 .../sls_deployment_bucket/README.md | 2 +- ..._holder.tf => ini_s3_serverless_holder.tf} | 11 - .../sls_deployment_bucket/variables.tf | 2 +- .../sls_deployment_bucket/vlocals.tf | 10 + .../{outputs.tf => voutputs.tf} | 0 terraform_v2/envs/dev/dev.backend.hcl | 4 +- terraform_v2/envs/dev/dev.tfvars | 2 +- terraform_v2/envs/prod/prod.backend.hcl | 4 +- terraform_v2/envs/prod/prod.tfvars | 2 +- .../modules/exif_ripper_buckets/README.md | 2 +- .../{data.tf => ssm_data.tf} | 9 +- .../modules/exif_ripper_buckets/variables.tf | 4 +- .../modules/exif_ripper_buckets/vlocals.tf | 6 + .../{outputs.tf => voutputs.tf} | 0 56 files changed, 144 insertions(+), 586 deletions(-) rename terraform_v1/01_sls_deployment_bucket/{s3_serverless_holder.tf => ini_s3_serverless_holder.tf} (66%) create mode 100644 terraform_v1/01_sls_deployment_bucket/vlocals.tf rename terraform_v1/01_sls_deployment_bucket/{outputs.tf => voutputs.tf} (100%) rename terraform_v1/02_DEV/{setup_dev.tf => ini_setup_dev.tf} (78%) create mode 100644 terraform_v1/02_DEV/vlocals.tf rename terraform_v1/02_DEV/{outputs.tf => voutputs.tf} (100%) create mode 100644 terraform_v1/03_PROD/ini_setup_prod.tf delete mode 100644 terraform_v1/03_PROD/outputs.tf delete mode 100644 terraform_v1/03_PROD/setup_prod.tf create mode 100644 terraform_v1/03_PROD/vlocals.tf create mode 100644 terraform_v1/03_PROD/voutputs.tf rename terraform_v1/modules/exif_ripper_buckets/{data.tf => vdata.tf} (100%) rename terraform_v1/modules/exif_ripper_buckets/{outputs.tf => voutputs.tf} (100%) rename terraform_v1/modules/iam_exif_users/{outputs.tf => voutputs.tf} (100%) create mode 100644 terraform_v1/modules/lambda_iam_role_and_policies/vlocals.tf rename terraform_v1/modules/lambda_iam_role_and_policies/{outputs.tf => voutputs.tf} (100%) delete mode 100644 terraform_v2/00_setup_remote_s3_backend_dev/errored.tfstate rename terraform_v2/00_setup_remote_s3_backend_dev/{create_s3_and_dyndb_backend.tf => ini_create_s3_and_dyndb_backend.tf} (85%) rename terraform_v2/00_setup_remote_s3_backend_prod/{backend_prod.tf => ini_backend_prod.tf} (66%) rename terraform_v2/entrypoints/exifripper_buckets_and_iam_role/{main.tf => ini_create_buckets_and_perms.tf} (67%) create mode 100644 terraform_v2/entrypoints/exifripper_buckets_and_iam_role/vlocals.tf rename terraform_v2/entrypoints/exifripper_buckets_and_iam_role/{outputs.tf => voutputs.tf} (100%) rename terraform_v2/entrypoints/sls_deployment_bucket/{s3_serverless_holder.tf => ini_s3_serverless_holder.tf} (66%) create mode 100644 terraform_v2/entrypoints/sls_deployment_bucket/vlocals.tf rename terraform_v2/entrypoints/sls_deployment_bucket/{outputs.tf => voutputs.tf} (100%) rename terraform_v2/modules/exif_ripper_buckets/{data.tf => ssm_data.tf} (71%) create mode 100644 terraform_v2/modules/exif_ripper_buckets/vlocals.tf rename terraform_v2/modules/exif_ripper_buckets/{outputs.tf => voutputs.tf} (100%) diff --git a/serverless/exif-ripper/00_test_upload_image_2_s3_source.sh b/serverless/exif-ripper/00_test_upload_image_2_s3_source.sh index a872fb2..e55a43f 100755 --- a/serverless/exif-ripper/00_test_upload_image_2_s3_source.sh +++ b/serverless/exif-ripper/00_test_upload_image_2_s3_source.sh @@ -54,7 +54,7 @@ cp -v test_images/OG_IMG_20220423_124829.jpg test_images/sls_test_img1.jpg SOURCE_BUCKET=$(aws --profile $AWS_PROFILE \ --region eu-west-1 \ ssm get-parameter \ - --name /genomics/exifripper/dev/bucketsource \ + --name /stablecaps/exifripper/dev/bucketsource \ | jq '.Parameter.Value' \ | sed 's|"||g') @@ -62,7 +62,7 @@ SOURCE_BUCKET=$(aws --profile $AWS_PROFILE \ DEST_BUCKET=$(aws --profile $AWS_PROFILE \ --region eu-west-1 \ ssm get-parameter \ - --name /genomics/exifripper/dev/bucketdest \ + --name /stablecaps/exifripper/dev/bucketdest \ | jq '.Parameter.Value' \ | sed 's|"||g') diff --git a/serverless/exif-ripper/config/dev.yml b/serverless/exif-ripper/config/dev.yml index ef1c19c..6492d12 100644 --- a/serverless/exif-ripper/config/dev.yml +++ b/serverless/exif-ripper/config/dev.yml @@ -4,4 +4,4 @@ aws_region: eu-west-1 deployment_bucket: serverless-deployment-holder-658fi8r7 stage: dev iam_role_arn: arn:aws:iam::779934699932:role/lambda/dev/exif-ripper-dev-eu-west-1-lambdaRole20220427180337074400000001 -ssm_root_prefix: /genomics/exifripper +ssm_root_prefix: /stablecaps/exifripper diff --git a/serverless/exif-ripper/config/prod.yml b/serverless/exif-ripper/config/prod.yml index 88343ae..c1e9efa 100644 --- a/serverless/exif-ripper/config/prod.yml +++ b/serverless/exif-ripper/config/prod.yml @@ -4,4 +4,4 @@ aws_region: eu-west-1 deployment_bucket: serverless-deployment-holder-658fi8r7 stage: prod iam_role_arn: arn:aws:iam::779934699932:role/lambda/dev/exif-ripper-dev-eu-west-1-lambdaRole20220427180337074400000001 -ssm_root_prefix: /genomics/exifripper +ssm_root_prefix: /stablecaps/exifripper diff --git a/terraform_v1/01_sls_deployment_bucket/README.md b/terraform_v1/01_sls_deployment_bucket/README.md index e229610..05a59f1 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 uniuque 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` | n/a | yes | ## Outputs diff --git a/terraform_v1/01_sls_deployment_bucket/s3_serverless_holder.tf b/terraform_v1/01_sls_deployment_bucket/ini_s3_serverless_holder.tf similarity index 66% rename from terraform_v1/01_sls_deployment_bucket/s3_serverless_holder.tf rename to terraform_v1/01_sls_deployment_bucket/ini_s3_serverless_holder.tf index 9f2346d..a0d4974 100644 --- a/terraform_v1/01_sls_deployment_bucket/s3_serverless_holder.tf +++ b/terraform_v1/01_sls_deployment_bucket/ini_s3_serverless_holder.tf @@ -1,14 +1,3 @@ -locals { - tags = { - environment = var.env - project = "genomics" - owner = "gtampi/devops" - created_by = "terraform" - } - - bucket_name = "serverless-deployment-holder-${var.env}-${var.random_string}" -} - module "s3_serverless_deployment_bucket" { source = "terraform-aws-modules/s3-bucket/aws" diff --git a/terraform_v1/01_sls_deployment_bucket/provider.tf b/terraform_v1/01_sls_deployment_bucket/provider.tf index 4a6aa5c..86f8a6a 100644 --- a/terraform_v1/01_sls_deployment_bucket/provider.tf +++ b/terraform_v1/01_sls_deployment_bucket/provider.tf @@ -11,5 +11,3 @@ terraform { provider "aws" { region = "eu-west-1" } - -# TODO: Setup remote state \ No newline at end of file diff --git a/terraform_v1/01_sls_deployment_bucket/variables.tf b/terraform_v1/01_sls_deployment_bucket/variables.tf index 136bfbe..b1ef3a0 100644 --- a/terraform_v1/01_sls_deployment_bucket/variables.tf +++ b/terraform_v1/01_sls_deployment_bucket/variables.tf @@ -5,6 +5,6 @@ variable "env" { } variable "random_string" { - description = "A random string to ensure that different people can create uniuque s3 resources" + description = "A random string to ensure that different people can create globally unique s3 resources" type = string } diff --git a/terraform_v1/01_sls_deployment_bucket/vlocals.tf b/terraform_v1/01_sls_deployment_bucket/vlocals.tf new file mode 100644 index 0000000..371a478 --- /dev/null +++ b/terraform_v1/01_sls_deployment_bucket/vlocals.tf @@ -0,0 +1,10 @@ +locals { + tags = { + environment = var.env + project = "stablecaps" + owner = "DevOps" + created_by = "terraform" + } + + bucket_name = "serverless-deployment-holder-${var.env}-${var.random_string}" +} diff --git a/terraform_v1/01_sls_deployment_bucket/outputs.tf b/terraform_v1/01_sls_deployment_bucket/voutputs.tf similarity index 100% rename from terraform_v1/01_sls_deployment_bucket/outputs.tf rename to terraform_v1/01_sls_deployment_bucket/voutputs.tf diff --git a/terraform_v1/02_DEV/README.md b/terraform_v1/02_DEV/README.md index c32778d..47efd37 100644 --- a/terraform_v1/02_DEV/README.md +++ b/terraform_v1/02_DEV/README.md @@ -27,8 +27,8 @@ 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 uniuque s3 resources | `string` | n/a | yes | -| [ssm\_root\_prefix](#input\_ssm\_root\_prefix) | SSM root prefix used to construct the key path | `string` | `"/genomics/exifripper"` | no | +| [random\_string](#input\_random\_string) | A random string to ensure that different people can create globally unique s3 resources | `string` | n/a | yes | +| [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/setup_dev.tf b/terraform_v1/02_DEV/ini_setup_dev.tf similarity index 78% rename from terraform_v1/02_DEV/setup_dev.tf rename to terraform_v1/02_DEV/ini_setup_dev.tf index 8fdae07..ddbd7dd 100644 --- a/terraform_v1/02_DEV/setup_dev.tf +++ b/terraform_v1/02_DEV/ini_setup_dev.tf @@ -1,19 +1,10 @@ -locals { - tags = { - environment = var.env - project = "genomics" - owner = "gtampi/devops" - created_by = "terraform" - } -} - module "exif_buckets" { source = "../modules/exif_ripper_buckets" env = var.env random_string = var.random_string - bucket_source = "genomics-source" - bucket_dest = "genomics-destination" + bucket_source = "stablecaps-source" + bucket_dest = "stablecaps-destination" tags = local.tags diff --git a/terraform_v1/02_DEV/provider.tf b/terraform_v1/02_DEV/provider.tf index 4a6aa5c..c422836 100644 --- a/terraform_v1/02_DEV/provider.tf +++ b/terraform_v1/02_DEV/provider.tf @@ -12,4 +12,3 @@ provider "aws" { region = "eu-west-1" } -# TODO: Setup remote state \ No newline at end of file diff --git a/terraform_v1/02_DEV/variables.tf b/terraform_v1/02_DEV/variables.tf index 217951c..4835bb9 100644 --- a/terraform_v1/02_DEV/variables.tf +++ b/terraform_v1/02_DEV/variables.tf @@ -5,12 +5,12 @@ variable "env" { } variable "random_string" { - description = "A random string to ensure that different people can create uniuque s3 resources" + description = "A random string to ensure that different people can create globally unique s3 resources" type = string } variable "ssm_root_prefix" { description = "SSM root prefix used to construct the key path" type = string - default = "/genomics/exifripper" + default = "/stablecaps/exifripper" } diff --git a/terraform_v1/02_DEV/vlocals.tf b/terraform_v1/02_DEV/vlocals.tf new file mode 100644 index 0000000..9bf393d --- /dev/null +++ b/terraform_v1/02_DEV/vlocals.tf @@ -0,0 +1,8 @@ +locals { + tags = { + environment = var.env + project = "stablecaps" + owner = "DevOps" + created_by = "terraform" + } +} diff --git a/terraform_v1/02_DEV/outputs.tf b/terraform_v1/02_DEV/voutputs.tf similarity index 100% rename from terraform_v1/02_DEV/outputs.tf rename to terraform_v1/02_DEV/voutputs.tf diff --git a/terraform_v1/03_PROD/README.md b/terraform_v1/03_PROD/README.md index cac30bf..04a4f5c 100644 --- a/terraform_v1/03_PROD/README.md +++ b/terraform_v1/03_PROD/README.md @@ -26,8 +26,8 @@ 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 uniuque s3 resources | `string` | n/a | yes | -| [ssm\_root\_prefix](#input\_ssm\_root\_prefix) | SSM root prefix used to construct the key path | `string` | `"/genomics/exifripper"` | no | +| [random\_string](#input\_random\_string) | A random string to ensure that different people can create globally unique s3 resources | `string` | n/a | yes | +| [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/ini_setup_prod.tf b/terraform_v1/03_PROD/ini_setup_prod.tf new file mode 100644 index 0000000..a360991 --- /dev/null +++ b/terraform_v1/03_PROD/ini_setup_prod.tf @@ -0,0 +1,25 @@ +module "exif_buckets" { + source = "../modules/exif_ripper_buckets" + + env = var.env + random_string = var.random_string + bucket_source = "stablecaps-source" + bucket_dest = "stablecaps-destination" + + tags = local.tags + + ssm_root_prefix = var.ssm_root_prefix + +} + +module "lambda_role_and_policies" { + source = "../modules/lambda_iam_role_and_policies" + + env = var.env + bucket_source = module.exif_buckets.bucket_source_name + bucket_dest = module.exif_buckets.bucket_dest_name + + tags = local.tags + + ssm_root_prefix = var.ssm_root_prefix +} diff --git a/terraform_v1/03_PROD/outputs.tf b/terraform_v1/03_PROD/outputs.tf deleted file mode 100644 index 6715eaa..0000000 --- a/terraform_v1/03_PROD/outputs.tf +++ /dev/null @@ -1,40 +0,0 @@ -output "iam_role_arn" { - description = "Lambda IAM role arn used for serverless function" - value = module.lambda_role_and_policies.iam_role_arn -} - -output "bucket_source_name" { - description = "exif-ripper s3 source bucket name" - value = module.exif_buckets.bucket_source_name -} - -output "bucket_dest_name" { - description = "exif-ripper s3 destination bucket name" - value = module.exif_buckets.bucket_dest_name -} - -# TODO: users module disabled for now - -# output "iam_exif_s3_rwa_id" { -# description = "user A RW IAM access id" -# sensitive = true -# value = module.iam_exif_users.iam_exif_s3_rwa_id -# } - -# output "iam_exif_s3_rwa_secret" { -# description = "user A RW IAM access secret" -# sensitive = true -# value = module.iam_exif_users.iam_exif_s3_rwa_secret -# } -# # -# output "iam_exif_s3_rob_id" { -# description = "user B RO IAM access id" -# sensitive = true -# value = module.iam_exif_users.iam_exif_s3_rob_id -# } - -# output "iam_exif_s3_rob_secret" { -# description = "user B RO IAM access secret" -# sensitive = true -# value = module.iam_exif_users.iam_exif_s3_rob_secret -# } \ No newline at end of file diff --git a/terraform_v1/03_PROD/provider.tf b/terraform_v1/03_PROD/provider.tf index 4a6aa5c..c422836 100644 --- a/terraform_v1/03_PROD/provider.tf +++ b/terraform_v1/03_PROD/provider.tf @@ -12,4 +12,3 @@ provider "aws" { region = "eu-west-1" } -# TODO: Setup remote state \ No newline at end of file diff --git a/terraform_v1/03_PROD/setup_prod.tf b/terraform_v1/03_PROD/setup_prod.tf deleted file mode 100644 index 782bb27..0000000 --- a/terraform_v1/03_PROD/setup_prod.tf +++ /dev/null @@ -1,48 +0,0 @@ -locals { - tags = { - environment = var.env - project = "genomics" - owner = "gtampi/devops" - created_by = "terraform" - } -} - -module "exif_buckets" { - source = "../modules/exif_ripper_buckets" - - env = var.env - random_string = var.random_string - bucket_source = "genomics-source" - bucket_dest = "genomics-destination" - - tags = local.tags - - ssm_root_prefix = var.ssm_root_prefix - -} - -module "lambda_role_and_policies" { - source = "../modules/lambda_iam_role_and_policies" - - env = var.env - bucket_source = module.exif_buckets.bucket_source_name - bucket_dest = module.exif_buckets.bucket_dest_name - - tags = local.tags - - ssm_root_prefix = var.ssm_root_prefix -} - -# TODO: make this module able to assign any number of users arbitrary bucket permssions -# TODO: make this handle multiple envs - -# module "iam_exif_users" { -# source = "../modules/iam_exif_users" - -# env = var.env -# tags = local.tags - -# bucket_source = module.exif_buckets.bucket_source_name -# bucket_dest = module.exif_buckets.bucket_dest_name - -# } diff --git a/terraform_v1/03_PROD/variables.tf b/terraform_v1/03_PROD/variables.tf index 61660f4..5aee797 100644 --- a/terraform_v1/03_PROD/variables.tf +++ b/terraform_v1/03_PROD/variables.tf @@ -5,12 +5,12 @@ variable "env" { } variable "random_string" { - description = "A random string to ensure that different people can create uniuque s3 resources" + description = "A random string to ensure that different people can create globally unique s3 resources" type = string } variable "ssm_root_prefix" { description = "SSM root prefix used to construct the key path" type = string - default = "/genomics/exifripper" + default = "/stablecaps/exifripper" } diff --git a/terraform_v1/03_PROD/vlocals.tf b/terraform_v1/03_PROD/vlocals.tf new file mode 100644 index 0000000..9bf393d --- /dev/null +++ b/terraform_v1/03_PROD/vlocals.tf @@ -0,0 +1,8 @@ +locals { + tags = { + environment = var.env + project = "stablecaps" + owner = "DevOps" + created_by = "terraform" + } +} diff --git a/terraform_v1/03_PROD/voutputs.tf b/terraform_v1/03_PROD/voutputs.tf new file mode 100644 index 0000000..3f01d3f --- /dev/null +++ b/terraform_v1/03_PROD/voutputs.tf @@ -0,0 +1,16 @@ +output "iam_role_arn" { + description = "Lambda IAM role arn used for serverless function" + value = module.lambda_role_and_policies.iam_role_arn +} + +output "bucket_source_name" { + description = "exif-ripper s3 source bucket name" + value = module.exif_buckets.bucket_source_name +} + +output "bucket_dest_name" { + description = "exif-ripper s3 destination bucket name" + value = module.exif_buckets.bucket_dest_name +} + +# NOTE: users module disabled for purposes of this example diff --git a/terraform_v1/modules/exif_ripper_buckets/README.md b/terraform_v1/modules/exif_ripper_buckets/README.md index c6cc1c2..c3ede61 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 uniuque 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` | n/a | yes | | [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 c8ae054..1e4cdee 100644 --- a/terraform_v1/modules/exif_ripper_buckets/variables.tf +++ b/terraform_v1/modules/exif_ripper_buckets/variables.tf @@ -4,7 +4,7 @@ variable "env" { } variable "random_string" { - description = "A random string to ensure that different people can create uniuque s3 resources" + description = "A random string to ensure that different people can create globally unique s3 resources" type = string } @@ -27,4 +27,4 @@ variable "ssm_root_prefix" { variable "tags" { description = "A map that is used to apply tags to resources created by terraform" type = map(string) -} \ No newline at end of file +} diff --git a/terraform_v1/modules/exif_ripper_buckets/data.tf b/terraform_v1/modules/exif_ripper_buckets/vdata.tf similarity index 100% rename from terraform_v1/modules/exif_ripper_buckets/data.tf rename to terraform_v1/modules/exif_ripper_buckets/vdata.tf diff --git a/terraform_v1/modules/exif_ripper_buckets/outputs.tf b/terraform_v1/modules/exif_ripper_buckets/voutputs.tf similarity index 100% rename from terraform_v1/modules/exif_ripper_buckets/outputs.tf rename to terraform_v1/modules/exif_ripper_buckets/voutputs.tf diff --git a/terraform_v1/modules/iam_exif_users/outputs.tf b/terraform_v1/modules/iam_exif_users/voutputs.tf similarity index 100% rename from terraform_v1/modules/iam_exif_users/outputs.tf rename to terraform_v1/modules/iam_exif_users/voutputs.tf diff --git a/terraform_v1/modules/lambda_iam_role_and_policies/gen_iam_role.tf b/terraform_v1/modules/lambda_iam_role_and_policies/gen_iam_role.tf index d48be74..19b5628 100644 --- a/terraform_v1/modules/lambda_iam_role_and_policies/gen_iam_role.tf +++ b/terraform_v1/modules/lambda_iam_role_and_policies/gen_iam_role.tf @@ -1,7 +1,3 @@ -locals { - lambda_role_name = "exif-ripper-${var.env}-eu-west-1-lambdaRole" -} - resource "aws_iam_role" "lambda_role" { name_prefix = local.lambda_role_name diff --git a/terraform_v1/modules/lambda_iam_role_and_policies/vlocals.tf b/terraform_v1/modules/lambda_iam_role_and_policies/vlocals.tf new file mode 100644 index 0000000..4eb8911 --- /dev/null +++ b/terraform_v1/modules/lambda_iam_role_and_policies/vlocals.tf @@ -0,0 +1,3 @@ +locals { + lambda_role_name = "exif-ripper-${var.env}-eu-west-1-lambdaRole" +} diff --git a/terraform_v1/modules/lambda_iam_role_and_policies/outputs.tf b/terraform_v1/modules/lambda_iam_role_and_policies/voutputs.tf similarity index 100% rename from terraform_v1/modules/lambda_iam_role_and_policies/outputs.tf rename to terraform_v1/modules/lambda_iam_role_and_policies/voutputs.tf diff --git a/terraform_v2/00_setup_remote_s3_backend_dev/dev.backend.hcl b/terraform_v2/00_setup_remote_s3_backend_dev/dev.backend.hcl index aa0bb78..4b85749 100644 --- a/terraform_v2/00_setup_remote_s3_backend_dev/dev.backend.hcl +++ b/terraform_v2/00_setup_remote_s3_backend_dev/dev.backend.hcl @@ -1,3 +1,3 @@ region = "eu-west-1" -bucket = "tf-backend-dev-genomics-bhuna" -dynamodb_table = "tf-backend-dev-genomics-bhuna" +bucket = "tf-backend-dev-stablecaps-bhuna" +dynamodb_table = "tf-backend-dev-stablecaps-bhuna" diff --git a/terraform_v2/00_setup_remote_s3_backend_dev/errored.tfstate b/terraform_v2/00_setup_remote_s3_backend_dev/errored.tfstate deleted file mode 100644 index 093174b..0000000 --- a/terraform_v2/00_setup_remote_s3_backend_dev/errored.tfstate +++ /dev/null @@ -1,392 +0,0 @@ -{ - "version": 4, - "terraform_version": "1.0.6", - "serial": 2, - "lineage": "91121643-68f3-4cd4-21be-046819483a13", - "outputs": {}, - "resources": [ - { - "module": "module.terraform_state_backend", - "mode": "data", - "type": "aws_iam_policy_document", - "name": "prevent_unencrypted_uploads", - "provider": "provider[\"registry.terraform.io/hashicorp/aws\"]", - "instances": [ - { - "index_key": 0, - "schema_version": 0, - "attributes": { - "id": "712607802", - "json": "{\n \"Version\": \"2012-10-17\",\n \"Statement\": [\n {\n \"Sid\": \"DenyIncorrectEncryptionHeader\",\n \"Effect\": \"Deny\",\n \"Action\": \"s3:PutObject\",\n \"Resource\": \"arn:aws:s3:::tf-backend-dev-genomics-haribo/*\",\n \"Principal\": {\n \"AWS\": \"*\"\n },\n \"Condition\": {\n \"StringNotEquals\": {\n \"s3:x-amz-server-side-encryption\": [\n \"AES256\",\n \"aws:kms\"\n ]\n }\n }\n },\n {\n \"Sid\": \"DenyUnEncryptedObjectUploads\",\n \"Effect\": \"Deny\",\n \"Action\": \"s3:PutObject\",\n \"Resource\": \"arn:aws:s3:::tf-backend-dev-genomics-haribo/*\",\n \"Principal\": {\n \"AWS\": \"*\"\n },\n \"Condition\": {\n \"Null\": {\n \"s3:x-amz-server-side-encryption\": \"true\"\n }\n }\n },\n {\n \"Sid\": \"EnforceTlsRequestsOnly\",\n \"Effect\": \"Deny\",\n \"Action\": \"s3:*\",\n \"Resource\": [\n \"arn:aws:s3:::tf-backend-dev-genomics-haribo/*\",\n \"arn:aws:s3:::tf-backend-dev-genomics-haribo\"\n ],\n \"Principal\": {\n \"AWS\": \"*\"\n },\n \"Condition\": {\n \"Bool\": {\n \"aws:SecureTransport\": \"false\"\n }\n }\n }\n ]\n}", - "override_json": null, - "override_policy_documents": null, - "policy_id": null, - "source_json": null, - "source_policy_documents": null, - "statement": [ - { - "actions": [ - "s3:PutObject" - ], - "condition": [ - { - "test": "StringNotEquals", - "values": [ - "AES256", - "aws:kms" - ], - "variable": "s3:x-amz-server-side-encryption" - } - ], - "effect": "Deny", - "not_actions": [], - "not_principals": [], - "not_resources": [], - "principals": [ - { - "identifiers": [ - "*" - ], - "type": "AWS" - } - ], - "resources": [ - "arn:aws:s3:::tf-backend-dev-genomics-haribo/*" - ], - "sid": "DenyIncorrectEncryptionHeader" - }, - { - "actions": [ - "s3:PutObject" - ], - "condition": [ - { - "test": "Null", - "values": [ - "true" - ], - "variable": "s3:x-amz-server-side-encryption" - } - ], - "effect": "Deny", - "not_actions": [], - "not_principals": [], - "not_resources": [], - "principals": [ - { - "identifiers": [ - "*" - ], - "type": "AWS" - } - ], - "resources": [ - "arn:aws:s3:::tf-backend-dev-genomics-haribo/*" - ], - "sid": "DenyUnEncryptedObjectUploads" - }, - { - "actions": [ - "s3:*" - ], - "condition": [ - { - "test": "Bool", - "values": [ - "false" - ], - "variable": "aws:SecureTransport" - } - ], - "effect": "Deny", - "not_actions": [], - "not_principals": [], - "not_resources": [], - "principals": [ - { - "identifiers": [ - "*" - ], - "type": "AWS" - } - ], - "resources": [ - "arn:aws:s3:::tf-backend-dev-genomics-haribo", - "arn:aws:s3:::tf-backend-dev-genomics-haribo/*" - ], - "sid": "EnforceTlsRequestsOnly" - } - ], - "version": "2012-10-17" - }, - "sensitive_attributes": [] - } - ] - }, - { - "module": "module.terraform_state_backend", - "mode": "data", - "type": "aws_region", - "name": "current", - "provider": "provider[\"registry.terraform.io/hashicorp/aws\"]", - "instances": [ - { - "schema_version": 0, - "attributes": { - "description": "Europe (Ireland)", - "endpoint": "ec2.eu-west-1.amazonaws.com", - "id": "eu-west-1", - "name": "eu-west-1" - }, - "sensitive_attributes": [] - } - ] - }, - { - "module": "module.terraform_state_backend", - "mode": "managed", - "type": "aws_dynamodb_table", - "name": "with_server_side_encryption", - "provider": "provider[\"registry.terraform.io/hashicorp/aws\"]", - "instances": [ - { - "index_key": 0, - "schema_version": 1, - "attributes": { - "arn": "arn:aws:dynamodb:eu-west-1:779934699932:table/tf-backend-dev-genomics-haribo", - "attribute": [ - { - "name": "LockID", - "type": "S" - } - ], - "billing_mode": "PAY_PER_REQUEST", - "global_secondary_index": [], - "hash_key": "LockID", - "id": "tf-backend-dev-genomics-haribo", - "local_secondary_index": [], - "name": "tf-backend-dev-genomics-haribo", - "point_in_time_recovery": [ - { - "enabled": false - } - ], - "range_key": null, - "read_capacity": 0, - "replica": [], - "restore_date_time": null, - "restore_source_name": null, - "restore_to_latest_time": null, - "server_side_encryption": [ - { - "enabled": true, - "kms_key_arn": "arn:aws:kms:eu-west-1:779934699932:key/b3133ad2-5ace-447b-88ab-cb59606c1d12" - } - ], - "stream_arn": "", - "stream_enabled": false, - "stream_label": "", - "stream_view_type": "", - "table_class": "", - "tags": { - "Attributes": "state-lock", - "Environment": "eu-west-1", - "Name": "genomics-haribo-eu-west-1-dev-terraform-state-lock", - "Namespace": "genomics-haribo", - "Stage": "dev" - }, - "tags_all": { - "Attributes": "state-lock", - "Environment": "eu-west-1", - "Name": "genomics-haribo-eu-west-1-dev-terraform-state-lock", - "Namespace": "genomics-haribo", - "Stage": "dev" - }, - "timeouts": null, - "ttl": [ - { - "attribute_name": "", - "enabled": false - } - ], - "write_capacity": 0 - }, - "sensitive_attributes": [], - "private": "eyJlMmJmYjczMC1lY2FhLTExZTYtOGY4OC0zNDM2M2JjN2M0YzAiOnsiY3JlYXRlIjoxODAwMDAwMDAwMDAwLCJkZWxldGUiOjYwMDAwMDAwMDAwMCwidXBkYXRlIjozNjAwMDAwMDAwMDAwfSwic2NoZW1hX3ZlcnNpb24iOiIxIn0=" - } - ] - }, - { - "module": "module.terraform_state_backend", - "mode": "managed", - "type": "aws_iam_role", - "name": "replication", - "provider": "provider[\"registry.terraform.io/hashicorp/aws\"]", - "instances": [] - }, - { - "module": "module.terraform_state_backend", - "mode": "managed", - "type": "aws_s3_bucket", - "name": "default", - "provider": "provider[\"registry.terraform.io/hashicorp/aws\"]", - "instances": [ - { - "index_key": 0, - "schema_version": 0, - "attributes": { - "acceleration_status": "", - "acl": "private", - "arn": "arn:aws:s3:::tf-backend-dev-genomics-haribo", - "bucket": "tf-backend-dev-genomics-haribo", - "bucket_domain_name": "tf-backend-dev-genomics-haribo.s3.amazonaws.com", - "bucket_prefix": null, - "bucket_regional_domain_name": "tf-backend-dev-genomics-haribo.s3.eu-west-1.amazonaws.com", - "cors_rule": [], - "force_destroy": true, - "grant": [ - { - "id": "e977ccd666fc5c7c681c389ce84a78c7a6019c99fd814e9a98fdacc404f33def", - "permissions": [ - "FULL_CONTROL" - ], - "type": "CanonicalUser", - "uri": "" - } - ], - "hosted_zone_id": "Z1BKCTXD74EZPE", - "id": "tf-backend-dev-genomics-haribo", - "lifecycle_rule": [], - "logging": [], - "object_lock_configuration": [], - "object_lock_enabled": false, - "policy": "{\"Version\":\"2012-10-17\",\"Statement\":[{\"Sid\":\"DenyIncorrectEncryptionHeader\",\"Effect\":\"Deny\",\"Principal\":{\"AWS\":\"*\"},\"Action\":\"s3:PutObject\",\"Resource\":\"arn:aws:s3:::tf-backend-dev-genomics-haribo/*\",\"Condition\":{\"StringNotEquals\":{\"s3:x-amz-server-side-encryption\":[\"AES256\",\"aws:kms\"]}}},{\"Sid\":\"DenyUnEncryptedObjectUploads\",\"Effect\":\"Deny\",\"Principal\":{\"AWS\":\"*\"},\"Action\":\"s3:PutObject\",\"Resource\":\"arn:aws:s3:::tf-backend-dev-genomics-haribo/*\",\"Condition\":{\"Null\":{\"s3:x-amz-server-side-encryption\":\"true\"}}},{\"Sid\":\"EnforceTlsRequestsOnly\",\"Effect\":\"Deny\",\"Principal\":{\"AWS\":\"*\"},\"Action\":\"s3:*\",\"Resource\":[\"arn:aws:s3:::tf-backend-dev-genomics-haribo/*\",\"arn:aws:s3:::tf-backend-dev-genomics-haribo\"],\"Condition\":{\"Bool\":{\"aws:SecureTransport\":\"false\"}}}]}", - "region": "eu-west-1", - "replication_configuration": [], - "request_payer": "BucketOwner", - "server_side_encryption_configuration": [ - { - "rule": [ - { - "apply_server_side_encryption_by_default": [ - { - "kms_master_key_id": "", - "sse_algorithm": "AES256" - } - ], - "bucket_key_enabled": false - } - ] - } - ], - "tags": { - "Attributes": "state", - "Environment": "eu-west-1", - "Name": "genomics-haribo-eu-west-1-dev-terraform-state", - "Namespace": "genomics-haribo", - "Stage": "dev" - }, - "tags_all": { - "Attributes": "state", - "Environment": "eu-west-1", - "Name": "genomics-haribo-eu-west-1-dev-terraform-state", - "Namespace": "genomics-haribo", - "Stage": "dev" - }, - "versioning": [ - { - "enabled": true, - "mfa_delete": false - } - ], - "website": [], - "website_domain": null, - "website_endpoint": null - }, - "sensitive_attributes": [], - "private": "bnVsbA==", - "dependencies": [ - "module.terraform_state_backend.aws_iam_role.replication", - "module.terraform_state_backend.data.aws_iam_policy_document.prevent_unencrypted_uploads", - "module.terraform_state_backend.module.log_storage.aws_s3_bucket.default" - ] - } - ] - }, - { - "module": "module.terraform_state_backend", - "mode": "managed", - "type": "aws_s3_bucket_public_access_block", - "name": "default", - "provider": "provider[\"registry.terraform.io/hashicorp/aws\"]", - "instances": [ - { - "index_key": 0, - "schema_version": 0, - "attributes": { - "block_public_acls": true, - "block_public_policy": true, - "bucket": "tf-backend-dev-genomics-haribo", - "id": "tf-backend-dev-genomics-haribo", - "ignore_public_acls": true, - "restrict_public_buckets": true - }, - "sensitive_attributes": [], - "private": "bnVsbA==", - "dependencies": [ - "module.terraform_state_backend.aws_iam_role.replication", - "module.terraform_state_backend.aws_s3_bucket.default", - "module.terraform_state_backend.data.aws_iam_policy_document.prevent_unencrypted_uploads", - "module.terraform_state_backend.module.log_storage.aws_s3_bucket.default" - ] - } - ] - }, - { - "module": "module.terraform_state_backend.module.log_storage", - "mode": "data", - "type": "aws_caller_identity", - "name": "current", - "provider": "provider[\"registry.terraform.io/hashicorp/aws\"]", - "instances": [ - { - "schema_version": 0, - "attributes": { - "account_id": "779934699932", - "arn": "arn:aws:iam::779934699932:user/gtampi", - "id": "779934699932", - "user_id": "AIDA3LF53CGOBTWYX7RZC" - }, - "sensitive_attributes": [] - } - ] - }, - { - "module": "module.terraform_state_backend.module.log_storage", - "mode": "data", - "type": "aws_partition", - "name": "current", - "provider": "provider[\"registry.terraform.io/hashicorp/aws\"]", - "instances": [ - { - "schema_version": 0, - "attributes": { - "dns_suffix": "amazonaws.com", - "id": "aws", - "partition": "aws", - "reverse_dns_prefix": "com.amazonaws" - }, - "sensitive_attributes": [] - } - ] - }, - { - "module": "module.terraform_state_backend.module.log_storage", - "mode": "managed", - "type": "aws_s3_bucket", - "name": "default", - "provider": "provider[\"registry.terraform.io/hashicorp/aws\"]", - "instances": [] - } - ] -} diff --git a/terraform_v2/00_setup_remote_s3_backend_dev/create_s3_and_dyndb_backend.tf b/terraform_v2/00_setup_remote_s3_backend_dev/ini_create_s3_and_dyndb_backend.tf similarity index 85% rename from terraform_v2/00_setup_remote_s3_backend_dev/create_s3_and_dyndb_backend.tf rename to terraform_v2/00_setup_remote_s3_backend_dev/ini_create_s3_and_dyndb_backend.tf index e737018..2000d54 100644 --- a/terraform_v2/00_setup_remote_s3_backend_dev/create_s3_and_dyndb_backend.tf +++ b/terraform_v2/00_setup_remote_s3_backend_dev/ini_create_s3_and_dyndb_backend.tf @@ -18,12 +18,11 @@ variable "terraform_backend_config_file_path" { } - module "terraform_state_backend" { source = "cloudposse/tfstate-backend/aws" version = "0.38.1" - namespace = "genomics-${var.random_string}" + namespace = "stablecaps-${var.random_string}" stage = var.env name = "terraform" attributes = ["state"] @@ -31,11 +30,11 @@ module "terraform_state_backend" { environment = "eu-west-1" dynamodb_enabled = true - dynamodb_table_name = "tf-backend-${var.env}-genomics-${var.random_string}" + dynamodb_table_name = "tf-backend-${var.env}-stablecaps-${var.random_string}" billing_mode = "PAY_PER_REQUEST" enable_point_in_time_recovery = false - s3_bucket_name = "tf-backend-${var.env}-genomics-${var.random_string}" + s3_bucket_name = "tf-backend-${var.env}-stablecaps-${var.random_string}" bucket_enabled = true block_public_acls = true block_public_policy = true 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 a42d560..e3c4c30 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 @@ -23,7 +23,7 @@ module "terraform_state_backend" { source = "cloudposse/tfstate-backend/aws" version = "0.38.1" - namespace = "genomics-${var.random_string}" + namespace = "stablecaps-${var.random_string}" stage = var.env name = "terraform" attributes = ["state"] @@ -31,11 +31,11 @@ module "terraform_state_backend" { environment = "eu-west-1" dynamodb_enabled = true - dynamodb_table_name = "tf-backend-${var.env}-genomics-${var.random_string}" + dynamodb_table_name = "tf-backend-${var.env}-stablecaps-${var.random_string}" billing_mode = "PAY_PER_REQUEST" enable_point_in_time_recovery = false - s3_bucket_name = "tf-backend-${var.env}-genomics-${var.random_string}" + s3_bucket_name = "tf-backend-${var.env}-stablecaps-${var.random_string}" bucket_enabled = true block_public_acls = true block_public_policy = true diff --git a/terraform_v2/00_setup_remote_s3_backend_prod/backend_prod.tf b/terraform_v2/00_setup_remote_s3_backend_prod/ini_backend_prod.tf similarity index 66% rename from terraform_v2/00_setup_remote_s3_backend_prod/backend_prod.tf rename to terraform_v2/00_setup_remote_s3_backend_prod/ini_backend_prod.tf index aa81dd9..f5ae575 100644 --- a/terraform_v2/00_setup_remote_s3_backend_prod/backend_prod.tf +++ b/terraform_v2/00_setup_remote_s3_backend_prod/ini_backend_prod.tf @@ -3,9 +3,9 @@ terraform { backend "s3" { region = "eu-west-1" - bucket = "tf-backend-prod-genomics-bhuna" + bucket = "tf-backend-prod-stablecaps-bhuna" key = "terraform.tfstate" - dynamodb_table = "tf-backend-prod-genomics-bhuna" + dynamodb_table = "tf-backend-prod-stablecaps-bhuna" profile = "" role_arn = "" encrypt = "true" diff --git a/terraform_v2/00_setup_remote_s3_backend_prod/prod.backend.hcl b/terraform_v2/00_setup_remote_s3_backend_prod/prod.backend.hcl index 01c576d..c4796fd 100644 --- a/terraform_v2/00_setup_remote_s3_backend_prod/prod.backend.hcl +++ b/terraform_v2/00_setup_remote_s3_backend_prod/prod.backend.hcl @@ -1,3 +1,3 @@ region = "eu-west-1" -bucket = "tf-backend-prod-genomics-bhuna" -dynamodb_table = "tf-backend-prod-genomics-bhuna" +bucket = "tf-backend-prod-stablecaps-bhuna" +dynamodb_table = "tf-backend-prod-stablecaps-bhuna" 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 2147904..ce30140 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 uniuque 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` | n/a | yes | | [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/main.tf b/terraform_v2/entrypoints/exifripper_buckets_and_iam_role/ini_create_buckets_and_perms.tf similarity index 67% rename from terraform_v2/entrypoints/exifripper_buckets_and_iam_role/main.tf rename to terraform_v2/entrypoints/exifripper_buckets_and_iam_role/ini_create_buckets_and_perms.tf index d8a0fec..a847bf1 100644 --- a/terraform_v2/entrypoints/exifripper_buckets_and_iam_role/main.tf +++ b/terraform_v2/entrypoints/exifripper_buckets_and_iam_role/ini_create_buckets_and_perms.tf @@ -1,22 +1,10 @@ -locals { - tags = { - environment = var.env - project = "genomics" - owner = "gtampi/devops" - created_by = "terraform" - } - - bucket_source = module.exif_buckets.bucket_source_name - bucket_dest = module.exif_buckets.bucket_dest_name -} - module "exif_buckets" { source = "../../modules/exif_ripper_buckets" env = var.env random_string = var.random_string - bucket_source = "genomics-source" - bucket_dest = "genomics-destination" + bucket_source = "stablecaps-source" + bucket_dest = "stablecaps-destination" tags = local.tags 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 e8fa432..d735540 100644 --- a/terraform_v2/entrypoints/exifripper_buckets_and_iam_role/variables.tf +++ b/terraform_v2/entrypoints/exifripper_buckets_and_iam_role/variables.tf @@ -4,7 +4,7 @@ variable "env" { } variable "random_string" { - description = "A random string to ensure that different people can create uniuque s3 resources" + description = "A random string to ensure that different people can create globally unique s3 resources" type = string } diff --git a/terraform_v2/entrypoints/exifripper_buckets_and_iam_role/vlocals.tf b/terraform_v2/entrypoints/exifripper_buckets_and_iam_role/vlocals.tf new file mode 100644 index 0000000..7302086 --- /dev/null +++ b/terraform_v2/entrypoints/exifripper_buckets_and_iam_role/vlocals.tf @@ -0,0 +1,11 @@ +locals { + tags = { + environment = var.env + project = "stablecaps" + owner = "DevOps" + created_by = "terraform" + } + + bucket_source = module.exif_buckets.bucket_source_name + bucket_dest = module.exif_buckets.bucket_dest_name +} diff --git a/terraform_v2/entrypoints/exifripper_buckets_and_iam_role/outputs.tf b/terraform_v2/entrypoints/exifripper_buckets_and_iam_role/voutputs.tf similarity index 100% rename from terraform_v2/entrypoints/exifripper_buckets_and_iam_role/outputs.tf rename to terraform_v2/entrypoints/exifripper_buckets_and_iam_role/voutputs.tf diff --git a/terraform_v2/entrypoints/sls_deployment_bucket/README.md b/terraform_v2/entrypoints/sls_deployment_bucket/README.md index e229610..05a59f1 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 uniuque 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` | n/a | yes | ## Outputs diff --git a/terraform_v2/entrypoints/sls_deployment_bucket/s3_serverless_holder.tf b/terraform_v2/entrypoints/sls_deployment_bucket/ini_s3_serverless_holder.tf similarity index 66% rename from terraform_v2/entrypoints/sls_deployment_bucket/s3_serverless_holder.tf rename to terraform_v2/entrypoints/sls_deployment_bucket/ini_s3_serverless_holder.tf index 9f2346d..a0d4974 100644 --- a/terraform_v2/entrypoints/sls_deployment_bucket/s3_serverless_holder.tf +++ b/terraform_v2/entrypoints/sls_deployment_bucket/ini_s3_serverless_holder.tf @@ -1,14 +1,3 @@ -locals { - tags = { - environment = var.env - project = "genomics" - owner = "gtampi/devops" - created_by = "terraform" - } - - bucket_name = "serverless-deployment-holder-${var.env}-${var.random_string}" -} - module "s3_serverless_deployment_bucket" { source = "terraform-aws-modules/s3-bucket/aws" diff --git a/terraform_v2/entrypoints/sls_deployment_bucket/variables.tf b/terraform_v2/entrypoints/sls_deployment_bucket/variables.tf index 136bfbe..b1ef3a0 100644 --- a/terraform_v2/entrypoints/sls_deployment_bucket/variables.tf +++ b/terraform_v2/entrypoints/sls_deployment_bucket/variables.tf @@ -5,6 +5,6 @@ variable "env" { } variable "random_string" { - description = "A random string to ensure that different people can create uniuque s3 resources" + description = "A random string to ensure that different people can create globally unique s3 resources" type = string } diff --git a/terraform_v2/entrypoints/sls_deployment_bucket/vlocals.tf b/terraform_v2/entrypoints/sls_deployment_bucket/vlocals.tf new file mode 100644 index 0000000..371a478 --- /dev/null +++ b/terraform_v2/entrypoints/sls_deployment_bucket/vlocals.tf @@ -0,0 +1,10 @@ +locals { + tags = { + environment = var.env + project = "stablecaps" + owner = "DevOps" + created_by = "terraform" + } + + bucket_name = "serverless-deployment-holder-${var.env}-${var.random_string}" +} diff --git a/terraform_v2/entrypoints/sls_deployment_bucket/outputs.tf b/terraform_v2/entrypoints/sls_deployment_bucket/voutputs.tf similarity index 100% rename from terraform_v2/entrypoints/sls_deployment_bucket/outputs.tf rename to terraform_v2/entrypoints/sls_deployment_bucket/voutputs.tf diff --git a/terraform_v2/envs/dev/dev.backend.hcl b/terraform_v2/envs/dev/dev.backend.hcl index aa0bb78..4b85749 100644 --- a/terraform_v2/envs/dev/dev.backend.hcl +++ b/terraform_v2/envs/dev/dev.backend.hcl @@ -1,3 +1,3 @@ region = "eu-west-1" -bucket = "tf-backend-dev-genomics-bhuna" -dynamodb_table = "tf-backend-dev-genomics-bhuna" +bucket = "tf-backend-dev-stablecaps-bhuna" +dynamodb_table = "tf-backend-dev-stablecaps-bhuna" diff --git a/terraform_v2/envs/dev/dev.tfvars b/terraform_v2/envs/dev/dev.tfvars index 959408d..c08c5a7 100644 --- a/terraform_v2/envs/dev/dev.tfvars +++ b/terraform_v2/envs/dev/dev.tfvars @@ -1,2 +1,2 @@ env = "dev" -ssm_root_prefix = "/genomics/exifripper" \ No newline at end of file +ssm_root_prefix = "/stablecaps/exifripper" diff --git a/terraform_v2/envs/prod/prod.backend.hcl b/terraform_v2/envs/prod/prod.backend.hcl index 01c576d..c4796fd 100644 --- a/terraform_v2/envs/prod/prod.backend.hcl +++ b/terraform_v2/envs/prod/prod.backend.hcl @@ -1,3 +1,3 @@ region = "eu-west-1" -bucket = "tf-backend-prod-genomics-bhuna" -dynamodb_table = "tf-backend-prod-genomics-bhuna" +bucket = "tf-backend-prod-stablecaps-bhuna" +dynamodb_table = "tf-backend-prod-stablecaps-bhuna" diff --git a/terraform_v2/envs/prod/prod.tfvars b/terraform_v2/envs/prod/prod.tfvars index 351aa61..c8dd0b5 100644 --- a/terraform_v2/envs/prod/prod.tfvars +++ b/terraform_v2/envs/prod/prod.tfvars @@ -1,2 +1,2 @@ env = "prod" -ssm_root_prefix = "/genomics/exifripper" \ No newline at end of file +ssm_root_prefix = "/stablecaps/exifripper" diff --git a/terraform_v2/modules/exif_ripper_buckets/README.md b/terraform_v2/modules/exif_ripper_buckets/README.md index c6cc1c2..c3ede61 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 uniuque 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` | n/a | yes | | [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/data.tf b/terraform_v2/modules/exif_ripper_buckets/ssm_data.tf similarity index 71% rename from terraform_v2/modules/exif_ripper_buckets/data.tf rename to terraform_v2/modules/exif_ripper_buckets/ssm_data.tf index 1e6d476..cdc69f8 100644 --- a/terraform_v2/modules/exif_ripper_buckets/data.tf +++ b/terraform_v2/modules/exif_ripper_buckets/ssm_data.tf @@ -1,10 +1,3 @@ -locals { - - bucket_source_name = "${var.bucket_source}-${var.env}-${var.random_string}" - bucket_dest_name = "${var.bucket_dest}-${var.env}-${var.random_string}" - -} - resource "aws_ssm_parameter" "bucket_source" { name = "${var.ssm_root_prefix}/${var.env}/bucketsource" type = "String" @@ -21,4 +14,4 @@ resource "aws_ssm_parameter" "bucket_dest" { overwrite = true tags = var.tags -} \ No newline at end of file +} diff --git a/terraform_v2/modules/exif_ripper_buckets/variables.tf b/terraform_v2/modules/exif_ripper_buckets/variables.tf index c8ae054..1e4cdee 100644 --- a/terraform_v2/modules/exif_ripper_buckets/variables.tf +++ b/terraform_v2/modules/exif_ripper_buckets/variables.tf @@ -4,7 +4,7 @@ variable "env" { } variable "random_string" { - description = "A random string to ensure that different people can create uniuque s3 resources" + description = "A random string to ensure that different people can create globally unique s3 resources" type = string } @@ -27,4 +27,4 @@ variable "ssm_root_prefix" { variable "tags" { description = "A map that is used to apply tags to resources created by terraform" type = map(string) -} \ No newline at end of file +} diff --git a/terraform_v2/modules/exif_ripper_buckets/vlocals.tf b/terraform_v2/modules/exif_ripper_buckets/vlocals.tf new file mode 100644 index 0000000..45e36c0 --- /dev/null +++ b/terraform_v2/modules/exif_ripper_buckets/vlocals.tf @@ -0,0 +1,6 @@ +locals { + + bucket_source_name = "${var.bucket_source}-${var.env}-${var.random_string}" + bucket_dest_name = "${var.bucket_dest}-${var.env}-${var.random_string}" + +} diff --git a/terraform_v2/modules/exif_ripper_buckets/outputs.tf b/terraform_v2/modules/exif_ripper_buckets/voutputs.tf similarity index 100% rename from terraform_v2/modules/exif_ripper_buckets/outputs.tf rename to terraform_v2/modules/exif_ripper_buckets/voutputs.tf