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.68k stars 651 forks source link

Unable to use apigatewaymanagementapi using sdk v2 1.19.11 #2687

Closed zxl199409 closed 5 months ago

zxl199409 commented 5 months ago

Acknowledgements

Describe the bug

InvalidSignatureException: Credential should be scoped to correct service: 'execute-api'.

Expected Behavior

I don’t know why it is incompatible after the upgrade

Current Behavior

impact test

Reproduction Steps

1

Possible Solution

No response

Additional Information/Context

func init() {
    cfg, err := config.LoadDefaultConfig(context.Background())
    if err != nil {
        return
    }

    pushClient = apigatewaymanagementapi.NewFromConfig(cfg, func(o *apigatewaymanagementapi.Options) {
        o.EndpointResolver = apigatewaymanagementapi.EndpointResolverFromURL(imConfig.EnvVar.ApiGatewayEndpoint)
        o.HTTPClient = &http.Client{Transport: service.DefaultHTTPTransport()}
    })
}

    _, err := pushClient.PostToConnection(ctx, &apigatewaymanagementapi.PostToConnectionInput{
        ConnectionId: &connectionId,
        Data:         data,
    })

error!!! PostToConnection error: operation error ApiGatewayManagementApi: PostToConnection, https response error StatusCode: 403, RequestID: 5192a476-9b9c-46f4-8e1d-aed5e7492917, api error InvalidSignatureException: Credential should be scoped to correct service: 'execute-api'.

AWS Go SDK V2 Module Versions Used

github.com/aws/aws-sdk-go-v2/service/apigatewaymanagementapi v1.19.11

Compiler and Version used

go 1.19

Operating System and version

arm64

RanVaknin commented 5 months ago

Hi @zxl199409,

You mentioned "incompatible after the upgrade" does downgrading the SDK version resolve this issue for you?

Additionally, It's hard to tell what might be going wrong since you are providing your own custom HTTP transport and your own endpoint resolver. Can you share these configurations with us?

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.

timvlaer commented 1 month ago

I saw the exact same issue using github.com/aws/aws-sdk-go-v2/service/apigatewaymanagementapi 1.23.2 I see the same issue on 1.18.1 and 1.16.5. Didn't try 1.17.x yet.

My original version was 1.10.15, but when I rollback to that version I get not found, ResolveEndpointV2 so I am expecting another depency (github.com/aws/aws-sdk-go-v2 or github.com/aws/aws-sdk-go-v2/config) is the culprit.

timvlaer commented 1 month ago

I brought everything back to v1.16.14 which fixed the issue 😅 I came here because I wanted to add the kinesis service dependency and triggered me to update everything. I also put the kinesis dependency to the version related to 1.16.14.

This may help: if you select the version tag in github, you can check the go_module_metadata.go in the services you need to see the corresponding versions of that release. Because the versions of the main project, services and config are not the same. I ended up with:

    github.com/aws/aws-sdk-go-v2 v1.16.14
    github.com/aws/aws-sdk-go-v2/config v1.17.5
    github.com/aws/aws-sdk-go-v2/service/apigatewaymanagementapi v1.10.15
    github.com/aws/aws-sdk-go-v2/service/eventbridge v1.16.12
    github.com/aws/aws-sdk-go-v2/service/kinesis v1.15.17

This version is ancient ([2022-09-02]) so I'd love to go to a more recent version. Also, I don't know which exact version caused this issue.

Happy to upgrade and try this out if we have a better understanding of the issue.

The versions I tried first, the latest and greatest, but that kept failing with the InvalidSignatureException

github.com/aws/aws-sdk-go-v2 v1.32.2
github.com/aws/aws-sdk-go-v2/config v1.28.0
github.com/aws/aws-sdk-go-v2/service/apigatewaymanagementapi v1.23.2
github.com/aws/aws-sdk-go-v2/service/eventbridge v1.35.2
github.com/aws/aws-sdk-go-v2/service/kinesis v1.32.2

Scherm­afbeelding 2024-10-27 om 00 35 59