aws:ecs: fromSecretsManager causing cyclic dependency when secret creation is done in a separate stack #26511
Labels
@aws-cdk/aws-ecs
Related to Amazon Elastic Container
bug
This issue is a bug.
closed-for-staleness
This issue was automatically closed because it hadn't received any attention in a while.
response-requested
Waiting on additional info and feedback. Will move to "closing-soon" in 7 days.
Describe the bug
As per best practices, we have the secret manager's secret creation in a different stack, and we want to use this secret as an environment variable for an ecs task, when this ecs task and it's related task execution role is created in a different stack.
Expected Behavior
Stacks are created successfully.
Current Behavior
Error: secret stack depends on ecs stack. secret stack -> ecs stack/task execution role. adding this dependency will would create a cyclic reference.
Since we want secret stack to be created first and then we pass the secret to the ecs stack, we get a cyclic dependency when we try to set the secret as env variable, because the function tries to add policy to the secret's kms key which allows access to the ecs task's execution role to access the secret.
Reproduction Steps
Possible Solution
We get an option where fromSecretsManager function gives an optional parameter which enables us to either create or not create the policy statement automatically for the KMS key.
Additional Information/Context
No response
CDK CLI Version
2.85.0
Framework Version
No response
Node.js Version
18.16.0
OS
Windows 10
Language
Typescript
Language Version
No response
Other information
No response
The text was updated successfully, but these errors were encountered: