[英]How can I create an AWS Cloud Formation condition for creating a new SSM Parameter if not already created?
Anyone used condition in Cloudformation template for SSM Parameter Store parameter "if it is not created before then create or do nothing" like condition in Cloudformation ? 是否有人在Cloudformation模板中使用了条件作为SSM参数存储参数“如果未在创建之前创建或什么都不做”,例如Cloudformation中的条件?
I have tried it in many ways but no luck. 我已经尝试了很多方法,但是没有运气。 Also search for it but there is no real working thing around. 也可以搜索它,但是周围没有真正的工作工具。
The simplest way I have tried outside of my real CF template is this but not working. 我在真正的CF模板之外尝试过的最简单方法是这种方法,但无法正常工作。 There is no detailed documentation at the AWS Cloudformation part. AWS Cloudformation部分没有详细的文档。
Parameters:
DAXClusterUrl:
Description: DAX Cluster Url
Type: 'AWS::SSM::Parameter::Name<String>'
Default: "/testservice/dev/AWS_CLUSTER_ENDPOINT"
Conditions:
CreateDAXClusterUrlParameter: !Not [!Equals ["", !Ref DAXClusterUrl]]
Resources:
DAXClusterUrlParameter:
Condition: CreateDAXClusterUrlParameter
Type: 'AWS::SSM::Parameter'
Properties:
Name: "/testservice/dev/AWS_CLUSTER_ENDPOINT"
Type: String
Value: "TestURL"
Description: '-'
I don't think it is possible to do what you are trying here. 我认为您在这里所做的尝试是不可能的。 Cloudformation only allows a very limited type of programming and conditional statements. Cloudformation仅允许非常有限类型的编程和条件语句。
Depending on what you are trying to achieve, there are some workaround you can use. 根据要实现的目标,可以使用一些解决方法。 For example, if you are trying to do this, because you need to deploy the stack multiple times, you can either create the SSM parameter manually or in a different CFN stack and pass it as a parameter. 例如,如果您尝试执行此操作,因为您需要多次部署堆栈,则可以手动创建SSM参数,也可以在其他CFN堆栈中创建SSM参数并将其作为参数传递。 Or, if you are creating the SSM parameter in a separate CFN stack anyway, you can add it to the outputs
section of the template and then use the Fn::ImportValue
method to create a cross-stack reference. 或者,如果仍然在单独的CFN堆栈中创建SSM参数,则可以将其添加到模板的outputs
部分,然后使用Fn::ImportValue
方法创建跨堆栈引用。
EDIT 编辑
After the comment by OP I did some more research and while the link that's in the comment only forces the value of the parameter to be a certain way, dynamic references might provide a solution here. 在OP发表评论之后,我进行了更多研究,尽管评论中的链接仅强制将参数的值确定为某种方式,但动态引用可能会在此处提供解决方案。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.