# CustomizeRolesOptions

Options for customizing IAM role creation.

- Source: [`aws-iam/lib/role.ts`](https://github.com/aws/aws-cdk/blob/v2.275.0/packages/aws-cdk-lib/aws-iam/lib/role.ts#L222)
- Type last changed: v2.51.0 · 18 Nov 2022

## Example

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

## Properties

- `preventSynthesis`: boolean = 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`: { [key: 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.

  ```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',
    },
  });
  ```
