[AWS] API Gateway v2 /HTTP API custom domain expose


I just use the latested version (2.59.0) to deploy my api gateway with aws_apigatewayv2_domain_name,
the deploy process is fine, but I found it doest not expose the API Gateway domain name for me, so I could not add it to my route53 record

I guess my whole routing process should like:

  1. Route53 record: example.com
  2. API GW Domain Name: d-ph3hk2a1s6.execute-api.ap-northeast-1.amazonaws.com
  3. API GW mapping id and stage: d3ae01i26i $default
  4. d3ae01i26i.execute-api.ap-northeast-1.amazonaws.com

I would like to know how to get the value of step 2 from terraform’s output


@gogoge The api_endpoint attribute of the aws_apigatewayv2_api resource should give you the domain name you are looking for.

@ewbankkit Just ran into this issue as well. The api_endpoint is not the correct endpoint to use for DNS purposes.

The correct format (displayed under API Custom Domain Names as “API Gateway domain name”) is d-xxxxxxxxxx.execute-api.<region>.amazonaws.com while the api_endpoint has the format https://yyyyyyyyyy.execute-api.<region>.amazonaws.com.

The API id:s for x and y are also different. The logical place to get it would be as an output from aws_apigatewayv2_domain_name, along with the correct API Gateway zone ID (similar to how aws_api_gateway_domain_name works). But it seems currently there is no way of getting the right values other than manually checking the AWS Console.

@tibbing https://github.com/terraform-providers/terraform-provider-aws/issues/12892 has some discussion on possible solutions.

@ewbankkit Wow, thanks! Totally missed those outputs as they were listed under arguments and not attributes in the documentation, slightly confusing :slightly_smiling_face: