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

Region specified with -r not fully honoured in bootstrapping #37

Open
craig-jones-bjss opened this issue Jul 13, 2022 · 2 comments
Open

Comments

@craig-jones-bjss
Copy link

craig-jones-bjss commented Jul 13, 2022

When bootstrapping for the first time, it's possible to get into a state where the S3 state bucket when initially created has the correct name but is placed in the wrong region.

When the region is specified via -r <region> the expectation is that this is honoured throughout all areas of the bootstrap.

However, if you have a different region specified in any of the .tfvars file within etc (such as global.tfvars) the S3 bootstrapping bucket ends up associated to this region, not the region that was specified by -r flag.

I would have the expectation that the -r flag overrides any other regions it adopts from .tfvars as an explicit value and overrides any picked up through vars.

The bucket is placed in the expected region if the -r value and any it finds in .tfvars matches up

Tested in version:

  • v1.7.0

Steps to reproduce:

  • Edit ./etc/global.tfvars and amend the value for region to region = eu-west-1
  • Run bootstrapping command ./bin/terraform.sh --bootstrap -r us-east-1 -p myproject -a plan

Expected:

  • S3 bucket for storing state is created in the region specified by -r - us-east-1

Actual:

  • S3 bucket for storing state is created in the region specified in .tfvars files picked up in the project - eu-west-1
  • S3 bucket name created does however have the expected name ending in us-east-1
@dickymoore
Copy link

dickymoore commented Jul 19, 2022

I'm not sure whether the -r argument is there just for naming of the bucket? If so, would it be better for the region variable to be taken from the tfvars file rather than the argument passed in with -r?

@jack-parsons-bjss
Copy link

Would it be fine to override whatever is in the var files? We could pass -var "region=" so this mismatch wouldn't ever happen - is there a use case for mismatching regions between the two?

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

No branches or pull requests

3 participants