Skip to content

(aws-iam): grantAssumeRole does nothing #24507

@dkaksl

Description

@dkaksl

Describe the bug

Role.grantAssumeRole() does not make any difference in the generated policy.

Expected Behavior

grantAssumeRole should grant the given princial permission to assume the role.

Current Behavior

No-op.

Reproduction Steps

const role = new Role(this, 'role', {
  assumedBy: new AccountPrincipal(this.account)
})
role.grantAssumeRole(new AccountPrincipal('123456789')) // no-op

Possible Solution

No response

Additional Information/Context

Workaround:

const role = new Role(this, 'role', {
  assumedBy: new AccountPrincipal(this.account)
})

//role.grantAssumeRole(new AccountPrincipal('123456789'))

role.assumeRolePolicy?.addStatements(
  new PolicyStatement({
    effect: Effect.ALLOW,
    actions: ['sts:AssumeRole'],
    principals: [new AccountPrincipal('123456789')]
  })
)

CDK CLI Version

2.67.0

Framework Version

No response

Node.js Version

v18.14.2

OS

Ubuntu

Language

Typescript

Language Version

No response

Other information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    @aws-cdk/aws-iamRelated to AWS Identity and Access ManagementbugThis issue is a bug.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions