# FromRoleArnOptions

Struct · Stable

Options allowing customizing the behavior of `Role.fromRoleArn`.

Used as argument in: [Role.fromRoleArn](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_iam.Role.html#fromrolearn)

- Source: [`aws-iam/lib/role.ts`](https://github.com/aws/aws-cdk/blob/v2.278.0/packages/aws-cdk-lib/aws-iam/lib/role.ts#L186)
- Type last changed: v2.29.0 · 23 Jun 2022

## Example

TypeScript:

```ts
const role = iam.Role.fromRoleArn(this, 'Role', 'arn:aws:iam::123456789012:role/MyExistingRole', {
  // Set 'mutable' to 'false' to use the role as-is and prevent adding new
  // policies to it. The default is 'true', which means the role may be
  // modified as part of the deployment.
  mutable: false,
});
```

Python:

```python
role = iam.Role.from_role_arn(self, "Role", "arn:aws:iam::123456789012:role/MyExistingRole",
    # Set 'mutable' to 'false' to use the role as-is and prevent adding new
    # policies to it. The default is 'true', which means the role may be
    # modified as part of the deployment.
    mutable=False
)
```

Java:

```java
IRole role = Role.fromRoleArn(this, "Role", "arn:aws:iam::123456789012:role/MyExistingRole", FromRoleArnOptions.builder()
        // Set 'mutable' to 'false' to use the role as-is and prevent adding new
        // policies to it. The default is 'true', which means the role may be
        // modified as part of the deployment.
        .mutable(false)
        .build());
```

C#:

```csharp
// Install: dotnet add package Amazon.CDK.Lib
var role = Role.FromRoleArn(this, "Role", "arn:aws:iam::123456789012:role/MyExistingRole", new FromRoleArnOptions {
    // Set 'mutable' to 'false' to use the role as-is and prevent adding new
    // policies to it. The default is 'true', which means the role may be
    // modified as part of the deployment.
    Mutable = false
});
```

Go:

```go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
role := iam.Role_FromRoleArn(this, jsii.String("Role"), jsii.String("arn:aws:iam::123456789012:role/MyExistingRole"), &FromRoleArnOptions{
	// Set 'mutable' to 'false' to use the role as-is and prevent adding new
	// policies to it. The default is 'true', which means the role may be
	// modified as part of the deployment.
	Mutable: jsii.Boolean(false),
})
```

## Properties

- `addGrantsToResources`: boolean = false — For immutable roles: add grants to resources instead of dropping them.

  If this is `false` or not specified, grant permissions added to this role are ignored.
  It is your own responsibility to make sure the role has the required permissions.

  If this is `true`, any grant permissions will be added to the resource instead.

- `defaultPolicyName`: string = 'Policy' — Any policies created by this role will use this value as their ID, if specified.

  Specify this if importing the same role in multiple stacks, and granting it
  different permissions in at least two stacks. If this is not specified
  (or if the same name is specified in more than one stack),
  a CloudFormation issue will result in the policy created in whichever stack
  is deployed last overwriting the policies created by the others.

- `mutable`: boolean = true — Whether the imported role can be modified by attaching policy resources to it.
