简体   繁体   English

我可以在 AWS Cloudformation json 模板的“参数”中使用“Fn::Join”吗

[英]Can I use "Fn::Join" in "Parameters" of AWS Cloudformation json template

I want to use in Parameters of Cloudformation json template shortcut of some Policy/Loadbalancers tags name, like that:我想在一些 Policy/Loadbalancers 标签名称的 Cloudformation json 模板快捷方式的参数中使用,如下所示:

"SomeScalingGroupName": {
            "Type": "String",
            "Default": {"Fn::Join": ["", ["Process-", {"Ref": "Env"}, "-Some-Worker-Name"]]}
        },

And I get error:我得到错误:

Template validation error: Template format error: Every Default member must be a string.模板验证错误:模板格式错误:每个默认成员都必须是字符串。

So my question if that proper way to use function join in Parameters?所以我的问题是在参数中使用函数连接的正确方法吗? Or I they have any other way to do that?或者我他们有其他方法可以做到这一点? Or you have any better suggestions to using that?或者您对使用它有什么更好的建议?

Thanks!谢谢!

You cannot use intrinsic functions within the parameters section of your template.您不能在模板的参数部分中使用内部函数。

You can use intrinsic functions only in specific parts of a template.您只能在模板的特定部分使用内部函数。 Currently, you can use intrinsic functions in resource properties, metadata attributes, and update policy attributes.目前,您可以在资源属性、元数据属性和更新策略属性中使用内部函数。

http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/intrinsic-function-reference.html http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/intrinsic-function-reference.html

You will need use this function within your resource properties.您将需要在资源属性中使用此功能。 For example:例如:

"Parameters" : {
  "Env" : {
    "Type" : "String",
    "Default" : "test"
  },
  "WorkerName" : {
    "Type" : "String",
    "Default" : "my-worker"
  }
}

"Resources" : {
  "LoadBalancer" : {
    "Type" : "AWS::ElasticLoadBalancing::LoadBalancer",
    ...
    "Properties" : {
      "Tags" : [ 
        { "Key" : "Name", "Value": { "Fn::Join" : [ "-", [ "process", { "Ref" : "Env" }, { "Ref" : "SomeWorkerName" }]]}},
      ]
    }
  }
}

This will apply a 'Name' tag to your Load Balancer with a value of 'process-test-my-worker'.这会将“名称”标签应用到您的负载均衡器,其值为“process-test-my-worker”。 You can also use this same function anywhere else within the properties of your resources.您还可以在资源属性内的任何其他位置使用相同的功能。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 AWS Cloudformation json模板中的“参数”内应是什么,以及“资源”内应是什么? - What should be inside “Parameters” and what in “Resoures” in AWS Cloudformation json template? 在 cloudformation 中的 yaml 中的 json 中使用 Fn::ImportValue - use Fn::ImportValue inside a json which is inside a yaml in cloudformation AWS Cloudformation JSON模板到C#对象 - AWS Cloudformation JSON template to c# object 如何将 AWS Cloudformation 的 YAML 连接格式写入 Terraform 格式? - How can I write a YAML Join Format of AWS Cloudformation to Terraform format? 如何在 aws cloudformation yaml 模板中格式化数据类型 json 的参数? - How to format parameter of data type json in a aws cloudformation yaml template? AWS CloudFormation模板(JSON)创建EC2-意外错误 - AWS CloudFormation Template (JSON) to Create EC2 - Unexpected Error cloudformation模板中的opsworks参数和资源 - opsworks parameters and resources in the cloudformation template Eclipse:使用Json编辑器插件自动格式化JSON文件(如AWS Cloudformation Template) - Eclipse: Autoformat JSON file like AWS Cloudformation Template with Json editor plugin 将参数作为json文件传递时,AWS Cloudformation CLI使用简写语法 - AWS Cloudformation CLI uses shorthand syntax when passing parameters as json file Amazon AWS Cloudformation JSON模板,用于将LAMP www / html文件夹权限分配给ec2-user - Amazon AWS Cloudformation JSON template to assign the LAMP www/html folder permissions to ec2-user
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM