-
Notifications
You must be signed in to change notification settings - Fork 9.3k
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
New resource: aws_apigatewayv2_api_mapping #9461
New resource: aws_apigatewayv2_api_mapping #9461
Conversation
Includes
|
1ec8a49
to
84d856d
Compare
Rebased to fix merge conflict. $ make testacc TEST=./aws/ TESTARGS='-run=TestAccAWSAPIGateway2ApiMapping_'
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./aws/ -v -parallel 20 -run=TestAccAWSAPIGateway2ApiMapping_ -timeout 120m
=== RUN TestAccAWSAPIGateway2ApiMapping_basic
=== PAUSE TestAccAWSAPIGateway2ApiMapping_basic
=== RUN TestAccAWSAPIGateway2ApiMapping_ApiMappingKey
=== PAUSE TestAccAWSAPIGateway2ApiMapping_ApiMappingKey
=== CONT TestAccAWSAPIGateway2ApiMapping_basic
=== CONT TestAccAWSAPIGateway2ApiMapping_ApiMappingKey
--- PASS: TestAccAWSAPIGateway2ApiMapping_ApiMappingKey (52.60s)
--- PASS: TestAccAWSAPIGateway2ApiMapping_basic (72.66s)
PASS
ok github.com/terraform-providers/terraform-provider-aws/aws 72.707s |
After merge of #9391 and #9232, incorporate all the feedback:
|
6f28b78
to
01bf3a5
Compare
01bf3a5
to
7922b81
Compare
Renamed resource to $ make testacc TEST=./aws/ TESTARGS='-run=TestAccAWSAPIGatewayV2ApiMapping'
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./aws/ -v -count 1 -parallel 20 -run=TestAccAWSAPIGatewayV2ApiMapping -timeout 120m
=== RUN TestAccAWSAPIGatewayV2ApiMapping
=== RUN TestAccAWSAPIGatewayV2ApiMapping/createCertificate
=== RUN TestAccAWSAPIGatewayV2ApiMapping/basic
=== RUN TestAccAWSAPIGatewayV2ApiMapping/disappears
=== RUN TestAccAWSAPIGatewayV2ApiMapping/ApiMappingKey
--- PASS: TestAccAWSAPIGatewayV2ApiMapping (118.36s)
--- PASS: TestAccAWSAPIGatewayV2ApiMapping/createCertificate (3.25s)
--- PASS: TestAccAWSAPIGatewayV2ApiMapping/basic (32.32s)
--- PASS: TestAccAWSAPIGatewayV2ApiMapping/disappears (30.17s)
--- PASS: TestAccAWSAPIGatewayV2ApiMapping/ApiMappingKey (52.61s)
PASS
ok github.com/terraform-providers/terraform-provider-aws/aws 118.433s Closes #7004. |
The acceptance tests require that an ACM certificate be created outside of Terraform configuration (and left dangling after the tests finish) as any certificate created as part of the test configuration is in an associated state when deletion is attempted. This seems to be because the API Gateway domain name has a backing CloudFront distribution (in an AWS-owned account) and that can take up to 60 minutes to delete:
$ make testacc TEST=./aws/ TESTARGS='-run=TestAccAWSAPIGatewayV2ApiMapping_'
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./aws/ -v -count 1 -parallel 20 -run=TestAccAWSAPIGatewayV2ApiMapping_ -timeout 120m
=== RUN TestAccAWSAPIGatewayV2ApiMapping_basic
=== PAUSE TestAccAWSAPIGatewayV2ApiMapping_basic
=== RUN TestAccAWSAPIGatewayV2ApiMapping_ApiMappingKey
=== PAUSE TestAccAWSAPIGatewayV2ApiMapping_ApiMappingKey
=== CONT TestAccAWSAPIGatewayV2ApiMapping_basic
=== CONT TestAccAWSAPIGatewayV2ApiMapping_ApiMappingKey
--- FAIL: TestAccAWSAPIGatewayV2ApiMapping_basic (635.71s)
testing.go:730: Error destroying resource! WARNING: Dangling resources
may exist. The full state and error is shown below.
Error: errors during apply: Error deleting certificate: ResourceInUseException: Certificate arn:aws:acm:us-west-2:123456789012:certificate/e2e672f5-1d17-4338-bd8d-98881d622293 in account 123456789012 is in use.
State: aws_acm_certificate.test:
ID = arn:aws:acm:us-west-2:123456789012:certificate/e2e672f5-1d17-4338-bd8d-98881d622293
provider = provider.aws
arn = arn:aws:acm:us-west-2:123456789012:certificate/e2e672f5-1d17-4338-bd8d-98881d622293
certificate_authority_arn =
certificate_body = 790e1bd1153e851211df8beaf27cd09ecb1d21bc
domain_name = tf-acc-test-7526054328147068447.example.com
domain_validation_options.# = 0
options.# = 1
options.0.certificate_transparency_logging_preference = DISABLED
private_key = 21d2128df77fad2a11f6d8b94470538213c74f12
subject_alternative_names.# = 0
tags.% = 1
tags.Name = tf-acc-test-7526054328147068447
validation_emails.# = 0
validation_method = NONE
--- FAIL: TestAccAWSAPIGatewayV2ApiMapping_ApiMappingKey (668.35s)
testing.go:730: Error destroying resource! WARNING: Dangling resources
may exist. The full state and error is shown below.
Error: errors during apply: Error deleting certificate: ResourceInUseException: Certificate arn:aws:acm:us-west-2:123456789012:certificate/59441bc8-10e1-4679-848b-3996e65b7bbf in account 123456789012 is in use.
State: aws_acm_certificate.test:
ID = arn:aws:acm:us-west-2:123456789012:certificate/59441bc8-10e1-4679-848b-3996e65b7bbf
provider = provider.aws
arn = arn:aws:acm:us-west-2:123456789012:certificate/59441bc8-10e1-4679-848b-3996e65b7bbf
certificate_authority_arn =
certificate_body = a245b90590f966072471d91eb7d54c0d47d11185
domain_name = tf-acc-test-7248658647982118682.example.com
domain_validation_options.# = 0
options.# = 1
options.0.certificate_transparency_logging_preference = DISABLED
private_key = cc95ddca77f902c828ef60aa931cb55b3b6614da
subject_alternative_names.# = 0
tags.% = 1
tags.Name = tf-acc-test-7248658647982118682
validation_emails.# = 0
validation_method = NONE
FAIL
FAIL github.com/terraform-providers/terraform-provider-aws/aws 668.512s
FAIL
GNUmakefile:26: recipe for target 'testacc' failed
make: *** [testacc] Error 1 |
Ready for review. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This might need a resource sweeper, but otherwise LGTM 🚀
--- PASS: TestAccAWSAPIGatewayV2ApiMapping (99.68s)
--- PASS: TestAccAWSAPIGatewayV2ApiMapping/createCertificate (1.54s)
--- PASS: TestAccAWSAPIGatewayV2ApiMapping/basic (15.64s)
--- PASS: TestAccAWSAPIGatewayV2ApiMapping/disappears (38.98s)
--- PASS: TestAccAWSAPIGatewayV2ApiMapping/ApiMappingKey (43.52s)
"github.com/hashicorp/terraform-plugin-sdk/terraform" | ||
"github.com/terraform-providers/terraform-provider-aws/aws/internal/keyvaluetags" | ||
) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this have a sweeper, or will the resources get cleaned up when other resources are deleted?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's the aws_acm_certificate
that was created that needs sweeping - I'll add a sweeper as that resource doesn't have one currently - #12888.
If I try to sweep APIs with API mappings defined I get:
$ SWEEP=us-west-2 SWEEP_DIR=./aws/ SWEEPARGS=-sweep-run=aws_apigatewayv2_api make sweep
WARNING: This will destroy infrastructure. Use only in development accounts.
go test ./aws/ -v -sweep=us-west-2 -sweep-run=aws_apigatewayv2_api -timeout 60m
2020/04/18 17:56:38 [DEBUG] Running Sweepers for region (us-west-2):
2020/04/18 17:56:38 [DEBUG] Running Sweeper (aws_apigatewayv2_api) in region (us-west-2)
2020/04/18 17:56:38 [INFO] Building AWS auth structure
2020/04/18 17:56:38 [INFO] Setting AWS metadata API timeout to 100ms
2020/04/18 17:56:39 [INFO] Ignoring AWS metadata API endpoint at default location as it doesn't return any instance-id
2020/04/18 17:56:39 [INFO] AWS Auth provider used: "EnvProvider"
2020/04/18 17:56:39 [DEBUG] Trying to get account information via sts:GetCallerIdentity
2020/04/18 17:56:40 [DEBUG] Trying to get account information via sts:GetCallerIdentity
2020/04/18 17:56:41 [INFO] Deleting API Gateway v2 API: bvowp2c4b5
2020/04/18 17:56:41 [ERROR] error deleting API Gateway v2 API (bvowp2c4b5): BadRequestException: Deleting RestApi bvowp2c4b5 failed. Please remove all base path mappings related to the RestApi in your domains.
2020/04/18 17:56:41 [ERROR] Error running Sweeper (aws_apigatewayv2_api) in region (us-west-2): 1 error occurred:
* error deleting API Gateway v2 API (bvowp2c4b5): BadRequestException: Deleting RestApi bvowp2c4b5 failed. Please remove all base path mappings related to the RestApi in your domains.
FAIL github.com/terraform-providers/terraform-provider-aws/aws 3.718s
FAIL
GNUmakefile:19: recipe for target 'sweep' failed
make: *** [sweep] Error 1
That error message seems to be a holdover from API Gateway v1 but it means that domain names need to be deleted first, so I've added a dependency to the aws_apigatewayv2_api
sweeper:
$ SWEEP=us-west-2 SWEEP_DIR=./aws/ SWEEPARGS=-sweep-run=aws_apigatewayv2_api make sweep
WARNING: This will destroy infrastructure. Use only in development accounts.
go test ./aws/ -v -sweep=us-west-2 -sweep-run=aws_apigatewayv2_api -timeout 60m
2020/04/18 18:14:38 [DEBUG] Running Sweepers for region (us-west-2):
2020/04/18 18:14:38 [DEBUG] Sweeper (aws_apigatewayv2_api) has dependency (aws_apigatewayv2_domain_name), running..
2020/04/18 18:14:38 [DEBUG] Running Sweeper (aws_apigatewayv2_domain_name) in region (us-west-2)
2020/04/18 18:14:38 [INFO] Building AWS auth structure
2020/04/18 18:14:38 [INFO] Setting AWS metadata API timeout to 100ms
2020/04/18 18:14:40 [INFO] Ignoring AWS metadata API endpoint at default location as it doesn't return any instance-id
2020/04/18 18:14:40 [INFO] AWS Auth provider used: "EnvProvider"
2020/04/18 18:14:40 [DEBUG] Trying to get account information via sts:GetCallerIdentity
2020/04/18 18:14:40 [DEBUG] Trying to get account information via sts:GetCallerIdentity
2020/04/18 18:14:41 [INFO] Deleting API Gateway v2 domain name: example-ws-api.example.com
2020/04/18 18:14:42 [DEBUG] Running Sweeper (aws_apigatewayv2_api) in region (us-west-2)
2020/04/18 18:14:42 [INFO] Building AWS auth structure
2020/04/18 18:14:42 [INFO] Setting AWS metadata API timeout to 100ms
2020/04/18 18:14:43 [INFO] Ignoring AWS metadata API endpoint at default location as it doesn't return any instance-id
2020/04/18 18:14:43 [INFO] AWS Auth provider used: "EnvProvider"
2020/04/18 18:14:43 [DEBUG] Trying to get account information via sts:GetCallerIdentity
2020/04/18 18:14:43 [DEBUG] Trying to get account information via sts:GetCallerIdentity
2020/04/18 18:14:44 [INFO] Deleting API Gateway v2 API: m36pbck0ii
2020/04/18 18:14:46 [DEBUG] Sweeper (aws_apigatewayv2_domain_name) already ran in region (us-west-2)
2020/04/18 18:14:46 Sweeper Tests ran successfully:
- aws_apigatewayv2_domain_name
- aws_apigatewayv2_api
ok github.com/terraform-providers/terraform-provider-aws/aws 7.842s
…yv2_domain_name'.
This has been released in version 2.59.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 for triage. Thanks! |
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! |
Community Note
Another resource for #7004.
Release note for CHANGELOG:
Output from acceptance testing:
Currently based on #8842, will need to rebase once that PR is merged.