Cloudformation 模板的 ACM 证书验证失败

问题描述 投票:0回答:2

我正在部署 AWS Cloudformation 堆栈,其中包含 Beanstalk 实例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 页面,但不能导航到证书下。

编辑 08/08/2023 我运行 2 个

nslookup
命令(这些命令是个性化的,如上面的示例):

  • nslookup hello.com
    回复是:非权威答案,服务器未知

  • nslookup ${ApplicationName}-${EnvironmentName}.api.hello.com
    (参数当然会改变)。服务器也不知道,但我没有非权威的答案。

amazon-elastic-beanstalk aws-cloudformation aws-acm aws-route53
2个回答
0
投票
根据文档,两个

DomainName:

 指令的值必须相同。 
AWS::CertificateManager::证书云前端文档

为了配置 AWS::CertificateManager::Certificate 并在 CloudFormation 中自动进行验证,

DomainName

属性需要与 
DomainName
 属性之一相同
在 DomainValidationOptions 中提供,如果 ValidationMethod 是
DNS


0
投票
当您通过 CloudFormation 创建 ACM 证书时,它会要求您转到 ACM 并手动将 CNAME 记录添加到托管区域(域)。按下按钮后,会将这些记录添加到您的域中,并且 CloudFormation 堆栈将继续进行。这是手动方法,对于一次性工作来说,这是可以的。 但如果您必须一遍又一遍地这样做,那么您最好考虑 CloudFormation 的自定义资源,它将触发具有所需功能的 Lambda 函数。看看

这个仓库看起来有你正在寻找的东西

© www.soinside.com 2019 - 2024. All rights reserved.