Add check in delete environment for create_failed stacks #1386
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Feature or Bugfix
Detail
When an environment stack fails in its creation (the CloudFormation stack is not deployed), the cdk-pivot role won't be created. Then, when a user tries to delete the environment they will get an error
Data.all Environment Pivot Role does not have permissions to to get the list of attached policies to the role dataall-testenva-jv54380n: An error occurred (AccessDenied) when calling the AssumeRole operation: User: arn:aws:sts::XXXXXXX:assumed-role/tool-tst-graphql-role/tool-tst-graphql is not authorized to perform: sts:AssumeRole on resource: arn:aws:iam::1111111111:role/dataallPivotRole-cdk',
Those managed permissions do not even exist if the environment stack was never deployed successfully. This PR adds a check that verifies that the environment stack was deployed before removing env-managed policies.
Relates
Security
Please answer the questions below briefly where applicable, or write
N/A
. Based onOWASP 10.
fetching data from storage outside the application (e.g. a database, an S3 bucket)?
eval
or similar functions are used?By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.