-
Notifications
You must be signed in to change notification settings - Fork 4k
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
(cfn2ts): "metric" function does not work cross account/region resources #18951
Comments
Hi @jonnekaunisto thanks for reporting this. Do you have any updates on your end as far as what you've tried or observed regarding this issue? We just received another issue that appears to be related: #24061. If these are overlapping issues then we likely want to de-duplicate them and close one for tracking purposes. |
This issue has not received a response in a while. If you want to keep this issue open, please leave a comment below and auto-close will be canceled. |
Yeah it's pretty much the same issue |
Thanks for confirming, I've closed the newer issue as a duplicate. I think this one will need to get prioritized for a deep dive to address the root problem. |
We would need to add options for which account and region you're importing the resource from. Then we'd be able to configure the metric appropriately automatically. But as it is now, we support the |
This issue has not received a response in a while. If you want to keep this issue open, please leave a comment below and auto-close will be canceled. |
I think the issue is that one would like to be able to do, e.g.: const queue = Queue.fromQueueArn(this, 'Queue', QUEUE_ARN);
queue.metricApproximateNumberOfMessagesVisible(); but has to do instead: const queue = Queue.fromQueueArn(this, 'Queue', QUEUE_ARN);
new Metric({
metricName: 'ApproximateNumberOfMessagesVisible',
namespace: 'AWS/SQS',
account: ACCOUNT_NUMBER,
dimensionsMap: { QueueName: queue.queueName },
}); even though the queue should contain/know everything already as both the region and the account are coming from |
What is the problem?
When using the metric function on an Interface of a resource in another region or account, a metric is returned with no account or region information, which means that the metric does not properly work on alarms or dashboards.
Reproduction Steps
For example when doing something like this:
What did you expect to happen?
The metric should be for the queue on the other account.
The source on dashboard should look like this ideally:
What actually happened?
If you add the following metric to your dashboard it will try to get the metric from the account that the dashboard is in instead of where the queue is.
The source on dashboard looked like this:
CDK CLI Version
1.143.0
Framework Version
1.139.0
Node.js Version
16
OS
Mac OS
Language
Typescript
Language Version
3.6.4
Other information
The way the metric function is implemented currently is by using code generation here: https://github.com/aws/aws-cdk/blob/3721358fa1501e42b3514b8a8f15f05c9615f149/tools/%40aws-cdk/cfn2ts/lib/augmentation-generator.ts
The following code is generated by that:
I believe changing it to this would fix it:
The text was updated successfully, but these errors were encountered: