简体   繁体   English

如果尚未创建新的SSM参数,如何创建AWS云形成条件?

[英]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.

相关问题 如何使用 AWS Cloudformer 为现有 API 网关创建云形成模板? - How can I use AWS Cloudformer to create a cloud formation template for an existing API Gateway? AWS Secrets Manager 和 Cloud Formation - 无法创建秘密,因为它已经存在 - AWS Secrets Manager and Cloud Formation - can not create secret because it already exists 如何从 Terraform 创建 AWS SSM 参数 - How to create AWS SSM Parameter from Terraform Lambda API 结果作为在 Cloud Formation 中创建 AWS 资源的条件 - Lambda API result as a condition to create AWS resource in Cloud Formation 如何为已部署的 AWS 资源获取云形成模板 - How to get cloud formation template for an already deployed AWS resource 如何知道是否使用AWS Cloud SDK完全创建了堆栈 - How to know if the stack is completely created using AWS SDK for Cloud Formation 我们如何使用 AWS 云形成模板创建跨区域 RDS 只读副本? - How can we create cross region RDS read replica using AWS cloud formation template? 删除 AWS 云形成堆栈及其创建的资源 - Delete AWS Cloud formation stack with resources created by it 如何从现有 AWS 环境创建云形成模板? - How to create a cloud formation template from an existing AWS environment? 如何在 AWS Java SDK 中使用 IAM 角色创建云形成? - How to create cloud formation using IAM roles in AWS Java SDK?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM