我在云形成方面遇到问题。使用Fn :: Join和参数时出错 [英] I have a problem in cloud formation. Error when using Fn::Join with a parameter

查看:86
本文介绍了我在云形成方面遇到问题。使用Fn :: Join和参数时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试创建一个安全组并使用cloudformation从参数调用其他安全组。我将其用作资源,但是从cloudfromation得到以下错误消息

I am trying to create one Security Group and calling other security group from parameters using cloudformation. I used this as a resource however I get the following error message from cloudfromation


模板验证错误:模板错误:每个Fn :: Join对象
需要两个参数,(1)一个字符串定界符,(2)要连接的
字符串列表,或者返回一个字符串列表
的函数(例如Fn :: GetAZs)

Template validation error: Template error: every Fn::Join object requires two parameters, (1) a string delimiter and (2) a list of strings to be joined or a function that returns a list of strings (such as Fn::GetAZs) to be joined.



AWSTemplateFormatVersion : 2010-09-09
Description: "simple web layer"
Parameters:
Securitygroupid:
Description: enter sc
Type: List<AWS::EC2::SecurityGroup::Id>
NoEcho: false
Default: sg-05323df39f12d8034

Resources:
   Lpsecurity:
Type: AWS::EC2::SecurityGroup
Properties:
Securitygroupid:
Description: enter sc
Type: List<AWS::EC2::SecurityGroup::Id
NoEcho: false
Default: sg-05323df39f12d8034
      VpcId: !Ref Vpc
      GroupDescription: Sample target security group
      SecurityGroupIngress:        
      - IpProtocol: tcp
        FromPort: 80
        ToPort: 80
        CidrIp: !Ref Securitycab
      - IpProtocol: tcp
        FromPort: 443
        ToPort: 443
        CidrIp: !Ref Securitycab 
   MyEC2Instance1:
     Type: 'AWS::EC2::Instance'
     Properties:
       ImageId: !Ref ImageId
       InstanceType: t2.micro
       SubnetId: !Select [ 0, !Ref Subnets ]
       SecurityGroupIds: !Join [ ",", [ !Ref Securitygroupid, !Ref Lpsecurity ]]

什么是我在做w

推荐答案

我找到了解决方案。

SecurityGroupIds:  !Split
    - ","
    - !Sub
      - "${idList},${Lpsecurity}"
      - idList: !Join [",",!Ref "SecurityGroup"]  

这篇关于我在云形成方面遇到问题。使用Fn :: Join和参数时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆