【问题标题】:Value of property IamInstanceProfile must be of type String属性 IamInstanceProfile 的值必须是 String 类型
【发布时间】:2021-03-11 13:09:36
【问题描述】:

我想从另一个堆栈引用我的实例配置文件值。

如果实例配置文件资源在模板中,我可以 !Ref Name of the resource

---
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

有解决办法吗?

【问题讨论】:

    标签: amazon-web-services cloud amazon-cloudformation


    【解决方案1】:

    IamInstanceProfile 应该是仅限字符串,而不是字符串列表。所以应该是(去掉-):

          IamInstanceProfile: 
            Fn::ImportValue:
              Fn::Sub: "${SSMInstanceProfileStack}-Suffix" 
    

    【讨论】:

    • 谢谢。说得通。迟到让我想清楚!
    猜你喜欢
    • 2023-03-30
    • 2020-11-04
    • 2019-04-22
    • 2020-09-24
    • 1970-01-01
    • 1970-01-01
    • 2021-06-11
    • 2020-07-23
    • 1970-01-01
    相关资源
    最近更新 更多