Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add check in delete environment for create_failed stacks #1386

Merged
merged 1 commit into from
Jul 3, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 13 additions & 7 deletions backend/dataall/core/environment/services/environment_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -868,13 +868,19 @@ def delete_environment(uri):
f'related objects before proceeding',
)
else:
PolicyManager(
role_name=environment.EnvironmentDefaultIAMRoleName,
environmentUri=environment.environmentUri,
account=environment.AwsAccountId,
region=environment.region,
resource_prefix=environment.resourcePrefix,
).delete_all_policies()
if StackRepository.find_stack_by_target_uri(session, environment.environmentUri) not in [
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In case auto pivotRole creation the pivot role won't exist as well (I've come across this issue a few times) so I think that this check will fail regardless. Wdyt?

StackStatus.ROLLBACK_COMPLETE.value,
StackStatus.ROLLBACK_IN_PROGRESS.value,
StackStatus.CREATE_FAILED.value,
StackStatus.DELETE_COMPLETE.value,
]:
PolicyManager(
role_name=environment.EnvironmentDefaultIAMRoleName,
environmentUri=environment.environmentUri,
account=environment.AwsAccountId,
region=environment.region,
resource_prefix=environment.resourcePrefix,
).delete_all_policies()

KeyValueTagRepository.delete_key_value_tags(session, environment.environmentUri, 'environment')
EnvironmentResourceManager.delete_env(session, environment)
Expand Down
Loading