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

r/aws_sfn_state_machine: validate step-function definition at plan step #39229

Merged

Conversation

kevineor
Copy link
Contributor

@kevineor kevineor commented Sep 9, 2024

Description

This PR adds a validation in the plan step for aws_sfn_state_machine ressource.

This validation uses the newly aws provided API ValidateStateMachineDefinition to validate the state machine definition.
The validation takes place in the CustomizeDiff function and will fail the terraform plan and output the list of errors or warnings returned by the API.

However it does not cover the case where only WARNING are returned by the API, as it is not considered as an error.
As a result it won't fail or log any warnings.

Improvements to discuss

We could add the possibility to log the warnings returned by the API, but it would require to migrate the ressource to the terraform-plugin-framework.
We would migrate this validation to the ModifyPlan step and logging all warnings and errors to resource.ModifyPlanResponse.

Let me know if a such improvement is required.

Relations

Closes #39150

References

https://aws.amazon.com/about-aws/whats-new/2024/08/validation-api-step-functions/?nc1=h_ls
https://docs.aws.amazon.com/step-functions/latest/apireference/API_ValidateStateMachineDefinition.html

Output from Acceptance Testing

% make testacc PKG=sfn
make: Verifying source code with gofmt...
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go1.23.0 test ./internal/service/sfn/... -v -count 1 -parallel 20   -timeout 360m
=== RUN   TestAccSFNActivityDataSource_basic
=== PAUSE TestAccSFNActivityDataSource_basic
=== RUN   TestAccSFNActivity_basic
=== PAUSE TestAccSFNActivity_basic
=== RUN   TestAccSFNActivity_disappears
=== PAUSE TestAccSFNActivity_disappears
=== RUN   TestAccSFNActivity_tags
=== PAUSE TestAccSFNActivity_tags
=== RUN   TestAccSFNActivity_encryptionConfigurationCustomerManagedKMSKey
--- PASS: TestAccSFNActivity_encryptionConfigurationCustomerManagedKMSKey (74.87s)
=== RUN   TestAccSFNActivity_encryptionConfigurationServiceOwnedKey
--- PASS: TestAccSFNActivity_encryptionConfigurationServiceOwnedKey (69.83s)
=== RUN   TestAccSFNAliasDataSource_basic
=== PAUSE TestAccSFNAliasDataSource_basic
=== RUN   TestAccSFNAlias_basic
=== PAUSE TestAccSFNAlias_basic
=== RUN   TestAccSFNAlias_disappears
=== PAUSE TestAccSFNAlias_disappears
=== RUN   TestEndpointConfiguration
=== RUN   TestEndpointConfiguration/package_name_endpoint_config_overrides_base_envvar
=== RUN   TestEndpointConfiguration/alias_name_0_endpoint_config_overrides_base_envvar
=== RUN   TestEndpointConfiguration/base_endpoint_envvar
=== RUN   TestEndpointConfiguration/no_config
=== RUN   TestEndpointConfiguration/package_name_endpoint_config
=== RUN   TestEndpointConfiguration/package_name_endpoint_config_overrides_aws_service_envvar
=== RUN   TestEndpointConfiguration/base_endpoint_envvar_overrides_base_config_file
=== RUN   TestEndpointConfiguration/service_config_file
=== RUN   TestEndpointConfiguration/service_config_file_overrides_base_config_file
=== RUN   TestEndpointConfiguration/base_endpoint_config_file
=== RUN   TestEndpointConfiguration/package_name_endpoint_config_overrides_alias_name_0_config
=== RUN   TestEndpointConfiguration/package_name_endpoint_config_overrides_base_config_file
=== RUN   TestEndpointConfiguration/alias_name_0_endpoint_config
=== RUN   TestEndpointConfiguration/service_aws_envvar_overrides_service_config_file
=== RUN   TestEndpointConfiguration/service_aws_envvar_overrides_base_config_file
=== RUN   TestEndpointConfiguration/base_endpoint_envvar_overrides_service_config_file
=== RUN   TestEndpointConfiguration/use_fips_config
=== RUN   TestEndpointConfiguration/package_name_endpoint_config_overrides_service_config_file
=== RUN   TestEndpointConfiguration/alias_name_0_endpoint_config_overrides_aws_service_envvar
=== RUN   TestEndpointConfiguration/alias_name_0_endpoint_config_overrides_base_config_file
=== RUN   TestEndpointConfiguration/use_fips_config_with_package_name_endpoint_config
=== RUN   TestEndpointConfiguration/alias_name_0_endpoint_config_overrides_service_config_file
=== RUN   TestEndpointConfiguration/service_aws_envvar
=== RUN   TestEndpointConfiguration/service_aws_envvar_overrides_base_envvar
--- PASS: TestEndpointConfiguration (0.92s)
    --- PASS: TestEndpointConfiguration/package_name_endpoint_config_overrides_base_envvar (0.06s)
    --- PASS: TestEndpointConfiguration/alias_name_0_endpoint_config_overrides_base_envvar (0.04s)
    --- PASS: TestEndpointConfiguration/base_endpoint_envvar (0.03s)
    --- PASS: TestEndpointConfiguration/no_config (0.03s)
    --- PASS: TestEndpointConfiguration/package_name_endpoint_config (0.04s)
    --- PASS: TestEndpointConfiguration/package_name_endpoint_config_overrides_aws_service_envvar (0.04s)
    --- PASS: TestEndpointConfiguration/base_endpoint_envvar_overrides_base_config_file (0.03s)
    --- PASS: TestEndpointConfiguration/service_config_file (0.03s)
    --- PASS: TestEndpointConfiguration/service_config_file_overrides_base_config_file (0.03s)
    --- PASS: TestEndpointConfiguration/base_endpoint_config_file (0.03s)
    --- PASS: TestEndpointConfiguration/package_name_endpoint_config_overrides_alias_name_0_config (0.04s)
    --- PASS: TestEndpointConfiguration/package_name_endpoint_config_overrides_base_config_file (0.04s)
    --- PASS: TestEndpointConfiguration/alias_name_0_endpoint_config (0.04s)
    --- PASS: TestEndpointConfiguration/service_aws_envvar_overrides_service_config_file (0.03s)
    --- PASS: TestEndpointConfiguration/service_aws_envvar_overrides_base_config_file (0.03s)
    --- PASS: TestEndpointConfiguration/base_endpoint_envvar_overrides_service_config_file (0.03s)
    --- PASS: TestEndpointConfiguration/use_fips_config (0.03s)
    --- PASS: TestEndpointConfiguration/package_name_endpoint_config_overrides_service_config_file (0.04s)
    --- PASS: TestEndpointConfiguration/alias_name_0_endpoint_config_overrides_aws_service_envvar (0.05s)
    --- PASS: TestEndpointConfiguration/alias_name_0_endpoint_config_overrides_base_config_file (0.04s)
    --- PASS: TestEndpointConfiguration/use_fips_config_with_package_name_endpoint_config (0.05s)
    --- PASS: TestEndpointConfiguration/alias_name_0_endpoint_config_overrides_service_config_file (0.04s)
    --- PASS: TestEndpointConfiguration/service_aws_envvar (0.03s)
    --- PASS: TestEndpointConfiguration/service_aws_envvar_overrides_base_envvar (0.03s)
=== RUN   TestAccSFNStateMachineDataSource_basic
=== PAUSE TestAccSFNStateMachineDataSource_basic
=== RUN   TestAccSFNStateMachine_createUpdate
=== PAUSE TestAccSFNStateMachine_createUpdate
=== RUN   TestAccSFNStateMachine_expressUpdate
=== PAUSE TestAccSFNStateMachine_expressUpdate
=== RUN   TestAccSFNStateMachine_standardUpdate
=== PAUSE TestAccSFNStateMachine_standardUpdate
=== RUN   TestAccSFNStateMachine_nameGenerated
=== PAUSE TestAccSFNStateMachine_nameGenerated
=== RUN   TestAccSFNStateMachine_namePrefix
=== PAUSE TestAccSFNStateMachine_namePrefix
=== RUN   TestAccSFNStateMachine_publish
=== PAUSE TestAccSFNStateMachine_publish
=== RUN   TestAccSFNStateMachine_tags
=== PAUSE TestAccSFNStateMachine_tags
=== RUN   TestAccSFNStateMachine_tracing
=== PAUSE TestAccSFNStateMachine_tracing
=== RUN   TestAccSFNStateMachine_disappears
=== PAUSE TestAccSFNStateMachine_disappears
=== RUN   TestAccSFNStateMachine_expressLogging
=== PAUSE TestAccSFNStateMachine_expressLogging
=== RUN   TestAccSFNStateMachine_encryptionConfigurationCustomerManagedKMSKey
--- PASS: TestAccSFNStateMachine_encryptionConfigurationCustomerManagedKMSKey (133.17s)
=== RUN   TestAccSFNStateMachine_encryptionConfigurationServiceOwnedKey
--- PASS: TestAccSFNStateMachine_encryptionConfigurationServiceOwnedKey (76.91s)
=== RUN   TestAccSFNStateMachine_definitionValidation
=== PAUSE TestAccSFNStateMachine_definitionValidation
=== RUN   TestAccSFNStateMachineVersionsDataSource_basic
=== PAUSE TestAccSFNStateMachineVersionsDataSource_basic
=== CONT  TestAccSFNActivityDataSource_basic
=== CONT  TestAccSFNStateMachine_standardUpdate
=== CONT  TestAccSFNAlias_basic
=== CONT  TestAccSFNStateMachine_createUpdate
=== CONT  TestAccSFNStateMachine_expressUpdate
=== CONT  TestAccSFNActivity_tags
=== CONT  TestAccSFNActivity_disappears
=== CONT  TestAccSFNActivity_basic
=== CONT  TestAccSFNStateMachineVersionsDataSource_basic
=== CONT  TestAccSFNStateMachine_tracing
=== CONT  TestAccSFNStateMachine_publish
=== CONT  TestAccSFNStateMachine_namePrefix
=== CONT  TestAccSFNStateMachine_nameGenerated
=== CONT  TestAccSFNAliasDataSource_basic
=== CONT  TestAccSFNAlias_disappears
=== CONT  TestAccSFNStateMachine_tags
=== CONT  TestAccSFNStateMachineDataSource_basic
=== CONT  TestAccSFNStateMachine_definitionValidation
=== CONT  TestAccSFNStateMachine_disappears
=== CONT  TestAccSFNStateMachine_expressLogging
--- PASS: TestAccSFNActivity_disappears (36.24s)
--- PASS: TestAccSFNActivityDataSource_basic (36.47s)
--- PASS: TestAccSFNActivity_basic (66.01s)
--- PASS: TestAccSFNActivity_tags (72.36s)
--- PASS: TestAccSFNStateMachine_namePrefix (74.31s)
--- PASS: TestAccSFNAlias_disappears (91.04s)
--- PASS: TestAccSFNStateMachine_definitionValidation (102.11s)
--- PASS: TestAccSFNAliasDataSource_basic (128.50s)
--- PASS: TestAccSFNStateMachine_expressUpdate (139.81s)
--- PASS: TestAccSFNStateMachine_tracing (148.10s)
--- PASS: TestAccSFNStateMachine_publish (149.05s)
--- PASS: TestAccSFNStateMachine_standardUpdate (150.25s)
--- PASS: TestAccSFNStateMachine_createUpdate (151.41s)
--- PASS: TestAccSFNStateMachine_expressLogging (159.32s)
--- PASS: TestAccSFNStateMachineDataSource_basic (159.40s)
--- PASS: TestAccSFNStateMachine_disappears (173.34s)
--- PASS: TestAccSFNStateMachine_nameGenerated (197.26s)
--- PASS: TestAccSFNAlias_basic (203.81s)
--- PASS: TestAccSFNStateMachineVersionsDataSource_basic (217.23s)
--- PASS: TestAccSFNStateMachine_tags (228.25s)
PASS
ok  	github.com/hashicorp/terraform-provider-aws/internal/service/sfn	588.474s

@kevineor kevineor requested a review from a team as a code owner September 9, 2024 17:11
@github-actions github-actions bot added tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure. service/sfn Issues and PRs that pertain to the sfn service. labels Sep 9, 2024
Copy link

github-actions bot commented Sep 9, 2024

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 the needs-triage Waiting for first response or review from a maintainer. label Sep 9, 2024
Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Welcome @kevineor 👋

It looks like this is your first Pull Request submission to the Terraform AWS Provider! If you haven’t already done so please make sure you have checked out our CONTRIBUTOR guide and FAQ to make sure your contribution is adhering to best practice and has all the necessary elements in place for a successful approval.

Also take a look at our FAQ which details how we prioritize Pull Requests for inclusion.

Thanks again, and welcome to the community! 😃

@ewbankkit ewbankkit 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 Sep 11, 2024
@ewbankkit ewbankkit self-assigned this Sep 11, 2024
@github-actions github-actions bot added the prioritized Part of the maintainer teams immediate focus. To be addressed within the current quarter. label Sep 11, 2024
Copy link
Contributor

@ewbankkit ewbankkit left a comment

Choose a reason for hiding this comment

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

LGTM 🚀.

% make testacc TESTARGS='-run=TestAccSFNStateMachine_' PKG=sfn ACCTEST_PARALLELISM=3
make: Verifying source code with gofmt...
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go1.22.6 test ./internal/service/sfn/... -v -count 1 -parallel 3  -run=TestAccSFNStateMachine_ -timeout 360m
=== RUN   TestAccSFNStateMachine_createUpdate
=== PAUSE TestAccSFNStateMachine_createUpdate
=== RUN   TestAccSFNStateMachine_expressUpdate
=== PAUSE TestAccSFNStateMachine_expressUpdate
=== RUN   TestAccSFNStateMachine_standardUpdate
=== PAUSE TestAccSFNStateMachine_standardUpdate
=== RUN   TestAccSFNStateMachine_nameGenerated
=== PAUSE TestAccSFNStateMachine_nameGenerated
=== RUN   TestAccSFNStateMachine_namePrefix
=== PAUSE TestAccSFNStateMachine_namePrefix
=== RUN   TestAccSFNStateMachine_publish
=== PAUSE TestAccSFNStateMachine_publish
=== RUN   TestAccSFNStateMachine_tags
=== PAUSE TestAccSFNStateMachine_tags
=== RUN   TestAccSFNStateMachine_tracing
=== PAUSE TestAccSFNStateMachine_tracing
=== RUN   TestAccSFNStateMachine_disappears
=== PAUSE TestAccSFNStateMachine_disappears
=== RUN   TestAccSFNStateMachine_expressLogging
=== PAUSE TestAccSFNStateMachine_expressLogging
=== RUN   TestAccSFNStateMachine_encryptionConfigurationCustomerManagedKMSKey
--- PASS: TestAccSFNStateMachine_encryptionConfigurationCustomerManagedKMSKey (125.52s)
=== RUN   TestAccSFNStateMachine_encryptionConfigurationServiceOwnedKey
--- PASS: TestAccSFNStateMachine_encryptionConfigurationServiceOwnedKey (79.54s)
=== RUN   TestAccSFNStateMachine_definitionValidation
=== PAUSE TestAccSFNStateMachine_definitionValidation
=== CONT  TestAccSFNStateMachine_createUpdate
=== CONT  TestAccSFNStateMachine_disappears
=== CONT  TestAccSFNStateMachine_definitionValidation
--- PASS: TestAccSFNStateMachine_definitionValidation (27.25s)
=== CONT  TestAccSFNStateMachine_expressLogging
--- PASS: TestAccSFNStateMachine_disappears (82.22s)
=== CONT  TestAccSFNStateMachine_namePrefix
--- PASS: TestAccSFNStateMachine_createUpdate (117.24s)
=== CONT  TestAccSFNStateMachine_tracing
--- PASS: TestAccSFNStateMachine_expressLogging (92.08s)
=== CONT  TestAccSFNStateMachine_tags
--- PASS: TestAccSFNStateMachine_namePrefix (84.27s)
=== CONT  TestAccSFNStateMachine_publish
--- PASS: TestAccSFNStateMachine_tracing (94.38s)
=== CONT  TestAccSFNStateMachine_standardUpdate
--- PASS: TestAccSFNStateMachine_tags (98.51s)
=== CONT  TestAccSFNStateMachine_nameGenerated
--- PASS: TestAccSFNStateMachine_publish (94.23s)
=== CONT  TestAccSFNStateMachine_expressUpdate
--- PASS: TestAccSFNStateMachine_nameGenerated (63.98s)
--- PASS: TestAccSFNStateMachine_standardUpdate (92.44s)
--- PASS: TestAccSFNStateMachine_expressUpdate (102.08s)
PASS
ok  	github.com/hashicorp/terraform-provider-aws/internal/service/sfn	572.803s

@ewbankkit
Copy link
Contributor

@kevineor Thanks for the contribution 🎉 👏.

@ewbankkit ewbankkit merged commit 00d6762 into hashicorp:main Sep 11, 2024
33 checks passed
@github-actions github-actions bot added this to the v5.67.0 milestone Sep 11, 2024
Copy link

This functionality has been released in v5.67.0 of the Terraform AWS Provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading.

For further feature requests or bug reports with this functionality, please create a new GitHub issue following the template. Thank you!

@github-actions github-actions bot removed the prioritized Part of the maintainer teams immediate focus. To be addressed within the current quarter. label Sep 13, 2024
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 Oct 13, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement Requests to existing resources that expand the functionality or scope. service/sfn Issues and PRs that pertain to the sfn service. tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Enhancement]: use step function validation API in planning
2 participants