Amazon web services AWS Cloudformation-在YAML文件中导入Jinja定义的变量
我在Jinja文件中生成了一些Cloudwatch警报。我想在YML文件中使用其中一个警报来生成云。简单地放置Amazon web services AWS Cloudformation-在YAML文件中导入Jinja定义的变量,amazon-web-services,jinja2,amazon-cloudformation,Amazon Web Services,Jinja2,Amazon Cloudformation,我在Jinja文件中生成了一些Cloudwatch警报。我想在YML文件中使用其中一个警报来生成云。简单地放置DependsOn不起作用,因为processign失败,错误为 “StatusReason”:“模板格式错误:模板的资源块中未解析的资源依赖项[ABC.Alarm]”, 在YML文件中为Cloudformation部署导入Jinja变量的方法是什么 编辑: 我们的配置包含YML和Jinja文件,我不打算替换完整的模板。但只需使用Jinja文件中定义的参数 有多种方法可以使用yaml
DependsOn
不起作用,因为processign失败,错误为
“StatusReason”:“模板格式错误:模板的资源块中未解析的资源依赖项[ABC.Alarm]”,
在YML文件中为Cloudformation部署导入Jinja变量的方法是什么
编辑:
我们的配置包含YML和Jinja文件,我不打算替换完整的模板。但只需使用Jinja文件中定义的参数 有多种方法可以使用yaml模板被Jinja取代
- -需要最少代码的bash实用程序
- 使用Python(jinja模块)+bash
实验中.yml
:
- hosts: localhost
connection: local
gather_facts: False
tasks:
- cloudformation:
stack_name: experiments
template: experiments-stack.yml
template_parameters:
MyParameter: MyParameterValue
...
Parameters:
MyParameter:
Type: String
Resources:
Something:
Type: ...
Properties:
PropertyName: !Ref MyParameter
CloudFormation堆栈模板实验堆栈.yml
:
- hosts: localhost
connection: local
gather_facts: False
tasks:
- cloudformation:
stack_name: experiments
template: experiments-stack.yml
template_parameters:
MyParameter: MyParameterValue
...
Parameters:
MyParameter:
Type: String
Resources:
Something:
Type: ...
Properties:
PropertyName: !Ref MyParameter
使用ansible playbook/experiments.yml运行playbook,我不想替换完整的模板。但只需使用Jinja文件中定义的参数。