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

Normalize REST API Policy JSON before unquoting #4606

Merged
merged 1 commit into from
May 22, 2018

Conversation

strongoose
Copy link
Contributor

@strongoose strongoose commented May 22, 2018

Fixes #4397

This is required to unescape non-quote characters, e.g. forward slashes
in CIDR blocks, which the AWS API escapes in its JSON responses.

Acceptance test results to follow.

@ghost ghost added the size/S Managed by automation to categorize the size of a PR. label May 22, 2018
This is required to unescape non-quote characters, e.g. forward slashes
in CIDR blocks, which the AWS API escapes in its JSON responses.

Resolves: hashicorp#4397
@ghost ghost added the size/S Managed by automation to categorize the size of a PR. label May 22, 2018
@bflad bflad added bug Addresses a defect in current functionality. service/apigateway Issues and PRs that pertain to the apigateway service. labels May 22, 2018
@bflad bflad added this to the v1.20.0 milestone May 22, 2018
@strongoose
Copy link
Contributor Author

Having trouble running acceptance tests locally for some reason, are they covered by the CI?

Copy link
Contributor

@bflad bflad left a comment

Choose a reason for hiding this comment

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

Thanks for this fix @ouroboros8!! I was able to confirm it by adjusting the existing policy acceptance test to include this condition:

      "Condition": {
          "IpAddress": {
              "aws:SourceIp": "123.123.123.123/32"
          }
      }

Which previously returned:

make testacc TEST=./aws TESTARGS='-run=TestAccAWSAPIGatewayRestApi_policy'
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./aws -v -run=TestAccAWSAPIGatewayRestApi_policy -timeout 120m
=== RUN   TestAccAWSAPIGatewayRestApi_policy
--- FAIL: TestAccAWSAPIGatewayRestApi_policy (7.22s)
	testing.go:518: Step 0 error: Error applying: 1 error(s) occurred:

		* aws_api_gateway_rest_api.test: 1 error(s) occurred:

		* aws_api_gateway_rest_api.test: error unescaping policy: invalid syntax
	testing.go:579: Error destroying resource! WARNING: Dangling resources
		may exist. The full state and error is shown below.
		Error: Error refreshing: 1 error(s) occurred:

		* aws_api_gateway_rest_api.test: 1 error(s) occurred:

		* aws_api_gateway_rest_api.test: aws_api_gateway_rest_api.test: error unescaping policy: invalid syntax

		State: <nil>
FAIL
FAIL	github.com/terraform-providers/terraform-provider-aws/aws	7.255s
make: *** [testacc] Error 1

And with the updated code:

make testacc TEST=./aws TESTARGS='-run=TestAccAWSAPIGatewayRestApi_policy'
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./aws -v -run=TestAccAWSAPIGatewayRestApi_policy -timeout 120m
=== RUN   TestAccAWSAPIGatewayRestApi_policy
--- PASS: TestAccAWSAPIGatewayRestApi_policy (25.52s)
PASS
ok  	github.com/terraform-providers/terraform-provider-aws/aws	25.555s

@bflad bflad merged commit 9439b88 into hashicorp:master May 22, 2018
bflad added a commit that referenced this pull request May 22, 2018
@azizbodal
Copy link

Awesome, thank you!!!

@bflad
Copy link
Contributor

bflad commented May 23, 2018

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

@ghost
Copy link

ghost commented Apr 5, 2020

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. Thanks!

@ghost ghost locked and limited conversation to collaborators Apr 5, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Addresses a defect in current functionality. service/apigateway Issues and PRs that pertain to the apigateway service. size/S Managed by automation to categorize the size of a PR.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

API Gateway Resource Policy JSON
3 participants