Open nomeelnoj opened 6 months ago
Voting for Prioritization
Volunteering to Work on This Issue
A quick update. Turns out the replace_triggered_by
does not actually work here. Our batch module conditionally creates the launch template only if the module instantiation requires it--as you can create a batch compute environment without custom user data, and therefore no launch template required.
By setting the replace_triggered_by
to aws_launch_template.default[each.key]
, we run into the following error when the module is called for states that do not have launch template configurations:
╷
│ Error: no change found for aws_launch_template.default["foobar"] in module.batch
│
│
╵
Trying to find a workaround now to support our various use cases--both with and without launch templates, but figured it was worth posting as it provides additional evidence for the necessity of this fix.
I opened a similar issue #39470 . Not sure if that's the same bug.
Terraform Core Version
1.8.2
AWS Provider Version
5.49.0
Affected Resource(s)
aws_batch_compute_environment aws_launch_template
Expected Behavior
When updating the launch template associated with a compute environment and pointing the compute environment to the
default_version
, and also having the launch_template set to update_default_version, the compute environment should be recreated and no error should occur.Actual Behavior
The compute environment is NOT recreated, and terraform throws "Provider produced inconsistent final plan"
Relevant Error/Panic Output Snippet
Terraform Configuration Files
Steps to Reproduce
user_data
so that thelaunch_template
updates and wants to create a new versionThe first plan shows:
As you can see above, there is no "recreation" of resource, but it is an update of a field that is immutable.
After the error, if you run another plan, at this point the launch template has been updated so the value is known:
As you can see above, there is a known value this time (3), and it triggers a replacement correctly, and there is no error.
Solution
To resolve this issue, we can use a simple
replace_triggered_by
, which produces the following plan:However, I feel that this should be something handled by the provider, versus us having to implement our own solution.
Debug Output
No response
Panic Output
No response
Important Factoids
No response
References
No response
Would you like to implement a fix?
No