@aws-cdk/aws-iam
CDK routines for easily assigning correct and minimal IAM permissions
npm install @aws-cdk/aws-iam@1.53.0
ServicePrincipal
An IAM principal that represents an AWS service (i.e. sqs.amazonaws.com).
import { ServicePrincipal } from '@aws-cdk/aws-iam'new ServicePrincipal(service: string, opts?: ServicePrincipalOpts)
Name | Type | Description |
---|---|---|
service | string | AWS service (i.e. sqs.amazonaws.com). |
opts | ServicePrincipalOpts | No description. |
- Type: string
AWS service (i.e. sqs.amazonaws.com).
- Type: ServicePrincipalOpts
Name | Description |
---|---|
addToPolicy | Add to the policy of this principal. |
addToPrincipalPolicy | Add to the policy of this principal. |
toJSON | JSON-ify the principal. |
toString | Returns a string representation of an object. |
withConditions | Returns a new PrincipalWithConditions using this principal as the base, with the passed conditions added. |
public addToPolicy(statement: PolicyStatement): boolean
Add to the policy of this principal.
- Type: PolicyStatement
public addToPrincipalPolicy(_statement: PolicyStatement): AddToPrincipalPolicyResult
Add to the policy of this principal.
- Type: PolicyStatement
public toJSON(): {[ key: string ]: string[]}
JSON-ify the principal.
Used when JSON.stringify() is called
public toString(): string
Returns a string representation of an object.
public withConditions(conditions: {[ key: string ]: any}): IPrincipal
Returns a new PrincipalWithConditions using this principal as the base, with the passed conditions added.
When there is a value for the same operator and key in both the principal and the conditions parameter, the value from the conditions parameter will be used.
- Type: {[ key: string ]: any}
Name | Type | Description |
---|---|---|
assumeRoleAction | string | When this Principal is used in an AssumeRole policy, the action to use. |
grantPrincipal | IPrincipal | The principal to grant permissions to. |
policyFragment | PrincipalPolicyFragment | Return the policy fragment that identifies this principal in a Policy. |
service | string | AWS service (i.e. sqs.amazonaws.com). |
public readonly assumeRoleAction: string;
- Type: string
When this Principal is used in an AssumeRole policy, the action to use.
public readonly grantPrincipal: IPrincipal;
- Type: IPrincipal
The principal to grant permissions to.
public readonly policyFragment: PrincipalPolicyFragment;
- Type: PrincipalPolicyFragment
Return the policy fragment that identifies this principal in a Policy.
public readonly service: string;
- Type: string
AWS service (i.e. sqs.amazonaws.com).
Use the snippets below in your Git repositories or elsewhere to add a button that links to this package. The button will automatically update to light mode or dark mode based on whether the user's client has requested a light or dark theme.
[](https://constructs.dev/packages/@aws-cdk/aws-iam)
<a href="https://constructs.dev/packages/@aws-cdk/aws-iam"><img src="https://constructs.dev/badge?package=%40aws-cdk%2Faws-iam" alt="View on Construct Hub"/></a>