aws / aws-sdk-go-v2

AWS SDK for the Go programming language.
https://aws.github.io/aws-sdk-go-v2/docs/
Apache License 2.0
2.67k stars 642 forks source link

Add cloudwatch.PutMetricAlarmInput possibility to choose region #2650

Closed Redeltaz closed 5 months ago

Redeltaz commented 5 months ago

Describe the feature

Add the possibility, when creating a new alarm with cloudwatch.PutMetricAlarmInput, to add the region where you want this alarm to be created in.

Use Case

This idea mainly come from a problem that I encounter on the Terraform Provider for AWS, more specifically this issue where I discover that when all your work is in a specific region, but you want to create a cloudwatch alarm for billing for example, which is possible only in us-east-1 region, you just can't or you're forced to try specifics tricks to resolve a problem that can be simply solved by adding a parameter

Proposed Solution

While creating a new Cloudwatch alarm with the c.PutMetricAlarm, the function need a cloudwatch.PutMetricAlarmInput input params wich has multiple fields like AlarmName, AlarmDescription... I think it's here where we will need to add a Region parameter. I try to understand how the requests work after that, but I don't know for the moment if the call to the API when you add Region is simple or if there is other stuffs to update too.

Other Information

I also discover that this problem also affect other resources like lambda or other resources wich take the region selected by default on the console when created manually. So I don't know if a feature like that is doable, or if it's just impossible because of the way AWS is built.

Acknowledgements

AWS Go SDK V2 Module Versions Used

v1.27.15

Go version used

go 1.22.2

RanVaknin commented 5 months ago

Hi @Redeltaz ,

This is not possible for a few reasons:

  1. The AWS SDKs are all code-generated from the API models of each service. In this case, the Cloudwatch API team is the only one that can make changes to the API model to introduce new parameters, this is not actionable by the SDK team.

  2. The way the AWS server determines which region a resource will be created in is based on which AWS partition the request is being sent to. The SDK client is initialized in a specific region, and the SDKs routing rules will build the request URL based on the region provided in the client's config. Even if a service team has provided a parameter, there wouldn't be an API-operation-specific way to override the endpoint rules that the SDK client currently uses to build requests.

Even though Terraform folks interact with us regularly, I'm not super familiar with Terraform provider as a product (since AWS has its own product, CDK, that we use instead), but since its based on the Go SDK and based on what I've read on #28971, the correct, and only way is to create a provider for each region you are using.

Thanks, Ran~

github-actions[bot] commented 5 months ago

This issue is now closed. Comments on closed issues are hard for our team to see. If you need more assistance, please open a new issue that references this one.