https://pulumi.com logo
#aws
Title
# aws
l

limited-rainbow-51650

03/04/2020, 8:38 PM
Am I missing something in the definition of my
aws.iam.Role
here? The
Version
property is not assignable…
s

salmon-ghost-86211

03/04/2020, 8:44 PM
Version is not a property. It is a part of the JSON blob that gets passed to
assumeRolePolicy
.
l

limited-rainbow-51650

03/04/2020, 9:00 PM
@salmon-ghost-86211
assumeRolePolicy
is defined as follows:
readonly assumeRolePolicy: pulumi.Input<string | PolicyDocument>;
You can either pass a full JSON string blob, or use the
PolicyDocument
type which offers you Intellisense completion in the editor. I chose that and then
Version
is a property defined as:
Version: Input<"2008-10-17" | "2012-10-17">;
s

salmon-ghost-86211

03/04/2020, 9:16 PM
Yes. You are correct. In that case
Version
and `Statement`are properties under
assumeRolePolicy
. The below worked for me.
Copy code
const testRole = new aws.iam.Role("testRole", {
    assumeRolePolicy: {
        Version: "2012-10-17",
        Statement: [
            {
                "Action": "sts:AssumeRole",
                "Principal": {
                "Service": "<http://ec2.amazonaws.com|ec2.amazonaws.com>"
                },
                "Effect": "Allow",
                "Sid": ""            }
        ]
    },
    tags: {
        "Purpose": "Just testing",
    }
l

limited-rainbow-51650

03/04/2020, 9:17 PM
Strange. The error was actually in my
Condition
. Once I had that fixed, the error on
Version
disappeared also.
s

salmon-ghost-86211

03/04/2020, 9:17 PM
I think I actually prefer that layout over the JSON blob.
Interesting.
l

limited-rainbow-51650

03/04/2020, 9:22 PM
@salmon-ghost-86211 in the snippet you posted, you can even replace the String keys within your
Statement
with property names. In short: remove the quotes in the key names.
s

salmon-ghost-86211

03/04/2020, 9:57 PM
Yes. I copied an example and modified it quickly, but definitely a good reminder. Thanks.
w

white-balloon-205

03/05/2020, 2:23 AM
I saw this myself recently. I think there must be a TypeScript compiler bug (and somewhat recent regression) here. For now, you can insert a cast like
as any
.