在HostedZone资源的Lambda函数中指定名称服务器?

问题描述

这是我的Lambda函数

      Code:
        ZipFile: |
          import boto3
          var client = boto3.client('route53domains')
          response = client.update_domain_nameservers(
              DomainName='example.com',Nameservers=[
                  {
                      'Name': 'string',]
                  },]
          )

它应该做的是为Route53上我注册的域更新名称服务器,我只是不知道如何为其指定名称服务器,这是我CloudFormation堆栈中Lambda资源的一部分,我有一个资源HostedZone和我想将!GetAtt HostedZone.NameServers导入此函数

HostedZone.NameServer不会返回4个名称服务器的列表,该函数要求输入一个字符串,所以我想我需要添加4个字符串。我迷路了。

解决方法

您可以使用SubHostedZone.NameServers传入lambda源代码:

      Code:
        ZipFile: !Sub |
          import boto3
          var client = boto3.client('route53domains')
          response = client.update_domain_nameservers(
              DomainName='example.com',Nameservers=[
                  {
                      'Name': '${HostedZone.NameServers}',]
                  },]
          )

以上仅是示例。我不确定您确切要在哪里使用HostedZone.NameServers,但是使用${HostedZone.NameServers}时正确的引用方式是Sub