-
-
Notifications
You must be signed in to change notification settings - Fork 4.5k
Remove last uses of get_aws_account_id() and aws_stack.get_region() #9641
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
Conversation
| account_id = context.account_id or DEFAULT_AWS_ACCOUNT_ID | ||
| region_name = context.region_name or AWS_REGION_US_EAST_1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This mimics the existing behaviour. At the time of executing this function, the account ID and region enricher handlers are not executed in the handler chain:
localstack/localstack/aws/app.py
Line 38 in f7eff1f
| handlers.serve_edge_router_rules, |
These enricher handlers are responsible for setting the values in the thread context storage. Thus, the get_aws_account_id() and aws_stack.get_region() return the fallback values.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the explanation! I hope this doesn't fallback often, I guess it falls back before actually failing but at least we have values. This makes sense and will be revisited in an upcoming APIGW refactor! thanks a lot
f7eff1f to
58711ac
Compare
| ): | ||
| """Fix the account ID in the ARNs returned in the given Flask response or string""" | ||
| existing = existing or ["123456789", "1234567890", "123456789012", get_aws_account_id()] | ||
| existing = existing or ["123456789", "1234567890", DEFAULT_ACCOUNT_ID] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove hardcoded Moto default account ID
bentsku
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! This is great again, nice cleaning up! 🧹 that is quite the effort that lead to this final removal. Awesome!
Also, nice spotting the bug in the APIGW SQS integration. It might need a follow up on our side to make the URL construction depend on the SQS URL strategy.
| account_id = context.account_id or DEFAULT_AWS_ACCOUNT_ID | ||
| region_name = context.region_name or AWS_REGION_US_EAST_1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the explanation! I hope this doesn't fallback often, I guess it falls back before actually failing but at least we have values. This makes sense and will be revisited in an upcoming APIGW refactor! thanks a lot
| url = urljoin(config.internal_service_url(), f"{get_aws_account_id()}/{queue}") | ||
| url = urljoin(config.internal_service_url(), f"{account_id}/{queue}") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, damn, this was actually a bad bug 😬 shouldn't this URL depends on the SQS URL strategy actually?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not necessarily, URL strategy controls how queues will be formatted in outputs. SQS will still recognise other queue URL formats if presented. Moreover the use of config.internal_service_url() prevents us from using the standard and domain strategies.
But you're right in another way, the region is currently omitted in the queue URL. I've added it with 71b862a. Great catch, thanks!
1f06f0e to
2ab9534
Compare
2ab9534 to
b26f3f6
Compare
Motivation
This PR removes last notable remaining uses of
get_aws_account_id()andaws_stack.get_region().These functions will be marked as deprecated or removed altogether in a subsequent PR.