aws-cdk-lib.aws_iam.CustomizeRolesOptions

interface CustomizeRolesOptions

LanguageType name
.NETAmazon.CDK.AWS.IAM.CustomizeRolesOptions
Gogithub.com/aws/aws-cdk-go/awscdk/v2/awsiam#CustomizeRolesOptions
Javasoftware.amazon.awscdk.services.iam.CustomizeRolesOptions
Pythonaws_cdk.aws_iam.CustomizeRolesOptions
TypeScript (source)aws-cdk-lib » aws_iam » CustomizeRolesOptions

Options for customizing IAM role creation.

Example

declare const app: App;
const stack = new Stack(app, 'MyStack');
iam.Role.customizeRoles(this, {
  usePrecreatedRoles: {
    'MyStack/MyLambda/ServiceRole': 'my-role-name',
  }
});

Properties

NameTypeDescription
preventSynthesis?booleanWhether or not to synthesize the resource into the CFN template.
usePrecreatedRoles?{ [string]: string }A list of precreated IAM roles to substitute for roles that CDK is creating.

preventSynthesis?

Type: boolean (optional, default: true)

Whether or not to synthesize the resource into the CFN template.

Set this to false if you still want to create the resources and you also want to create the policy report.


usePrecreatedRoles?

Type: { [string]: string } (optional, default: there are no precreated roles. Synthesis will fail if preventSynthesis=true)

A list of precreated IAM roles to substitute for roles that CDK is creating.

The constructPath can be either a relative or absolute path from the scope that customizeRoles is used on to the role being created. Example

declare const app: App;

const stack = new Stack(app, 'MyStack');
new iam.Role(stack, 'MyRole', {
 assumedBy: new iam.AccountPrincipal('1111111111'),
});

iam.Role.customizeRoles(stack, {
  usePrecreatedRoles: {
    // absolute path
    'MyStack/MyRole': 'my-precreated-role-name',
    // or relative path from `stack`
    'MyRole': 'my-precreated-role',
  },
});