【问题标题】:Can we use Boto to deploy Yaml templates?我们可以使用 Boto 来部署 Yaml 模板吗?
【发布时间】:2022-02-08 23:48:47
【问题描述】:

我正在使用 boto 在 AWS 中部署 json 模板。我的问题是我是否也可以使用相同的 boto 库在 Yaml 中部署模板。当我尝试时,我得到错误 no json could be decoded。

如果有办法,请分享一个例子 谢谢。

【问题讨论】:

标签: python amazon-web-services boto boto3


【解决方案1】:

我们只需要使用 Yaml 解码器代替 json 解码器,如下所示:-

使用 open(template_path) 作为 yaml_data: 模板 = yaml.load(yaml_data) template_body = yaml.dump(模板)

别忘了导入 Yaml。

【讨论】:

    【解决方案2】:

    您现在可以直接从 Boto3 使用 YAML 文件:

    try:
        with open(template_file_location, 'r') as content_file:
            content = content_file.read() 
    except OSError as e:
      # error handling in case error reading file
    ...
    boto3_client.validate_template(TemplateBody=content)
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2023-02-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-01-30
      • 1970-01-01
      • 2021-08-08
      • 1970-01-01
      相关资源
      最近更新 更多