ASG: Grant CF Signal Permission to IAM Role for Stack that created ASG, not stack that created IAM Role
- Dominant language
- TypeScript
- Stars
- 12.9k
- Forks
- 4.6k
- Avg merge
- 2d 3h
- Merged PRs (30d)
- 83
Description
### Describe the bug
When you create an IAM role in Stack A, a cf policy is added for Signal Resource to it for resource ARN of stack A. If you pass that IAM role to Stack B, and create an ASG in Stack B, the IAM role doesn't have permission by default to signal resource on Stack B.
### Expected Behavior
If you pass an IAM role as a prop to a stack that creates an ASG, the ASG code should add a policy to the IAM role with the ARN of the stack it was created in and grant permission to signal resource.
### Current Behavior
Passing an IAM role, created in Stack A, as a prop to Stack B (that creates an ASG), the ASG creation will always fail because the IAM role is missing permission to signal resource on Stack B.
### Reproduction Steps
Create a stack in CDK with an IAM role. Then create a second stack, with a prop of an IAM role. In that second stack, create an ASG with the role from the first stack (aka the prop).
### Possible Solution
Modify two places to use the current stack ARN as opposed to the ARN of the stack that created the IAM role: https://github.com/aws/aws-cdk/blob/v2.47.0/packages/@aws-cdk/aws-autoscaling/lib/auto-scaling-group.ts#L1587-L1600 and https://github.com/aws/aws-cdk/blob/v2.47.0/packages/@aws-cdk/aws-ec2/lib/cfn-init.ts#L113-L116
### Additional Information/Context
_No response_
### CDK CLI Version
v2
### Framework Version
_No response_
### Node.js Version
17
### OS
AL2
### Language
Typescript
### Language Version
_No response_
### Other information
_No response_
Contributor guide
Research direction
Start with the two locations identified in packages/@aws-cdk/aws-autoscaling/lib/auto-scaling-group.ts and packages/@aws-cdk/aws-ec2/lib/cfn-init.ts. Reproduce the two-stack case with an IAM role from Stack A and an ASG in Stack B, then verify that the resulting signal permission uses Stack B's ARN in both paths.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- aws, typescript
- Domain
- cloud, infrastructure, security
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100