aws / aws-cdk

The AWS Cloud Development Kit is a framework for defining cloud infrastructure in code
https://aws.amazon.com/cdk
Apache License 2.0
11.33k stars 3.76k forks source link

aws_ec2.Instance: Generates dependency on role even after removal #30633

Open abstractalchemist opened 4 days ago

abstractalchemist commented 4 days ago

Describe the bug

I'm trying to prevent the Instance class from generating a new role because the environment I'm deploying to prevents me from creating the cloudformation service-role which can create IAM roles/instance profiles. I'm able to remove the instance profile and role ( which is very hacky, and honestly I'm not sure why it is generated by default, and why there is no way to just say don't remove it ), but even after doing so, the instance class still generates the dependency, This causes a dependency error when the changeset is deployed.

Expected Behavior

I expect there to be no dependency generated when I remove the instance profile and role. And I know I can sort of prevent this behavior with customize_roles, but that still demands a role.

Current Behavior

Generates a "depends-on" entry in the instance resource in the cloudformation template.

Reproduction Steps

My code for testing this is here: rke2-testing

Possible Solution

No response

Additional Information/Context

No response

CDK CLI Version

2.147.0 (build 3338fc0)

Framework Version

No response

Node.js Version

v20.10.0

OS

Fedora 30

Language

Python

Language Version

3.12.3

Other information

No response