# Error creating API Gateway Domain Name by terraform

**URL:** <https://discuss.hashicorp.com/t/error-creating-api-gateway-domain-name-by-terraform/8898>\
**Category:** Terraform\
**Created:** [May 19, 2020, 9:52am UTC](https://discuss.hashicorp.com/t/error-creating-api-gateway-domain-name-by-terraform/8898 "2020-05-19T09:52:28Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![anarinsky](https://sea2.discourse-cdn.com/hashicorp/user_avatar/discuss.hashicorp.com/anarinsky/32/6148_2.png) [@anarinsky](https://discuss.hashicorp.com/u/anarinsky)\
**Post date:** [May 19, 2020, 9:52am UTC](https://discuss.hashicorp.com/t/error-creating-api-gateway-domain-name-by-terraform/8898/1 "2020-05-19T09:52:28Z")

</div>

I have the terraform definition:  
resource “aws\_api\_gateway\_domain\_name” “apigatewatDomainName” {  
domain\_name = [servname.companyname.com](http://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](http://aaa.servername.companyname.com)”, so I specified

resource “aws\_api\_gateway\_domain\_name” “[aaa.servername.companyname.com](http://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.”
