I'm trying to create api gateway endpoints for multiple lambda functions, all using the same base custom domain name: api.example.io. One function is to be mapped to api.example.io/project , and another to api.example.io/report. I should be able to create the custom domain using aws_apigatewayv2_domain_name in one function, then use aws_apigatewayv2_api_mapping separately in each function to map to different api_mapping_keys.
Actual Behavior
aws_apigatewayv2_domain_name throws an error when the domain is already created (error output below). 🚨Furthermore, it clears out all existing custom domain configurations in API Gateway Console:
When I try to add an existing domain in aws_apigatewayv2_api_mapping, its domain_name argument does not accept the string of an existing domain or its arn. It throws the error that the domain name identifier is invalid (see below)
Relevant Error/Panic Output Snippet
----------------------------------------------------------------------------
From aws_apigatewayv2_domain_name
----------------------------------------------------------------------------
│ Error: error creating API Gateway v2 domain name (api.example.io): BadRequestException: The domain name you provided already exists.
│
│ with module.api_gateway.aws_apigatewayv2_domain_name.apigw_domain,
│ on ../../../terraform-modules/apigw_lambda/main.tf line 29, in resource "aws_apigatewayv2_domain_name" "apigw_domain":
│ 29: resource "aws_apigatewayv2_domain_name" "apigw_domain" {
----------------------------------------------------------------------------
From aws_apigatewayv2_api_mapping
----------------------------------------------------------------------------
â•·
│ Error: creating API Gateway v2 API mapping: NotFoundException: Invalid domain name identifier specified
│ {
│ RespMetadata: {
│ StatusCode: 404,
│ RequestID: "41ccd5de-73a4-4f31-99e6-a84b5748828d"
│ },
│ Message_: "Invalid domain name identifier specified"
│ }
│
│ with module.api_gateway.aws_apigatewayv2_api_mapping.apigw_mapping,
│ on ../../../terraform-modules/apigw_lambda/main.tf line 38, in resource "aws_apigatewayv2_api_mapping" "apigw_mapping":
│ 38: resource "aws_apigatewayv2_api_mapping" "apigw_mapping" {
│
╵
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.
Volunteering to Work on This Issue
If you are interested in working on this issue, please leave a comment.
If this would be your first contribution, please review the contribution guide.
Terraform Core Version
1.3.2
AWS Provider Version
4.34.0
Affected Resource(s)
aws_apigatewayv2_domain_name aws_apigatewayv2_api_mapping
Expected Behavior
I'm trying to create api gateway endpoints for multiple lambda functions, all using the same base custom domain name:
api.example.io
. One function is to be mapped toapi.example.io/project
, and another toapi.example.io/report
. I should be able to create the custom domain usingaws_apigatewayv2_domain_name
in one function, then useaws_apigatewayv2_api_mapping
separately in each function to map to different api_mapping_keys.Actual Behavior
aws_apigatewayv2_domain_name
throws an error when the domain is already created (error output below). 🚨Furthermore, it clears out all existing custom domain configurations in API Gateway Console:When I try to add an existing domain in
aws_apigatewayv2_api_mapping
, itsdomain_name
argument does not accept the string of an existing domain or its arn. It throws the error that the domain name identifier is invalid (see below)Relevant Error/Panic Output Snippet
Terraform Configuration Files
Steps to Reproduce
Debug Output
No response
Panic Output
No response
Important Factoids
No response
References
No response
Would you like to implement a fix?
No response