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

api_gateway_rest_api: Adds parameter fail_on_warnings [rebased] #22300

Closed
wants to merge 5 commits into from
Closed

api_gateway_rest_api: Adds parameter fail_on_warnings [rebased] #22300

wants to merge 5 commits into from

Conversation

fullammo
Copy link
Contributor

@fullammo fullammo commented Dec 21, 2021

Community Note

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

Closes #19154.
Closes #22674.
Closes #18397.

This PR is an up to date version of PR#18397, which complies to the mentioned refactoring changes that had to be addressed.

Output from acceptance testing:

% make testacc TESTS=TestAccAPIGatewayRestApi_Fail_On_Warnings PKG=apigateway
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./internal/service/apigateway/... -v -count 1 -parallel 20 -run='TestAccAPIGatewayRestApi_Fail_On_Warnings' -timeout 180m
=== RUN   TestAccAPIGatewayRestApi_Fail_On_Warnings
=== PAUSE TestAccAPIGatewayRestApi_Fail_On_Warnings
=== CONT  TestAccAPIGatewayRestApi_Fail_On_Warnings
--- PASS: TestAccAPIGatewayRestApi_Fail_On_Warnings (58.65s)
PASS
ok      github.com/hashicorp/terraform-provider-aws/internal/service/apigateway 61.240s

@johanwiren This was the easiest way to resolve your merge conflicts, I hope it's not a problem. 😄

@github-actions github-actions bot added documentation Introduces or discusses updates to documentation. service/apigateway Issues and PRs that pertain to the apigateway service. tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure. size/M Managed by automation to categorize the size of a PR. needs-triage Waiting for first response or review from a maintainer. labels Dec 21, 2021
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 @fullammo 👋

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 CONTRIBUTING 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! 😃

@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 Jan 13, 2022
@AdamTylerLynch AdamTylerLynch self-assigned this Jul 17, 2022
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 🚀

After closer review, changes will be needed.

@fullammo
Copy link
Contributor Author

Awesome! Could this change be included in one of the upcoming releases? Thanks in advance!

@fullammo
Copy link
Contributor Author

fullammo commented Aug 3, 2022

There were merge conflicts, i resolved them by rebasing the codebase to the latest main, just to make the merge a bit smoother 🥇

@michael-rivera-florencehc-com

Any updates on this? We can use this as well, and it would help a bunch?

@thxmike
Copy link

thxmike commented Jan 16, 2023

This would be a good feature to implement to prevent any deployment issues. Please merge this in

@DaniBencz
Copy link

It would be an improvement to the current behavior that 'swallows' warnings. Our team could benefit from it.

@njovanovic-fhc
Copy link

Hey team, any update on this? Our team can utilise this as well...

@somaSzolyak
Copy link

Hello!

This feature would help our team as well!

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.

AWS's API requires first creating a REST API and then updating that API if an OpenAPI spec is supplied.

Terraform's implementation of this resource is aligned to that intended use, where Terraform first creates a REST API (without an OpenAPI definition) and then if a OpenAPI definition is supplied immediately updates the API using the OpenAPI definition.

A failOnWarning during create would most likely result in an empty REST API, as the rollback would rollback the OpenAPI application step.

A failOnWarning during update would result in the expected behavior, but would leave the Terraform state in an inconsistent state. My hypothesis is the author saw this inconsistent state when testing, and this is why they removed the computed field from create_date.

Implementation of this failOnWarning feature introduces to many permutations of the potential resource and state due to the AWS APIs requirements, and this would require significant more AccTests to provide surety on permutation coverage.

internal/service/apigateway/rest_api.go Show resolved Hide resolved
@@ -55,7 +55,10 @@ func ResourceRestAPI() *schema.Resource {
},
"created_date": {
Type: schema.TypeString,
Computed: true,

"fail_on_warnings": {
Copy link
Collaborator

@AdamTylerLynch AdamTylerLynch Jan 23, 2023

Choose a reason for hiding this comment

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

It's important to note that the failOnWarnings parameter only applies to AWS's PutRestApi() method when using an OpenAPI definition. This is an update of an existing API only.

AWS's API requires first creating a REST API and then updating that API if an OpenAPI spec is supplied.

Terraform's implementation of this resource is aligned to that intended use, where Terraform first creates a REST API (without an OpenAPI definition) and then if a OpenAPI definition is supplied immediately updates the API using the OpenAPI definition.

@@ -229,6 +229,7 @@ The following arguments are supported:
* `endpoint_configuration` - (Optional) Configuration block defining API endpoint configuration including endpoint type. Defined below.
* `minimum_compression_size` - (Optional) Minimum response size to compress for the REST API. Integer between `-1` and `10485760` (10MB). Setting a value greater than `-1` will enable compression, `-1` disables compression (default). If importing an OpenAPI specification via the `body` argument, this corresponds to the [`x-amazon-apigateway-minimum-compression-size` extension](https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-openapi-minimum-compression-size.html). If the argument value (_except_ `-1`) is provided and is different than the OpenAPI value, the argument value will override the OpenAPI value.
* `name` - (Required) Name of the REST API. If importing an OpenAPI specification via the `body` argument, this corresponds to the `info.title` field. If the argument value is different than the OpenAPI value, the argument value will override the OpenAPI value.
* `fail_on_warnings` - (Optional) Whether warnings while API Gateway is creating or updating the resource should return an error or not. Defaults to `false`
Copy link
Collaborator

Choose a reason for hiding this comment

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

In our documentation, arguments are listed in alphabetical order. This argument should come after endpoint_configuration and before minimum_compression_size.

website/docs/r/api_gateway_rest_api.html.markdown Outdated Show resolved Hide resolved
@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 11, 2023
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. service/apigateway Issues and PRs that pertain to the apigateway service. size/M 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
9 participants