【问题标题】:How to use an environment variable from the Lambda CloudFormation resource for python?如何将 Lambda CloudFormation 资源中的环境变量用于 python?
【发布时间】:2021-02-18 06:08:37
【问题描述】:

这是相关部分:

      Environment:
        Variables:
          NameServers: !GetAtt HostedZone.NameServers
      Code:
        ZipFile: |
          import boto3
          var client = boto3.client('route53domains')
          var aws = require('aws-sdk')
          response = client.update_domain_nameservers(
              DomainName='example.com',
              Nameservers=[
                  {
                      'Name': 'get("NameServers")',
                      ]
                  },
              ]
          )

那么这是使用获取托管区域名称服务器的名称来更改域名服务器的正确方法吗?我根本不懂 Python。

【问题讨论】:

标签: python amazon-web-services aws-lambda sdk amazon-cloudformation


【解决方案1】:

我没有测试,但应该是这样的:

          import boto3
          import os  # <-- Added this

          var client = boto3.client('route53domains')
          var aws = require('aws-sdk')
          response = client.update_domain_nameservers(
              DomainName='example.com',
              Nameservers=[
                  {
                      'Name': os.environ['NameServers'],  # <-- Changed this
                      ]
                  },
              ]
          )

【讨论】:

    猜你喜欢
    • 2018-03-25
    • 2018-04-30
    • 2017-09-16
    • 2016-09-03
    • 2018-03-01
    • 1970-01-01
    • 2020-03-08
    • 1970-01-01
    • 2019-05-06
    相关资源
    最近更新 更多