Amazon web services AWS云层编队!Ref SecurityGroup返回无效的ID
我想通过cloudformation部署具有SecurityGroup入口规则的SecurityGroup 我目前在yaml文件中使用此选项:Amazon web services AWS云层编队!Ref SecurityGroup返回无效的ID,amazon-web-services,amazon-cloudformation,aws-security-group,Amazon Web Services,Amazon Cloudformation,Aws Security Group,我想通过cloudformation部署具有SecurityGroup入口规则的SecurityGroup 我目前在yaml文件中使用此选项: Security Type: AWS::EC2::SecurityGroup Properties: GroupDescription: Securitygroup with access to itself SecurityIngress: Type: AWS::EC2::SecurityGroupIngress Propert
Security
Type: AWS::EC2::SecurityGroup
Properties:
GroupDescription: Securitygroup with access to itself
SecurityIngress:
Type: AWS::EC2::SecurityGroupIngress
Properties:
GroupId: !Ref Security
SourceSecurityGroupId: !Ref Security
IpProtocol: tcp
FromPort: -1
这将给我一个错误,指出SucurityGroupId的格式不正确。该错误在创建SecurityIngress时发生。请注意,我已将stackname更改为stackname
无效Id:\Stackname-Security-N12M8127812\expecting\sg-\
所以我猜!Ref不返回SecurityGroup的ID,而是返回名称。
有没有办法找到id?使用!Ref将返回资源名称。这一点在报告中明确提到。你需要使用这个工具!获取一个资源属性,包括安全组id
SourceSecurityGroupId: !GetAtt Security.GroupId
使用!Ref将返回资源名称。这一点在报告中明确提到。你需要使用这个工具!获取一个资源属性,包括安全组id
SourceSecurityGroupId: !GetAtt Security.GroupId
这在文件中不是很清楚。doco告诉您,有时您会得到名称,有时会得到ID。AWS代码段有时采用一个,有时采用另一个。所以这是一个好问题。文档中不是很清楚。doco告诉您,有时您会得到名称,有时会得到ID。AWS代码段有时采用一个,有时采用另一个。所以这是个好问题。