CustomizeRolesOptions

class aws_cdk.aws_iam.CustomizeRolesOptions(*, prevent_synthesis=None, use_precreated_roles=None)

Bases: object

Options for customizing IAM role creation.

Parameters:
  • prevent_synthesis (Optional[bool]) – 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. Default: true

  • use_precreated_roles (Optional[Mapping[str, str]]) – 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. Default: - there are no precreated roles. Synthesis will fail if preventSynthesis=true

ExampleMetadata:

infused

Example:

# app: App

stack = Stack(app, "MyStack")
iam.Role.customize_roles(self,
    use_precreated_roles={
        "MyStack/MyLambda/ServiceRole": "my-role-name"
    }
)

Attributes

prevent_synthesis

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.

Default:

true

use_precreated_roles

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.

Default:
  • there are no precreated roles. Synthesis will fail if preventSynthesis=true

Example:

# app: App


stack = Stack(app, "MyStack")
iam.Role(stack, "MyRole",
    assumed_by=iam.AccountPrincipal("1111111111")
)

iam.Role.customize_roles(stack,
    use_precreated_roles={
        # absolute path
        "MyStack/MyRole": "my-precreated-role-name",
        # or relative path from `stack`
        "MyRole": "my-precreated-role"
    }
)