Last active
July 29, 2022 22:19
-
-
Save undeadops/2039c6c38efd2401dc14c2b542d4b288 to your computer and use it in GitHub Desktop.
pulumi - create inline iam policy
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
const kmsArns: pulumi.Output<string>[] = []; | |
config.get('kmsKeys').forEach((keyArgs: KmsKeyConfig) => { | |
const kms = new KmsKeys({ | |
env: config.get('env'), | |
...keyArgs, | |
}); | |
kmsArns.push(kms.arn); | |
}); | |
const kmsInlinePolicy = pulumi.all(args.kmsKeys).apply((kmsKeys) => { | |
const keys: any[] = []; | |
kmsKeys.forEach((key) => { keys.push(key)}); | |
return aws.iam.getPolicyDocument({ | |
statements: [{ | |
actions: [ | |
"kms:Encrypt", | |
"kms:Decrypt", | |
], | |
effect: "Allow", | |
resources: keys, | |
}], | |
}); | |
}); | |
const role = new aws.iam.Role( | |
`k8sapp-${service.name}-sa-role`, | |
{ | |
name: `k8sapp-${env}-${service.name}`, | |
description: `EKS Service Account: ${service.namespace}/${service.serviceAccountName}`, | |
assumeRolePolicy, | |
tags: { | |
Environment: env, | |
Name: service.name, | |
...service.tags, | |
}, | |
inlinePolicies: [ | |
{ | |
name: "kmsAllow", | |
policy: kmsInlinePolicy.json | |
}, | |
], | |
}, | |
{ parent: this } | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment