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
AWS loadbalancer- change region #7517
Comments
This was also asked at https://stackoverflow.com/questions/54650350/aws-load-balancer-change-region-with-terraform but, as mentioned in my comment there, I'm not sure what Terraform should really do in this situation. In this particular case it's failing because Terraform, during the refresh, is attempting to find the load balancer by an ARN that includes the previous region which is not valid at the AWS API side so it errors out hard. I'd expect the same behaviour for any other resource where the Read/Describe call is done by ARN and the ARN includes the region (eg not global resources). I'm less confident what the behaviour is for every other resource. Does it just say it can't find eg an instance with id |
I believe this explanation does make sense.
I hadn't even thought of that before, so I created another minimal terraform script that just deploys an instance. Your suspicions were correct. Terraform does create a completly new instance on the new region, without deleting the instance in the old region. After verifying this, I checked the state file, and I noticed that it contains only one instance (in the new region). |
I'm leaning towards thinking Terraform shouldn't do anything different in this scenario largely because the same argument could be said for running with credentials for a different AWS account or any number of things that Terraform would need to detect the drift on. That said it is a bit of a footgun and I don't know the best way to educate people on this or to protect around it happening. In my case I call Terraform through some simple shell scripts and hard-code regions for different areas where I'm applying changes to so the region configuration is in code and we protect against different AWS account usage by using the |
I understand and, to some degree, I even share the same opinion. This is an edge case that I doubt happens often. I simply found it by accident, and I was curious about the reasons that led to this behaviour, as it is not what I originally expected. In any case, I appreciate your support :). |
Thank you for using Terraform and for opening up this question! It looks appears @tomelliff has provided an answer to your question. Issues on GitHub are intended to be related to bugs or feature requests with the provider codebase. If you'd like additional feedback, please use https://discuss.hashicorp.com/c/terraform-providers for community discussions, and questions around Terraform. If you believe that your issue was miscategorized as a question or closed in error, please create a new issue using one of the following provided templates: bug report or feature request. Please make sure to provide us with the appropriate information so we can best determine how to assist with the given issue. |
I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. Thanks! |
This issue was originally opened by @rafaelmarques7 as hashicorp/terraform#20304. It was migrated here as a result of the provider split. The original body of the issue is below.
Hello,
I have a Terraform module that provisions an Auto-Scaling group and all the necessary infrastructure to support it on AWS. Usually, Terraform is quite good at detecting changes in the infrastructure code. However, today I noticed that, if Terraform is managing a load-balancer, a change in the region will lead to an error.
I constructed a minimal example to replicate the error (this example requires a valid AWS profile).
Below I provide all the necessary information to reproduce and debug the error. I will also be available to provide any other information or anything else.
Terraform Version
Terraform Configuration Files
Debug Output
link: https://gist.github.com/rafaelmarques7/8cab664b14bf9d540252b36b3a000436
Crash Output
Error:
Expected Behavior
I would expect Terraform to migrate all the infrastructure to the new region.
Actual Behavior
Terraform throws an error. Nothing happens.
Steps to Reproduce
Additional Context
References
There is an open ticket on stackoverflow: https://stackoverflow.com/questions/54650350/aws-load-balancer-change-region-with-terraform
The text was updated successfully, but these errors were encountered: