cloudwatch: fix functionality of metrics for multi-accounts and region#9945
cloudwatch: fix functionality of metrics for multi-accounts and region#9945sannya-singal merged 5 commits intomasterfrom
Conversation
joe4dev
left a comment
There was a problem hiding this comment.
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 |
joe4dev
left a comment
There was a problem hiding this comment.
LGTM 👍
Thank you @sannya-singal for fixing multi-accounts for Lambda CloudWatch metrics 🥳
|
Thanks @joe4dev 🚀 🎉 |
Motivation
When using values other than
000000000000for account ID orus-east-1for region,cloudwatchtests should still create the consequent resources in these accounts and region.Changes
This PR adds
account_idparameter to thecloudwatchclient 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: