Scilla
Scilla

Reputation: 385

Value of property IamInstanceProfile must be of type String

I want to reference my instance profile value from another stack.

If the Instance profile resource would be in the template, I could !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"

I am getting this error, the resource is deployed.

Value of property IamInstanceProfile must be of type String

Is there a fix for this?

Upvotes: 2

Views: 1109

Answers (2)

user21295874
user21295874

Reputation: 1

for ec2 instance it will expect profilenName only. for launch configuration and launchtemplate we can give ARN as well.

Upvotes: 0

Marcin
Marcin

Reputation: 238209

IamInstanceProfile should be a string only, not a list of strings. So it should be (remove -):

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

Upvotes: 1

Related Questions