import * as aws from "@pulumi/aws" ; import * as pulumi from "@pulumi/pulumi" ; import * as utils from "./utils" ; internal export function createRoleAndPolicies ( name , assumeRolePolicy , policyArns , opts ) { if ( typeof assumeRolePolicy !== "string" ) { assumeRolePolicy = JSON . stringify ( assumeRolePolicy ) ; } const role = new aws . iam . Role ( name , { assumeRolePolicy } , opts ) ; const policies = [ ] ; for ( let i = 0 ; i < policyArns . length ; i ++ ) { const policyArn = policyArns [ i ] ; policies . push ( new aws . iam . RolePolicyAttachment ( `${ name }-${ utils . sha1hash ( policyArn ) }` , { role , policyArn } , opts ) ) ; } return { role , policies } ; } internal export function createRole ( name , assumeRolePolicy , policyArns , opts ) { const { role } = createRoleAndPolicies ( name , assumeRolePolicy , policyArns , opts ) ; return role ; }