CustomizeRolesOptions Struct
Options for customizing IAM role creation.
| Source | aws-iam/lib/role.ts |
|---|---|
| Type last changed |
Example
csharp
// Install: dotnet add package Amazon.CDK.Lib
App app;
var stack = new Stack(app, "MyStack");
Role.CustomizeRoles(this, new CustomizeRolesOptions {
UsePrecreatedRoles = new Dictionary<string, string> {
{ "MyStack/MyLambda/ServiceRole", "my-role-name" }
}
});
go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
var app App
stack := awscdk.Newstack(app, jsii.String("MyStack"))
iam.Role_CustomizeRoles(this, &CustomizeRolesOptions{
UsePrecreatedRoles: map[string]*string{
"MyStack/MyLambda/ServiceRole": jsii.String("my-role-name"),
},
})
Properties
preventSynthesisoptionalbooleanprevent_synthesisoptionalboolpreventSynthesisoptionalBooleanPreventSynthesisoptionalboolPreventSynthesisoptional*bool = 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.
usePrecreatedRolesoptional{ [key: string]: string }use_precreated_rolesoptionaltyping.Mapping[str, str]usePrecreatedRolesoptionalMap<String, String>UsePrecreatedRolesoptionalIDictionary<string, string>UsePrecreatedRolesoptional*map[string]*string #A list of precreated IAM roles to substitute for roles that CDK is creating.
Default: there are no precreated roles. Synthesis will fail if preventSynthesis=true
The constructPath can be either a relative or absolute path from the scope that customizeRoles is used on to the role being created.
example
ts
declare const app: App;
const stack = new Stack(app, 'MyStack');
new iam.Role(stack, 'MyRole', {
assumedBy: new iam.AccountPrincipal('111111111111'),
});
iam.Role.customizeRoles(stack, {
usePrecreatedRoles: {
// absolute path
'MyStack/MyRole': 'my-precreated-role-name',
// or relative path from `stack`
'MyRole': 'my-precreated-role',
},
});