sparse-intern-71089
09/09/2020, 2:50 AMkind-mechanic-53546
09/09/2020, 3:20 AMarn:aws:iam::{account}:{user}
e.g.
{
"Version": "2012-10-17",
"Statement": {
"Effect": "Allow",
"Principal": {
"AWS": "arn:aws:iam::123456789012:root"
},
"Action": "sts:AssumeRole"
}
}
from herenarrow-jackal-57645
09/09/2020, 3:25 AMroot
because I do not want to grant permission to all users of the account.
And if you check the error message, the user ARN is actually correctkind-mechanic-53546
09/09/2020, 3:25 AMkind-mechanic-53546
09/09/2020, 3:26 AMkind-mechanic-53546
09/09/2020, 3:27 AMkind-mechanic-53546
09/09/2020, 3:27 AMnarrow-jackal-57645
09/09/2020, 3:32 AMnarrow-jackal-57645
09/09/2020, 3:33 AMkind-mechanic-53546
09/09/2020, 3:33 AMkind-mechanic-53546
09/09/2020, 3:33 AMkind-mechanic-53546
09/09/2020, 3:33 AMnarrow-jackal-57645
09/09/2020, 3:34 AMpulumi up
narrow-jackal-57645
09/09/2020, 3:34 AMindex.ts
to add another userkind-mechanic-53546
09/09/2020, 3:35 AMnarrow-jackal-57645
09/09/2020, 3:35 AMnarrow-jackal-57645
09/09/2020, 3:36 AMpulumi up
for step 2the role policy is updated correctlykind-mechanic-53546
09/09/2020, 3:50 AMkind-mechanic-53546
09/09/2020, 3:51 AMimport * as pulumi from "@pulumi/pulumi";
import * as kubernetes from "@pulumi/kubernetes";
import * as aws from "@pulumi/aws";
const getAccountARN = (accountId: string, resource: string = "*") => {
return `arn:aws:iam::${accountId}:${resource}`
}
interface UserList {
[username: string]: aws.iam.User;
}
const accountID = "437763615564"
let users: UserList = {};
// create 1 user
const user1 = new aws.iam.User("user1", {
name: "user1"
});
users["user1"] = user1;
// create 2 user
const user2 = new aws.iam.User("user2", {
name: "user2"
});
users["user2"] = user2;
// create a new role with sts:AssumeRole for those users
const assumeRolePolicy = aws.iam.getPolicyDocument({
statements: [{
effect: "Allow",
actions: ["sts:AssumeRole"],
principals: [{
type: "AWS",
identifiers: Object.keys(users).map((username) => {
return getAccountARN(accountID, `user/${username}`)
})
}]
}]
});
const role = new aws.iam.Role("devs", {
assumeRolePolicy: assumeRolePolicy.then(policy => policy.json),
name: "super-uber-devs"
}, {
//dependsOn: Object.values(users)
dependsOn: [user1, user2]
});
narrow-jackal-57645
09/09/2020, 3:52 AMkind-mechanic-53546
09/09/2020, 3:54 AMkind-mechanic-53546
09/09/2020, 3:55 AMnarrow-jackal-57645
09/09/2020, 4:01 AMkind-mechanic-53546
09/09/2020, 4:04 AMnarrow-jackal-57645
09/09/2020, 5:13 AMkind-mechanic-53546
09/09/2020, 6:23 AMkind-mechanic-53546
09/09/2020, 6:23 AMgentle-diamond-70147
09/09/2020, 5:47 PMworried-city-86458
09/09/2020, 10:19 PMgentle-diamond-70147
09/09/2020, 10:39 PMnarrow-jackal-57645
09/11/2020, 3:19 AMnarrow-jackal-57645
09/11/2020, 3:19 AMgentle-diamond-70147
09/11/2020, 3:20 AM