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

add: allow existing bucket names as array #276

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

berkguzel
Copy link

Fixes #275

This PR allows you to apply terraform code one time to scan several existing s3 buckets.

existing.sh script will ask you to provide existing s3 bucket names in a format like below.

 Bucket names: s3-bucket-protection-test s3-bucket-protection-test-test  

Copy link
Contributor

@ryanjpayne ryanjpayne left a comment

Choose a reason for hiding this comment

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

I've been working on this same approach and there are two issues:

  1. Buckets outside of current Region context will throw 301 in data.aws_s3_bucket.bucket. This means the user can only provide buckets in the same region as the current AWS CLI configuration.
  2. Running more than once (say to configure for multiple regions) will fail because the IAM resource names are not unique for each run.

A fix could be:

  • make any global resource names unique
  • require that the existing.sh is run for each region separately
    Issues with this approach:
  • the tf would need to be copied in a new location each time as the existing state file will cause the new region to fail
  • duplicate iam resources is not ideal

@ryanjpayne
Copy link
Contributor

a better approach would be to use modules. one module for infra, one module to set up bucket. infra module is only called once, while the bucket module is called foreach and everytime a bucket needs to be added going forward

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.

Allow passing multiple existing bucket names
2 participants