Skip to content

Commit

Permalink
Added upgrade guide and applying count on bucket creation
Browse files Browse the repository at this point in the history
  • Loading branch information
dunefro committed Jun 27, 2024
1 parent 2d11854 commit fe2d94a
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
3 changes: 2 additions & 1 deletion bucket.tf
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,15 @@ 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
tags = local.tags
}

module "truefoundry_bucket" {
count = var.truefoundry_s3_enabled ? 1 : 0
source = "terraform-aws-modules/s3-bucket/aws"
version = "3.14.0"

Expand Down
2 changes: 1 addition & 1 deletion output.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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" {
Expand Down
9 changes: 9 additions & 0 deletions upgrade-guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -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]
```

0 comments on commit fe2d94a

Please sign in to comment.