interface RoleLookupOptions
Language | Type name |
---|---|
![]() | Amazon.CDK.AWS.IAM.RoleLookupOptions |
![]() | github.com/aws/aws-cdk-go/awscdk/v2/awsiam#RoleLookupOptions |
![]() | software.amazon.awscdk.services.iam.RoleLookupOptions |
![]() | aws_cdk.aws_iam.RoleLookupOptions |
![]() | aws-cdk-lib » aws_iam » RoleLookupOptions |
Properties for looking up an existing Role.
Example
const role = iam.Role.fromLookup(this, 'Role', {
roleName: 'MyExistingRole',
});
Properties
Name | Type | Description |
---|---|---|
role | string | The name of the role to lookup. |
add | boolean | For immutable roles: add grants to resources instead of dropping them. |
default | string | Any policies created by this role will use this value as their ID, if specified. |
mutable? | boolean | Whether the imported role can be modified by attaching policy resources to it. |
roleName
Type:
string
The name of the role to lookup.
If the role you want to lookup is a service role, you need to specify the role name without the 'service-role' prefix. For example, if the role arn is 'arn:aws:iam::123456789012:role/service-role/ExampleServiceExecutionRole', you need to specify the role name as 'ExampleServiceExecutionRole'.
addGrantsToResources?
Type:
boolean
(optional, default: 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?
Type:
string
(optional, default: '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?
Type:
boolean
(optional, default: true)
Whether the imported role can be modified by attaching policy resources to it.