-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
cloudwatch: fix functionality of metrics for multi-accounts and region #9945
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
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.
Thank you for fixing this @sannya-singal ✨
I can confirm that using a different account failed before the fix and now works properly 👏👏👏: TEST_AWS_ACCOUNT_ID=111111111111 LAMBDA_DEV_PORT_EXPOSE=1 TEST_PATH="tests/aws/services/cloudwatch/test_cloudwatch_metrics.py::TestCloudWatchLambdaMetrics::test_lambda_invoke_successful" make test
The region should already work properly.
Parsing the account_id
from the function ARN requires regex matching for every CloudWatch metric submission. We can speed things up by passing the account_id explicitly instead of parsing it. Hence, I suggest passing something like account_id=self.function_version.id.account,
in version_manager.py
.
cae2c20
to
83c43cc
Compare
Ext Integration Tests- https://github.com/localstack/localstack-ext/actions/runs/7721773635 |
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 👍
Thank you @sannya-singal for fixing multi-accounts for Lambda CloudWatch metrics 🥳
Thanks @joe4dev 🚀 🎉 |
Motivation
When using values other than
000000000000
for account ID orus-east-1
for region,cloudwatch
tests should still create the consequent resources in these accounts and region.Changes
This PR adds
account_id
parameter to thecloudwatch
client when publishing the lambda metric on function invoke. The remaining changes involves propagating its value to the corresponding functions.Testing
The tests were failing previously when executed with a non-default account ID, set through environment variables (
TEST_AWS_ACCOUNT_ID=111111111111
,TEST_AWS_ACCESS_KEY_ID=111111111111
,TEST_AWS_REGION=us-west-1
). This PR fixes: