8000 Fix deletion of AWS::IAM::Policy by dominikschubert · Pull Request #9092 · localstack/localstack · GitHub
[go: up one dir, main page]

Skip to content

Fix deletion of AWS::IAM::Policy #9092

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

Merged
merged 4 commits into from
Sep 12, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
improve logic around failing resource action a bit
  • Loading branch information
dominikschubert committed Sep 7, 2023
commit c2243b097c4bf7222814c3e308d4a7392e51a28f
27 changes: 23 additions & 4 deletions localstack/services/cloudformation/engine/template_deployer.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
)
from localstack.services.cloudformation.resource_provider import (
Credentials,
OperationStatus,
ResourceProviderExecutor,
ResourceProviderPayload,
get_resource_type,
Expand Down Expand Up @@ -1358,13 +1359,31 @@ def apply_change(self, change: ChangeConfig, stack: Stack) -> None:

progress_event = executor.deploy_loop(resource_provider_payload) # noqa

# TODO: clean up the surrounding loop (do_apply_changes_in_loop) so that the responsibilities are clearer
stack_action = get_action_name_for_resource_change(action)
10000 match progress_event.status:
case OperationStatus.FAILED:
stack.set_resource_status(resource_id, f"{stack_action}_FAILED")
# TODO: remove exception raising here?
Copy link
Member Author

Choose a reason for hiding this comment

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

currently we still need to raise otherwise the enclosing loop in the template deployer won't properly set the stack/resource states

# TODO: fix request token
raise Exception(
f'Resource handler returned message: "{progress_event.message}" (RequestToken: 10c10335-276a-33d3-5c07-018b684c3d26, HandlerErrorCode: InvalidRequest){progress_event.error_code}'
)
case OperationStatus.SUCCESS:
stack.set_resource_status(resource_id, f"{stack_action}_COMPLETE")
case OperationStatus.PENDING:
# this isn't really a state we use at the moment
raise Exception(
f"Usage of currently unsupported operation status detected: {OperationStatus.PENDING}"
)
case OperationStatus.IN_PROGRESS:
raise Exception("Resource deployment loop should not finish in this state")
case unknown_status:
raise Exception(f"Unknown operation status: {unknown_status}")

# TODO: this is probably already done in executor, try removing this
resource["Properties"] = progress_event.resource_model

# update resource status and physical resource id
stack_action = get_action_name_for_resource_change(action)
stack.set_resource_status(resource_id, f"{stack_action}_COMPLETE")

def create_resource_provider_executor(self) -> ResourceProviderExecutor:
return ResourceProviderExecutor(
stack_name=self.stack.stack_name,
Expand Down
3 changes: 3 additions & 0 deletions localstack/services/cloudformation/resource_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -640,6 +640,9 @@ def deploy_loop(

event = self.execute_action(resource_provider, payload)

if event.status == OperationStatus.FAILED:
return event

if event.status == OperationStatus.SUCCESS:

if not isinstance(resource_provider, LegacyResourceProvider):
Expand Down
0