https://pulumi.com logo
Title
s

salmon-ghost-86211

07/15/2020, 11:13 PM
I'm trying to assign an instance profile I just created to a Launch Template , but I get
error: aws:ec2/launchTemplate:LaunchTemplate resource 'my-launch-template' has a problem: iam_instance_profile.0: expected object, got string
Here's my basic code snippet
const myInstanceRole = new ServiceRole(
    `${pulumi.getStack()}-my-instanceRole`,
    {
        managedPolicyArns: [
            "arn:aws:iam::aws:policy/AmazonSSMManagedInstanceCore",
            "arn:aws:iam::aws:policy/CloudWatchAgentServerPolicy"
        ],
        service: "<http://ec2.amazonaws.com|ec2.amazonaws.com>"
    }
).role;

const myInstanceProfile = new aws.iam.InstanceProfile(
    "my-instance-profile",
    { role: myInstanceRole }
);

const myLaunchTemplate = new aws.ec2.LaunchTemplate(
    `${namePrefix}-launch-template`,
    {
        description: `Builds the ${namePrefix} my server`,
        iamInstanceProfile: myInstanceProfile,
        imageId: amiId,
        instanceType: instanceType,
        keyName: sshKey,
        namePrefix: namePrefix,
        userData: userData,
        vpcSecurityGroupIds: availableSubnetIds,
    }
);
Any ideas?
b

billowy-army-68599

07/15/2020, 11:17 PM
hey @salmon-ghost-86211, I believe that parameter takes an object, like this
iamInstanceProfile: {
        arn: instanceProfile.arn
}
s

salmon-ghost-86211

07/16/2020, 2:48 PM
Crikey! Totally missed that. Thank you @billowy-army-68599