I have the terraform definition:
resource “aws_api_gateway_domain_name” “apigatewatDomainName” {
domain_name = servname.companyname.com
certificate_arn = “arn:aws:acm:us-east-1:12345566:certificate/dddddd-3333-4444-5555-0123456789a”
}
When I apply the terraform I am getting the error:
Error: Error creating API Gateway Domain Name: BadRequestException: The certificate that is attached to your distribution doesn’t cover the alternate domain name (CNAME) that you’re trying to add.
When I apply the command
aws acm describe-certificate --certificate-arn
I am getting in the description
“DomainValidationOptions”: [
{
“ValidationStatus”: “SUCCESS”,
“ResourceRecord”: {
“Type”: “CNAME”,
“Name”: “_88f0a9b77497411fd26c281d7d61fbd9.servername.companyname.com”,
“Value”: “_4cee246cb2515f9a0c1f101edaee900e.hkvuiqjoua.acm-validations.aws.”
},
“ValidationDomain”: “.servername.companyname.com",
“ValidationMethod”: “DNS”,
“DomainName”: ".servername.companyname.com”
}
],
Also, in this description I see
“SubjectAlternativeNames”: [
“*.servername.companyname.com”
],
So, I assume that I can create a domain like “aaa.servername.companyname.com”, so I specified
resource “aws_api_gateway_domain_name” “aaa.servername.companyname.com” {
But terraform does not allow to have dots in a resource name :
“A name must start with a letter or underscore and may contain only letters, digits, underscores, and dashes.”