Giter VIP home page Giter VIP logo

Comments (5)

localstack-bot avatar localstack-bot commented on May 23, 2024

Welcome to LocalStack! Thanks for reporting your first issue and our team will be working towards fixing the issue for you or reach out for more background information. We recommend joining our Slack Community for real-time help and drop a message to LocalStack Pro Support if you are a Pro user! If you are willing to contribute towards fixing this issue, please have a look at our contributing guidelines and our contributing guide.

from localstack.

bentsku avatar bentsku commented on May 23, 2024

Hello @TheBlueSky and thanks a lot for your report!

In order to investigate this issue further, could you please start LocalStack with LS_LOG=trace, run the sample and share the logs here? We will have more informations about the region and the requests. Thank you!

from localstack.

TheBlueSky avatar TheBlueSky commented on May 23, 2024

Hi @bentsku,

I need started LocalStack without -d flag, and here is what it logged to the terminal:

2024-03-15T11:46:40.276 DEBUG --- [   asgi_gw_0] rolo.gateway.wsgi          : POST localhost:4566/
2024-03-15T11:46:40.279 DEBUG --- [   asgi_gw_0] l.aws.protocol.serializer  : No accept header given. Using request's Content-Type (application/x-www-form-urlencoded; charset=utf-8) as preferred response Content-Type.
2024-03-15T11:46:40.279  INFO --- [   asgi_gw_0] localstack.request.aws     : AWS sns.CreateTopic => 200; 000000000000/us-east-1; CreateTopicInput({'Name': 'another-test-topic'}, headers={'User-Agent': 'aws-sdk-dotnet-coreclr/3.7.301.4 ua/2.0 os/windows#10.0.19045.0 md/ARCH#X64 lang/.NET_Core#6.0.28 md/aws-sdk-dotnet-core#3.7.302.17 api/SNS#3.7.301.4 cfg/retry-mode#legacy md/ClientAsync', 'amz-sdk-invocation-id': '3878e8b1-42ad-4932-bbc8-2d40422f8120', 'amz-sdk-request': 'attempt=1; max=5', 'Host': 'localhost:4566', 'X-Amz-Date': '20240315T114638Z', 'X-Amz-Content-SHA256': '90ac42740a33d8b8b2371ba9384a4762369644160721e0df6057f02d7965dce6', 'Authorization': 'AWS4-HMAC-SHA256 Credential=test/20240315/us-east-1/sns/aws4_request, SignedHeaders=content-type;host;user-agent;x-amz-content-sha256;x-amz-date, Signature=566b7528c30387fc48ba99d10d0214cebdeb100735d12c8dde7d2743dcaa8784', 'Content-Length': '61', 'Content-Type': 'application/x-www-form-urlencoded; charset=utf-8', 'x-moto-account-id': '000000000000'}); CreateTopicResponse({'TopicArn': 'arn:aws:sns:us-east-1:000000000000:another-test-topic'}, headers={'Content-Type': 'text/xml', 'Content-Length': '340'})
2024-03-15T11:46:41.285 DEBUG --- [   asgi_gw_0] rolo.gateway.wsgi          : GET localhost.localstack.cloud:4566/_localstack/health
2024-03-15T11:46:42.363 DEBUG --- [   asgi_gw_0] rolo.gateway.wsgi          : POST localhost:4566/
2024-03-15T11:46:42.365 DEBUG --- [   asgi_gw_0] l.aws.protocol.serializer  : No accept header given. Using request's Content-Type (application/x-www-form-urlencoded; charset=utf-8) as preferred response Content-Type.
2024-03-15T11:46:42.366  INFO --- [   asgi_gw_0] localstack.request.aws     : AWS sns.Publish => 400 (InvalidParameter); 000000000000/us-east-1; PublishInput({'TopicArn': 'arn:aws:sns:eu-west-1:000000000000:one-test-topic', 'Message': 'Hello from .NET!'}, headers={'User-Agent': 'aws-sdk-dotnet-coreclr/3.7.301.4 ua/2.0 os/windows#10.0.19045.0 md/ARCH#X64 lang/.NET_Core#6.0.28 md/aws-sdk-dotnet-core#3.7.302.17 api/SNS#3.7.301.4 cfg/retry-mode#legacy md/ClientAsync', 'amz-sdk-invocation-id': 'a2ffda71-30fc-4628-88ea-38e2bda6d6ad', 'amz-sdk-request': 'attempt=1; max=5', 'Host': 'localhost:4566', 'X-Amz-Date': '20240315T114640Z', 'X-Amz-Content-SHA256': 'f6520d733a5843b386707fdb056bf40eb44beb32271240c1a814d45c39f555ab', 'Authorization': 'AWS4-HMAC-SHA256 Credential=test/20240315/us-east-1/sns/aws4_request, SignedHeaders=content-type;host;user-agent;x-amz-content-sha256;x-amz-date, Signature=417e39311133c28e5fc137178e810eda0a0ccb9020e652ae56334d9f920ca235', 'Content-Length': '133', 'Content-Type': 'application/x-www-form-urlencoded; charset=utf-8', 'x-moto-account-id': '000000000000'}); InvalidParameter(Invalid parameter: TopicArn, headers={'Content-Type': 'text/xml', 'Content-Length': '287'})

from localstack.

bentsku avatar bentsku commented on May 23, 2024

Hello @TheBlueSky, sorry for the delay on this one.

Looking at your logs, it seems your SDK is not properly setting the region here.
Here's the content of your credentials in your Authorization header: Credential=test/20240315/us-east-1/sns/aws4_request. As you can see, the region there is set to us-east-1, which is why the request is directed to that region.

I'm not exactly sure why that is, and why it works against AWS and not LocalStack? But LocalStack won't be able to target the correct region if the header sent is wrong.
Looking at our documentation for .NET SDK, it seems the way to set up the region should be a bit different:
https://docs.localstack.cloud/user-guide/integrations/sdks/dotnet/

I believe setting the region endpoint while targeting AWS will automatically set up your authentication region. But as you override the ServiceURL to another, the automated region detection might not work?

I think this is related to the AuthenticationRegion in the config.
Maybe doing the following would solve it?

var options = new AWSOptions
{
    Credentials = new BasicAWSCredentials("test", "test"),
    Region = Amazon.RegionEndpoint.EUWest1,
};
options.DefaultClientConfig.ServiceURL = "http://localhost:4566";
options.DefaultClientConfig.AuthenticationRegion = "eu-west-1";

Tell me if that does solve the issue for you? Thanks!

from localstack.

TheBlueSky avatar TheBlueSky commented on May 23, 2024

Hi @bentsku,

sorry for the delay on this one.

No worries. I appreciate the time and effort that you put into this.

Tell me if that does solve the issue for you?

Yes, setting options.DefaultClientConfig.AuthenticationRegion = "eu-west-1"; solved the issue. Thank you for that, and many thanks for the link to the .NET specific documentation... I did not know it existed๐Ÿ˜…

from localstack.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.