我想从另一个堆栈引用我的实例配置文件值。
如果实例配置文件资源位于模板中,我可以 !Ref 资源名称
---
AWSTemplateFormatVersion: '2010-09-09'
Parameters:
SSMInstanceProfileStack:
Description: instance profile stack
Type: String
Default: instance-profile
Resources:
Ec2:
Type: AWS::EC2::Instance
Properties:
InstanceType: t2.micro
ImageId: ami-077a5b1762a2dde35
IamInstanceProfile:
- Fn::ImportValue:
Fn::Sub: "${SSMInstanceProfileStack}-Suffix"
Tags:
- Key: Name
Value: Ec2SandPit
Outputs:
Ec2Output:
Description: A bare bone Ec2 instance
Value: !Ref Ec2
Export:
Name: !Sub "${AWS::StackName}-Ec2"
我收到此错误,资源已部署。
Value of property IamInstanceProfile must be of type String
有解决办法吗?
最佳答案
IamInstanceProfile
应该是仅字符串,而不是字符串列表。所以应该是(删除 -
):
IamInstanceProfile:
Fn::ImportValue:
Fn::Sub: "${SSMInstanceProfileStack}-Suffix"
关于amazon-web-services - 属性 IamInstanceProfile 的值必须为 String 类型,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66576763/