amazon-web-services - 属性 IamInstanceProfile 的值必须为 String 类型

标签 amazon-web-services cloud aws-cloudformation

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

如果实例配置文件资源位于模板中,我可以 !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/

相关文章:

java - 如何在互联网上使用 Eclipse 编写 Java 代码

amazon-web-services - 如何在存储桶名称中使用变量 AWS Cloudformation

amazon-web-services - 使用 AWS API Gateway + Lambda/ECS 开发的微服务应该怎么讲?

java - 绑定(bind) aws sqs 区域 Camel

architecture - 客户端-服务器云计算 : differences, 的缺点和优点?

amazon-web-services - AWS CloudFormation 参数中字符串类型的最大长度是多少?

jenkins - 将参数从 cloudformation 作为变量传递到 jenkins 实例中

amazon-web-services - 添加后 AWS 负载均衡器监听器消失

typescript - 在 APIGatewayProxyEvent 中,哪个字段会给我 URL?

java - 将标签云添加到 OpenCMS 网站