Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: allow assumeRoleAction to be set #31129

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions packages/aws-cdk-lib/aws-iam/lib/role.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,12 @@ export interface RoleProps {
*/
readonly assumedBy: IPrincipal;

/**
* The action to use when this Principal is used
* @default - sts:AssumeRole
*/
readonly assumeRoleAction?: 'sts:AssumeRole';

/**
* ID that the role assumer needs to provide when assuming this role
*
Expand Down Expand Up @@ -370,8 +376,6 @@ export class Role extends Resource implements IRole {
public readonly grantPrincipal: IPrincipal = this;
public readonly principalAccount: string | undefined = this.env.account;

public readonly assumeRoleAction: string = 'sts:AssumeRole';

/**
* The assume role policy document associated with this role.
*/
Expand Down
5 changes: 3 additions & 2 deletions packages/aws-cdk-lib/aws-iam/test/role.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,7 @@ describe('customizeRoles', () => {
// WHEN
const role = new Role(stack, 'Role', {
assumedBy: new ServicePrincipal('sns.amazonaws.com'),
assumeRoleAction: "sts:AssumeRoleWithWebIdentity";
});
const principal = Role.fromRoleName(stack, 'OtherRole', 'OtherRole');
role.grant(principal, 'sts:AssumeRole');
Expand Down Expand Up @@ -288,7 +289,7 @@ describe('customizeRoles', () => {
},
conditions: {},
},
AssumeRoleAction: 'sts:AssumeRole',
AssumeRoleAction: 'sts:AssumeRoleWithWebIdentity',
PrincipalAccount: {
Ref: 'AWS::AccountId',
},
Expand Down Expand Up @@ -1435,4 +1436,4 @@ test('roleName validation with Tokens', () =>{
}).not.toThrow('Invalid roleName');

jest.clearAllMocks();
});
});
Loading