terraform-aws-apigateway-v2
terraform-aws-apigateway-v2 copied to clipboard
Tainting aws_apiaws_apigatewayv2_stage.default with a custom domain fails to apply
Description
Tainting the aws_apigatewayv2_stage.default resource with a configured custom domain fails to apply cleanly.
- [x] β I have searched the open/closed issues and my issue is not listed.
β οΈ Note
Before you submit an issue, please perform the following first:
- Remove the local
.terraformdirectory (! ONLY if state is stored remotely, which hopefully you are following that best practice!):rm -rf .terraform/ - Re-initialize the project root to pull down modules:
terraform init - Re-attempt your terraform plan or apply and check if the issue still persists
Versions
-
Module version [Required]: 2.2.0
-
Terraform version:
Terraform v1.3.1
on darwin_arm64
- Provider version(s):
+ provider registry.terraform.io/hashicorp/aws v4.33.0
+ provider registry.terraform.io/hashicorp/null v3.1.1
+ provider registry.terraform.io/hashicorp/tls v4.0.3
Reproduction Code [Required]
Steps to reproduce the behavior:
Workspace? Yes Cleared local cache? Yes
Create API Gateway with a custom domain and automatic mapping, make sure the default stage is enabled.
terraform applyterarform taint aws_apigatewayv2_stage.defaultterraform apply
Expected behavior
The default stage is successfully unattached to the custom domain and deleted.
Actual behavior
$ terraform apply
...
module.demo.aws_apigatewayv2_stage.default[0]: Destroying... [id=$default]
β Error: deleting API Gateway v2 stage ($default): BadRequestException: Deleting stage $default failed. Please remove all base path mappings related to the stage in your domains: demo.example.com
Terminal Output Screenshot(s)
Terraform will perform the following actions:
# module.demo.aws_apigatewayv2_api_mapping.this[0] will be updated in-place
~ resource "aws_apigatewayv2_api_mapping" "this" {
id = "coffee"
~ stage = "$default" -> (known after apply)
# (2 unchanged attributes hidden)
}
# module.demo.aws_apigatewayv2_stage.default[0] is tainted, so must be replaced
-/+ resource "aws_apigatewayv2_stage" "default" {
~ arn = "arn:aws:apigateway:us-east-2::/apis/deadbeef/stages/$default" -> (known after apply)
~ deployment_id = "xfnne7" -> (known after apply)
~ execution_arn = "arn:aws:execute-api:us-east-2:1337133713370:deadbeef/$default" -> (known after apply)
~ id = "$default" -> (known after apply)
~ invoke_url = "https://deadbeef.execute-api.us-east-2.amazonaws.com/" -> (known after apply)
name = "$default"
- stage_variables = {} -> null
...
}
Plan: 1 to add, 1 to change, 1 to destroy.
Do you want to perform these actions in workspace "stg"?
Terraform will perform the actions described above.
Only 'yes' will be accepted to approve.
Enter a value: yes
module.demo.aws_apigatewayv2_stage.default[0]: Destroying... [id=$default]
β·
β Error: deleting API Gateway v2 stage ($default): BadRequestException: Deleting stage $default failed. Please remove all base path mappings related to the stage in your domains: demo.example.com
β
β
β΅
Additional context
I believe the aws_apigatewayv2_api_mapping.this resource needs a replace_triggered_by set for aws_apigatewayv2_stage.default[0].