Description
Describe the bug
Running SQS code to receive messages on my EC2 instance encountered an exception.
Expected Behavior
DNS resolution issue
I am testing DNS resolution on the EC2 instance, whether it is "nslookup sqs. us east-1. amazonaws. com" or "dig" https://sqs.us-east-1.amazonaws.com It's all normal.
i update all modules under aws-sdk-go-v2 (including indirects)
Current Behavior
The error message is as follows
https response error StatusCode: 0, RequestID: , request send failed, Post "https://sqs..amazonaws.com/": dial tcp: lookup sqs..amazonaws.com: no such host
Reproduction Steps
cfg, err := config.LoadDefaultConfig(context.Background(), config.WithRegion("us-east-1"))
sqsClient := sqs.NewFromConfig(cfg)
msgOutput, err := sqsClient.ReceiveMessage(context.Background(), &sqs.ReceiveMessageInput{
QueueUrl: ptrutil.Ptr("https://sqs.us-east-1.amazonaws.com/1111111/my-queue"),
MaxNumberOfMessages: 10,
WaitTimeSeconds: 20,
})
I have tried not specifying a region, but still encountered an error because my EC2 instance and SQS service are both in "us east-1" region
cfg, err = config.LoadDefaultConfig(context.Background())
However, if i make some changes to the code and log in and run it as SSO on the local machine without changing the version dependency, it can run normally
cfg, err := config.LoadDefaultConfig(context.Background(),config.WithSharedConfigProfile("my-profile-name"))
sqsClient := sqs.NewFromConfig(cfg)
msgOutput, err := sqsClient.ReceiveMessage(context.Background(), &sqs.ReceiveMessageInput{
QueueUrl: ptrutil.Ptr("https://sqs.us-east-1.amazonaws.com/1111111/my-queue"),
MaxNumberOfMessages: 10,
WaitTimeSeconds: 20,
})
Possible Solution
Region parsing may have issues
Additional Information/Context
No response
AWS Go SDK V2 Module Versions Used
My go version and related dependencies are as follows
go 1.20
require (
github.com/aws/aws-sdk-go-v2 v1.24.1
github.com/aws/aws-sdk-go-v2/config v1.26.6
github.com/aws/aws-sdk-go-v2/service/s3 v1.48.1
github.com/aws/aws-sdk-go-v2/service/ses v1.19.6
github.com/aws/aws-sdk-go-v2/service/sqs v1.29.7
)
require (
github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.5.4 // indirect
github.com/aws/aws-sdk-go-v2/credentials v1.16.16 // indirect
github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.14.11 // indirect
github.com/aws/aws-sdk-go-v2/internal/configsources v1.2.10 // indirect
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.5.10 // indirect
github.com/aws/aws-sdk-go-v2/internal/ini v1.7.3 // indirect
github.com/aws/aws-sdk-go-v2/internal/v4a v1.2.10 // indirect
github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.10.4 // indirect
github.com/aws/aws-sdk-go-v2/service/internal/checksum v1.2.10 // indirect
github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.10.10 // indirect
github.com/aws/aws-sdk-go-v2/service/internal/s3shared v1.16.10 // indirect
github.com/aws/aws-sdk-go-v2/service/sso v1.18.7 // indirect
github.com/aws/aws-sdk-go-v2/service/ssooidc v1.21.7 // indirect
github.com/aws/aws-sdk-go-v2/service/sts v1.26.7 // indirect
)
Compiler and Version used
go1.20.4 linux/amd64
Operating System and version
Ubuntu 22.04.3 LTS
Activity