Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow setting the full name of the S3 bucket #47

Merged
merged 2 commits into from
Apr 19, 2024

Conversation

Chili-Man
Copy link
Contributor

@Chili-Man Chili-Man commented Feb 6, 2024

What does this PR do?

This allows to respect the var.source_bucket_name as full bucket name instead of just the prefix.
This addresses #46 and does it in a backwards compatible way.

Motivation

When setting var.source_bucket_name, it turns out that it's only setting the bucket name prefix (see here) and not the actual name of the bucket. I'm not sure why the behavior is different given the variable's name and description. The other name variables, var.name and var.iam_role_name, are respected and passed through as the names for those resources, so I'm not sure why it's inconsistent for the s3 bucket.

More

  • Yes, I have tested the PR using my local account setup (Provide any test evidence report under Additional Notes)
  • Yes, I ran pre-commit run -a with this PR

For Moderators

  • E2E Test successfully complete before merge?

Additional Notes

There are 3 cases to consider for the name of the s3 bucket:

  1. When var.source_bucket_name == null, the value of var.use_source_bucket_name_as_prefix does not matter. In this case, we default to the original behavior of setting the default name prefix for the bucket.
  # module.mwaa.aws_s3_bucket.mwaa[0] will be created
  + resource "aws_s3_bucket" "mwaa" {
      + acceleration_status         = (known after apply)
      + acl                         = (known after apply)
      + arn                         = (known after apply)
      + bucket                      = (known after apply)
      + bucket_domain_name          = (known after apply)
      + bucket_prefix               = "mwaa-293664699268-"
      + bucket_regional_domain_name = (known after apply)
      + force_destroy               = false
      + hosted_zone_id              = (known after apply)
      + id                          = (known after apply)
      + object_lock_enabled         = (known after apply)
      + policy                      = (known after apply)
      + region                      = (known after apply)
      + request_payer               = (known after apply)
  1. When var.source_bucket_name != null and var.use_source_bucket_name_as_prefix == true . In this case, the original module behavior of setting var.source_bucket_name as the bucket name prefix.
  # module.mwaa.aws_s3_bucket.mwaa[0] will be created
  + resource "aws_s3_bucket" "mwaa" {
      + acceleration_status         = (known after apply)
      + acl                         = (known after apply)
      + arn                         = (known after apply)
      + bucket                      = (known after apply)
      + bucket_domain_name          = (known after apply)
      + bucket_prefix               = "cool-awesome-bucket-name"
      + bucket_regional_domain_name = (known after apply)
      + force_destroy               = false
      + hosted_zone_id              = (known after apply)
      + id                          = (known after apply)
      + object_lock_enabled         = (known after apply)
      + policy                      = (known after apply)
      + region                      = (known after apply)
      + request_payer               = (known after apply)
  1. When var.source_bucket_name != null and var.use_source_bucket_name_as_prefix == false. In this case, the new behavior is to set the full bucket name as var.source_bucket_name .
  # module.mwaa.aws_s3_bucket.mwaa[0] will be created
  + resource "aws_s3_bucket" "mwaa" {
      + acceleration_status         = (known after apply)
      + acl                         = (known after apply)
      + arn                         = (known after apply)
      + bucket                      = "cool-awesome-bucket-name"
      + bucket_domain_name          = (known after apply)
      + bucket_prefix               = (known after apply)
      + bucket_regional_domain_name = (known after apply)
      + force_destroy               = false
      + hosted_zone_id              = (known after apply)
      + id                          = (known after apply)
      + object_lock_enabled         = (known after apply)
      + policy                      = (known after apply)
      + region                      = (known after apply)
      + request_payer               = (known after apply)

Copy link
Collaborator

@vara-bonthu vara-bonthu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Please confirm if these changes are tested with all the s3 bucket name options. 🙏

@vara-bonthu vara-bonthu merged commit a77bfe8 into aws-ia:main Apr 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants