Skip to content

Instantly share code, notes, and snippets.

@timmyers
Created October 4, 2022 00:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save timmyers/9a2c012bcb7ddb17363249a37497e218 to your computer and use it in GitHub Desktop.
Save timmyers/9a2c012bcb7ddb17363249a37497e218 to your computer and use it in GitHub Desktop.
Pulumi IaC IAM Infrastructure Role
import * as aws from '@pulumi/aws';
const defaultTags = { Creator: 'pulumi' };
const awsAccountId = pulumi.output(aws.getCallerIdentity()).accountId;
const infrastructureRole = new aws.iam.Role('infrastructure', {
name: 'infrastructure',
assumeRolePolicy: {
Version: '2012-10-17',
Statement: [{
Effect: 'Allow',
Action: 'sts:AssumeRole',
Principal: {
AWS: pulumi.interpolate`${awsAccountId}`,
}
}],
},
tags: defaultTags,
})
new aws.iam.RolePolicyAttachment('infrastructure-admin', {
role: infrastructureRole.name,
policyArn: aws.iam.getPolicyOutput({ name: 'SystemAdministrator'}).arn,
});
new aws.iam.RolePolicyAttachment('infrastructure-iam', {
role: infrastructureRole.name,
policyArn: aws.iam.getPolicyOutput({ name: 'IAMFullAccess' }).arn,
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment