我正在部署带有 Beanstalk 实例的 AWS Cloudformation 堆栈, Routes53 记录和ACM 证书。
我想在堆栈部署期间立即通过 DNS 验证验证证书。
当我运行和部署堆栈时,除了持续处于验证等待状态的 ACM 证书之外,所有资源均已正确创建。验证等待。我没有任何错误,而且我不太明白为什么证书没有经过验证。
我的cloudformation模板看起来像这样:
AWSTemplateFormatVersion: "2010-09-09"
Description: Project beanstalk
Parameters:
ApplicationName:
Description: Name of your application
Type: String
Default: hello
MinLength: 1
MaxLength: 255
AllowedPattern: "^[a-zA-Z][-a-zA-Z0-9]*$"
EnvironmentName:
Description: Environment name, either dev or rec or main
Type: String
Default: dev
AllowedValues:
- dev
- rec
- main
ConstraintDescription: Specify either dev or rec or main
Resources:
Application:
Type: AWS::ElasticBeanstalk::Application
Properties:
ApplicationName: !Ref ApplicationName
Environment:
Type: AWS::ElasticBeanstalk::Environment
Properties:
ApplicationName: !Ref Application
EnvironmentName: !Sub "${ApplicationName}-${EnvironmentName}"
TemplateName: !Ref ConfigurationTemplate # I disable this part to limit code lines
DependsOn:
- ConfigurationTemplate
Route53APIRecordSet:
Type: "AWS::Route53::RecordSet"
Properties:
Name: !Sub "${ApplicationName}-${EnvironmentName}.api.hello.com"
Type: "A"
HostedZoneId: !Ref HostedZoneIdFromMyDNS # This var is hard code in my template
AliasTarget:
DNSName: !GetAtt Environment.EndpointURL
HostedZoneId: !Ref HostedZoneIdFromMyBeanstalk # ELB Zone ID for my region (it's also hardcoded)
APIACMCertificate:
Type: "AWS::CertificateManager::Certificate"
Properties:
DomainName: hello.com
ValidationMethod: DNS
DomainValidationOptions:
- DomainName: !Sub "${ApplicationName}-${EnvironmentName}.api.hello.com"
HostedZoneId: !Ref HostedZoneIdFromMyDNS
我不明白为什么我的 Routes53 记录的 ACM 证书未正确验证。你有好主意吗 ? 我的 Routes53 记录设置正确,因为我可以导航到我的 beanstalk 页面,但不能导航到证书下。
编辑 2023 年 8 月 8 日 我运行 2 个 nslookup 命令(这些命令是个性化的,如上面的示例):
nslookup hello.com
响应是:非权威答案,服务器未知nslookup ${ApplicationName}-${EnvironmentName}.api.hello.com
(参数当然会改变)。服务器也不知道,但我没有非权威的答案。
最佳答案
两个 DomainName:
指令在文档中必须具有相同的值。 AWS::CertificateManager::Certificate cloudfront docs
In order for a AWS::CertificateManager::Certificate to be provisioned and validated in CloudFormation automatically, the
DomainName
property needs to be identical to one of theDomainName
property supplied in DomainValidationOptions, if the ValidationMethod is DNS.
关于amazon-elastic-beanstalk - Cloudformation 模板的 ACM 证书验证失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/76847880/