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

Redeploying with different 'ec2_instance_type' fails (Terraform) #43

Closed
arm4b opened this issue Jan 31, 2023 · 6 comments
Closed

Redeploying with different 'ec2_instance_type' fails (Terraform) #43

arm4b opened this issue Jan 31, 2023 · 6 comments
Assignees
Labels
bug Something isn't working Terraform

Comments

@arm4b
Copy link
Member

arm4b commented Jan 31, 2023

User should be able to change the instance type after deploying a default one for example to right-size or increase resources.
The expectation is that the old instance will be destroyed and a new one will be created.
This however fails on Terraform's side.

Steps to reproduce

  1. Create a ST2 instance with everything by default
  2. Change ec2_instance_type: t2.large and re-run the deployment

The error

https://github.com/bitovi/operations-stackstorm/actions/runs/4058066174/jobs/6984566138#step:2:1504

Error: Provider produced inconsistent final plan

When expanding the plan for
│ module.Stackstorm-Single-VM.local_file.ansible_inventory to include new
│ values learned so far during apply, provider
│ "registry.terraform.io/hashicorp/local" produced an invalid new value for
│ .content: was cty.StringVal("bitops_servers:\n hosts:\n   3.101.57.229\n
│ vars:\n   ansible_ssh_user: ubuntu\n   ansible_ssh_private_key_file:
│ /tmp/tmpaqu6a50z/deployment/terraform/.ssh/bitops-ssh-key.pem\n
│ app_repo_name: operations-stackstorm\n   app_install_root: /home/ubuntu\n
│ ansible_python_interpreter: /usr/bin/python3"), but now
│ cty.StringVal("bitops_servers:\n hosts:\n   13.56.227.31\n vars:\n
│ ansible_ssh_user: ubuntu\n   ansible_ssh_private_key_file:
│ /tmp/tmpaqu6a50z/deployment/terraform/.ssh/bitops-ssh-key.pem\n
│ app_repo_name: operations-stackstorm\n   app_install_root: /home/ubuntu\n
│ ansible_python_interpreter: /usr/bin/python3").
│ 
│ This is a bug in the provider, which should be reported in the provider's
│ own issue tracker.
@arm4b arm4b added bug Something isn't working Terraform labels Jan 31, 2023
@arm4b
Copy link
Member Author

arm4b commented Jan 31, 2023

Re-running the job works 2nd time. It's good there are no Terraform conflicts.
So might be a relatively less complex fix to do.

@PhillypHenning
Copy link
Contributor

Yea this smells like a lifecycle block.
Will take a look now

@arm4b arm4b added this to the v0.2.0 milestone Feb 27, 2023
@arm4b
Copy link
Member Author

arm4b commented Feb 27, 2023

We couldn't find any reasonably good solutions to fix it for now.

Similar issues:

@arm4b arm4b removed this from the v0.2.0 milestone Feb 27, 2023
@PhillypHenning
Copy link
Contributor

Another way is to isolate the teraform for generating ansible files into a separate stack.

Outputs would be populated into an out file, a prehook would convert that into files that ansible could digest

@LeoDiazL
Copy link
Contributor

  • We have outputs.sh in D2EC2
    But generating something after the terraform deploy looks hackish to me, and hence, ugly.
  • IP from tf-state would be a better option. Thing here is key management. If the instance changes, does the key remains the same?

We could play with terraform depends_on or --target too.

How about this

@LeoDiazL
Copy link
Contributor

LeoDiazL commented Nov 1, 2023

Solved in latest release

@LeoDiazL LeoDiazL closed this as completed Nov 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Terraform
Projects
None yet
Development

No branches or pull requests

3 participants