When running sceptre diff, we get an UnboundLocalError
due to lack of permissions, can we make the error clearer to the user?
#1519
Labels
Subject of the issue
When running
sceptre diff some/stack.yaml
we get anUnboundLocalError
, caused by lack of permissions, can we make the error clearer to the user?Your environment
Steps to reproduce
We use AWS SSO to manage access to accounts, and obtain temporary access to AWS via SCIM integration with Azure.
We encounter this error when running
sceptre diff some/stack.yaml
, when the temporary access is not active.i.e. We do not currently have AWS permissions
Expected behaviour
We expect sceptre to fail because we don't have access, but we also expect it to make it clear the reason is because of receiving 403 Forbidden when interacting with the AWS API's.
Actual behaviour
We see an
UnboundLocalError
, which is unhelpful and caused us to dig into the sceptre source code to see what was wrong.Cause of issue
In
_create_deployed_stack_config
ofsceptre/diffing/stack_differ.py
there is a try/except block, but the except only checks forerr.response["Error"]["Message"].endswith("does not exist")
When the error is a permission error,
err
is instead:In this case, the code continues on to line 206
However
description
was never set and so we getUnboundLocalError
Suggested Fix
I'm happy to raise a PR, if you approve of the following suggestion:
We can add another check for when
err.response["Error"]["Code"] == "ForbiddenException"
and raise an error in this case, or perhaps we should just allowerr
to be thrown since the code can not continue from here?I.e.
Let me know how you'd prefer the fix to function, but I think it would be good to get the root issue (
403 Forbidden / No access
) up to the user.Thanks,
Jak
The text was updated successfully, but these errors were encountered: