From fe2d94a7671c4577a1b8a808283affdd93d6b56a Mon Sep 17 00:00:00 2001 From: Vedant Pareek Date: Thu, 27 Jun 2024 20:21:28 +0530 Subject: [PATCH] Added upgrade guide and applying count on bucket creation --- bucket.tf | 3 ++- output.tf | 2 +- upgrade-guide.md | 9 +++++++++ 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/bucket.tf b/bucket.tf index 691beb8..ff33627 100644 --- a/bucket.tf +++ b/bucket.tf @@ -41,7 +41,7 @@ data "aws_iam_policy_document" "truefoundry_bucket_policy" { } resource "aws_iam_policy" "truefoundry_bucket_policy" { - count = var.truefoundry_iam_role_enabled ? 1 : 0 + count = var.truefoundry_iam_role_enabled ? var.truefoundry_s3_enabled ? 1 : 0 : 0 name_prefix = "${local.truefoundry_unique_name}-access-to-bucket" description = "IAM policy for TrueFoundry bucket" policy = data.aws_iam_policy_document.truefoundry_bucket_policy.json @@ -49,6 +49,7 @@ resource "aws_iam_policy" "truefoundry_bucket_policy" { } module "truefoundry_bucket" { + count = var.truefoundry_s3_enabled ? 1 : 0 source = "terraform-aws-modules/s3-bucket/aws" version = "3.14.0" diff --git a/output.tf b/output.tf index 8c112a1..74fffd3 100644 --- a/output.tf +++ b/output.tf @@ -32,7 +32,7 @@ output "truefoundry_db_password" { } output "truefoundry_bucket_id" { - value = module.truefoundry_bucket.s3_bucket_id + value = var.truefoundry_s3_enabled ? module.truefoundry_bucket[0].s3_bucket_id : "" } output "truefoundry_iam_role_arn" { diff --git a/upgrade-guide.md b/upgrade-guide.md index 35fa9a6..fe75a75 100644 --- a/upgrade-guide.md +++ b/upgrade-guide.md @@ -16,4 +16,13 @@ echo "Doing this for resource $i" terragrunt state mv module.truefoundry_oidc_iam.aws_iam_role_policy_attachment.custom[$i] module.truefoundry_oidc_iam[0].aws_iam_role_policy_attachment.custom[$i] echo "Resource $i is moved" done + +terragrunt state mv module.truefoundry_bucket.aws_s3_bucket.this[0] module.truefoundry_bucket[0].aws_s3_bucket.this[0] +terragrunt state mv module.truefoundry_bucket.aws_s3_bucket_cors_configuration.this[0] module.truefoundry_bucket[0].aws_s3_bucket_cors_configuration.this[0] +terragrunt state mv module.truefoundry_bucket.aws_s3_bucket_intelligent_tiering_configuration.this module.truefoundry_bucket[0].aws_s3_bucket_intelligent_tiering_configuration.this +terragrunt state mv module.truefoundry_bucket.aws_s3_bucket_lifecycle_configuration.this[0] module.truefoundry_bucket[0].aws_s3_bucket_lifecycle_configuration.this[0] +terragrunt state mv module.truefoundry_bucket.aws_s3_bucket_policy.this[0] module.truefoundry_bucket[0].aws_s3_bucket_policy.this[0] +terragrunt state mv module.truefoundry_bucket.aws_s3_bucket_public_access_block.this[0] module.truefoundry_bucket[0].aws_s3_bucket_public_access_block.this[0] +terragrunt state mv module.truefoundry_bucket.aws_s3_bucket_server_side_encryption_configuration.this[0] module.truefoundry_bucket[0].aws_s3_bucket_server_side_encryption_configuration.this[0] +terragrunt state mv module.truefoundry_bucket.aws_s3_bucket_versioning.this[0] module.truefoundry_bucket[0].aws_s3_bucket_versioning.this[0] ``` \ No newline at end of file