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

fix: Add create_before_destroy lifecycle hook to aws_batch_compute_environment #18

Merged
merged 2 commits into from
Apr 27, 2023

Conversation

thatarchguy
Copy link
Contributor

Description

Solves #5. Also discussed in this stackoverflow question:
https://stackoverflow.com/questions/61669156/terraform-how-to-enable-deletion-of-batch-service-compute-environment

Motivation and Context

After applying and then making changes to the terraform, I am met with this error:


Error: deleting Batch Compute Environment (ec2_spot-20230302161118607200000001): : Cannot delete, found existing JobQueue relationship.
 	status code: 400, request id: d1174a9c-525b-45d5-8b4e-6830ea7a7246

No jobs are in the queue. This error is due to a dependency issue and is solved with this lifecycle hook.
To quote the stackoverflow answer:

When a resource is recreated in Terraform, it will be deleted and created in order by default. So if compute_environment_nameyou change and apply only, the computing environment on which the job queue depends temporarily does not exist, so you will die as follows. Error: Error applying plan:[...]
Therefore, compute_environment_namechange create_before_destroy = trueand specify the lifecycle explicitly.

Breaking Changes

None

How Has This Been Tested?

  • I have updated at least one of the examples/* to demonstrate and validate my change(s)
  • I have tested and validated these changes using one or more of the provided examples/* projects
  • I have executed pre-commit run -a on my pull request

@thatarchguy thatarchguy changed the title Add lifecycle to aws_batch_compute_environment fix: add lifecycle to aws_batch_compute_environment Apr 27, 2023
@thatarchguy thatarchguy changed the title fix: add lifecycle to aws_batch_compute_environment fix: Add lifecycle to aws_batch_compute_environment Apr 27, 2023
@bryantbiggs bryantbiggs changed the title fix: Add lifecycle to aws_batch_compute_environment fix: Add create_before_destroy lifecycle hook to aws_batch_compute_environment Apr 27, 2023
Copy link
Member

@bryantbiggs bryantbiggs left a comment

Choose a reason for hiding this comment

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

thank you!

@bryantbiggs bryantbiggs merged commit 614fc14 into terraform-aws-modules:master Apr 27, 2023
antonbabenko pushed a commit that referenced this pull request Apr 27, 2023
### [1.2.3](v1.2.2...v1.2.3) (2023-04-27)

### Bug Fixes

* Add `create_before_destroy` lifecycle hook to `aws_batch_compute_environment` ([#18](#18)) ([614fc14](614fc14))
@antonbabenko
Copy link
Member

This PR is included in version 1.2.3 🎉

@github-actions
Copy link

I'm going to lock this pull request because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 28, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants