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

Feature: AWS Batch Job Definition now creates a new version instead of ForceNew #34281

Conversation

drewmullen
Copy link
Collaborator

@drewmullen drewmullen commented Nov 6, 2023

Closes #29819.
Closes #18111.
Closes #31226.

Summary

job_definition (JD) was previously a ForceNew resource on all parameters. This was interesting because when a JD is deleted in AWS the revision still lasts but is marked as inactive. In some ways, the ForceNew didnt matter because a new revision was being created. This PR modifies the behavior so that instead of deleting each revision as a new is created, we merely add a new one.

Design decisions

  • old revisions are deactivated by default (prior behavior). This can be disabled by new param deregister_on_new_revision
  • delete now deregisters all JDs with the associated name
  • testing delete function (testAccCheckJobDefinitionDestroy) now checks to see if any revisions exist and fails accordingly
  • refactored tests for naming consistency, simplicity, and better alignment with provider norms. Details below

Refactored tests

  • renamed test: _capabilitiesEC2 -> _attributes - new parent test for root level attribute checks
  • renamed test: _PlatformCapabilitiesFargate_containerPropertiesDefaults -> _ContainerProperties_fargateDefaults
  • renamed test: _PlatformCapabilities_fargate -> _ContainerProperties_fargate
  • renamed test: _ContainerProperties_advanced -> _ContainerProperties_EC2
  • renamed test: _ContainerProperties_EmptyField -> _ContainerProperties_EC2EmptyField
  • removed test: _PlatformCapabilities_ec2 -> coverage by _attributes
  • removed test: _updateForcesNewResource -> coverage by _attributes
  • removed test: _propagateTags -> coverage by _attributes
  • removed test: _NodePropertiesupdateForcesNewResource -> coverage by _NodeProperties_basic
  • removed test: createTypeContainerWithBothProperties -> added ConflictsWith which prevents setting both properties
  • removed test: _createTypeMultiNodeWithBothProperties -> added ConflictsWith which prevents setting both properties
  • removed test: _NodeProperties_advanced -> replaced by _advancedUpdate
  • removed function: testAccCheckJobDefinitionRecreated -> covered by _attributes and jd.Revision parameter
  • modified function: testAccCheckJobDefinitionDestroy now checks for all revisions to be deregistered
  • removed config: _propagateTags -> covered by _attributes
  • removed config: _containerProperties_advancedUpdate -> covered by _attributes
  • removed config: _createTypeMultiNodeWithBothProperties -> added ConflictsWith which prevents setting both properties
$ make testacc TESTS=TestAccBatchJobDefinition_ PKG=batch    
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./internal/service/batch/... -v -count 1 -parallel 20 -run='TestAccBatchJobDefinition_'  -timeout 360m
=== RUN   TestAccBatchJobDefinition_basic
=== PAUSE TestAccBatchJobDefinition_basic
=== RUN   TestAccBatchJobDefinition_attributes
=== PAUSE TestAccBatchJobDefinition_attributes
=== RUN   TestAccBatchJobDefinition_disappears
=== PAUSE TestAccBatchJobDefinition_disappears
=== RUN   TestAccBatchJobDefinition_ContainerProperties_fargateDefaults
=== PAUSE TestAccBatchJobDefinition_ContainerProperties_fargateDefaults
=== RUN   TestAccBatchJobDefinition_ContainerProperties_fargate
=== PAUSE TestAccBatchJobDefinition_ContainerProperties_fargate
=== RUN   TestAccBatchJobDefinition_ContainerProperties_EC2
=== PAUSE TestAccBatchJobDefinition_ContainerProperties_EC2
=== RUN   TestAccBatchJobDefinition_tags
=== PAUSE TestAccBatchJobDefinition_tags
=== RUN   TestAccBatchJobDefinition_ContainerProperties_EC2EmptyField
=== PAUSE TestAccBatchJobDefinition_ContainerProperties_EC2EmptyField
=== RUN   TestAccBatchJobDefinition_NodeProperties_basic
=== PAUSE TestAccBatchJobDefinition_NodeProperties_basic
=== RUN   TestAccBatchJobDefinition_NodeProperties_createTypeContainerErr
=== PAUSE TestAccBatchJobDefinition_NodeProperties_createTypeContainerErr
=== RUN   TestAccBatchJobDefinition_ContainerProperties_createTypeMultiNodeErr
=== PAUSE TestAccBatchJobDefinition_ContainerProperties_createTypeMultiNodeErr
=== CONT  TestAccBatchJobDefinition_basic
=== CONT  TestAccBatchJobDefinition_tags
=== CONT  TestAccBatchJobDefinition_ContainerProperties_fargateDefaults
=== CONT  TestAccBatchJobDefinition_ContainerProperties_EC2EmptyField
=== CONT  TestAccBatchJobDefinition_ContainerProperties_fargate
=== CONT  TestAccBatchJobDefinition_ContainerProperties_EC2
=== CONT  TestAccBatchJobDefinition_attributes
=== CONT  TestAccBatchJobDefinition_ContainerProperties_createTypeMultiNodeErr
=== CONT  TestAccBatchJobDefinition_NodeProperties_createTypeContainerErr
=== CONT  TestAccBatchJobDefinition_NodeProperties_basic
=== CONT  TestAccBatchJobDefinition_disappears
--- PASS: TestAccBatchJobDefinition_ContainerProperties_createTypeMultiNodeErr (41.23s)
--- PASS: TestAccBatchJobDefinition_NodeProperties_createTypeContainerErr (41.59s)
--- PASS: TestAccBatchJobDefinition_disappears (78.78s)
--- PASS: TestAccBatchJobDefinition_basic (93.96s)
--- PASS: TestAccBatchJobDefinition_ContainerProperties_EC2 (96.96s)
--- PASS: TestAccBatchJobDefinition_ContainerProperties_EC2EmptyField (103.81s)
--- PASS: TestAccBatchJobDefinition_NodeProperties_basic (138.26s)
--- PASS: TestAccBatchJobDefinition_tags (165.20s)
--- PASS: TestAccBatchJobDefinition_attributes (168.57s)
--- PASS: TestAccBatchJobDefinition_ContainerProperties_fargate (187.95s)
--- PASS: TestAccBatchJobDefinition_ContainerProperties_fargateDefaults (189.10s)
PASS
ok      github.com/hashicorp/terraform-provider-aws/internal/service/batch      191.249s

Copy link

github-actions bot commented Nov 6, 2023

Community Note

Voting for Prioritization

  • Please vote on this pull request by adding a 👍 reaction to the original post to help the community and maintainers prioritize this pull request.
  • Please see our prioritization guide for information on how we prioritize.
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request.

For Submitters

  • Review the contribution guide relating to the type of change you are making to ensure all of the necessary steps have been taken.
  • For new resources and data sources, use skaff to generate scaffolding with comments detailing common expectations.
  • Whether or not the branch has been rebased will not impact prioritization, but doing so is always a welcome surprise.

@github-actions github-actions bot added size/XL Managed by automation to categorize the size of a PR. documentation Introduces or discusses updates to documentation. tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure. service/batch Issues and PRs that pertain to the batch service. repository Repository modifications; GitHub Actions, developer docs, issue templates, codeowners, changelog. and removed size/XL Managed by automation to categorize the size of a PR. labels Nov 6, 2023
Copy link

github-actions bot commented Nov 6, 2023

Hey @drewmullen 👋 Thank you very much for your contribution! At times, our maintainers need to make direct edits to pull requests in order to help get it ready to be merged. Your current settings do not allow maintainers to make such edits. To help facilitate this, update your pull request to allow such edits as described in GitHub's Allowing changes to a pull request branch created from a fork documentation. (If you're using a fork owned by an organization, your organization may not allow you to change this setting. If that is the case, let us know.)

@terraform-aws-provider terraform-aws-provider bot added needs-triage Waiting for first response or review from a maintainer. external-maintainer Contribution from a trusted external contributor. labels Nov 6, 2023
@drewmullen drewmullen force-pushed the f-batch_job_definition-newVersion-not-ForceNew branch 2 times, most recently from 52900cd to 1c659ae Compare November 6, 2023 18:35
Copy link

github-actions bot commented Nov 6, 2023

Thank you for your contribution! 🚀

Please note that typically Go dependency changes are handled in this repository by dependabot or the maintainers. This is to prevent pull request merge conflicts and further delay reviews of contributions. Remove any changes to the go.mod or go.sum files and commit them into this pull request.

Additional details:

  • Check open pull requests with the dependencies label to view other dependency updates.
  • If this pull request includes an update the AWS Go SDK (or any other dependency) version, only updates submitted via dependabot will be merged. This pull request will need to remove these changes and will need to be rebased after the existing dependency update via dependabot has been merged for this pull request to be reviewed.
  • If this pull request is for supporting a new AWS service:
    • Ensure the new AWS service changes are following the Contributing Guide section on new services, in particular that the dependency addition and initial provider support are in a separate pull request from other changes (e.g. new resources). Contributions not following this item will not be reviewed until the changes are split.
    • If this pull request is already a separate pull request from the above item, you can ignore this message.

@drewmullen drewmullen force-pushed the f-batch_job_definition-newVersion-not-ForceNew branch from 1c659ae to cfc5f9b Compare November 6, 2023 18:36
@github-actions github-actions bot added size/XL Managed by automation to categorize the size of a PR. and removed repository Repository modifications; GitHub Actions, developer docs, issue templates, codeowners, changelog. labels Nov 6, 2023
@drewmullen drewmullen force-pushed the f-batch_job_definition-newVersion-not-ForceNew branch from e6abee4 to 3ff51c1 Compare November 6, 2023 19:48
@justinretzolk justinretzolk added enhancement Requests to existing resources that expand the functionality or scope. and removed needs-triage Waiting for first response or review from a maintainer. labels Nov 7, 2023
Copy link
Collaborator

@AdamTylerLynch AdamTylerLynch left a comment

Choose a reason for hiding this comment

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

LGTM 🚀

Copy link
Member

@bschaatsbergen bschaatsbergen left a comment

Choose a reason for hiding this comment

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

Great pull request, @drewmullen! I believe the behavior you're suggesting aligns better with AWS's intentions. I've made a couple of comments in passing. I'll let a core member who merges this handle the integration test runs 👍🏼.

internal/service/batch/job_definition.go Outdated Show resolved Hide resolved
internal/service/batch/job_definition.go Outdated Show resolved Hide resolved
internal/service/batch/job_definition.go Show resolved Hide resolved
website/docs/r/batch_job_definition.html.markdown Outdated Show resolved Hide resolved
internal/service/batch/job_definition.go Outdated Show resolved Hide resolved
drewmullen and others added 2 commits November 8, 2023 16:44
Co-authored-by: Bruno Schaatsbergen <58337159+bschaatsbergen@users.noreply.github.com>
Co-authored-by: Bruno Schaatsbergen <58337159+bschaatsbergen@users.noreply.github.com>
@drewmullen drewmullen force-pushed the f-batch_job_definition-newVersion-not-ForceNew branch from 95778a4 to f304e9e Compare November 22, 2023 17:33
@drewmullen
Copy link
Collaborator Author

im going to rebase and strip out some of the changes in this PR into smaller PRs

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 Jan 19, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
documentation Introduces or discusses updates to documentation. enhancement Requests to existing resources that expand the functionality or scope. external-maintainer Contribution from a trusted external contributor. service/batch Issues and PRs that pertain to the batch service. size/XL Managed by automation to categorize the size of a PR. tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure.
Projects
None yet
6 participants