Created
October 4, 2022 00:13
-
-
Save timmyers/9a2c012bcb7ddb17363249a37497e218 to your computer and use it in GitHub Desktop.
Pulumi IaC IAM Infrastructure Role
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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