awsdocs / aws-doc-sdk-examples

Welcome to the AWS Code Examples Repository. This repo contains code examples used in the AWS documentation, AWS SDK Developer Guides, and more. For more information, see the Readme.md file below.
Apache License 2.0
9.58k stars 5.63k forks source link

[Bug]: 位于中国大陆的用户使用 go:sdk 发生了错误:send request failed #6135

Closed PaiHL closed 8 months ago

PaiHL commented 8 months ago

Expected behavior

在本机网络使用 aws 提供的 cli 能正常访问。期望 go:sdk 能像 cli 一样正常工作。

Actual behavior


import (
    "log"

    "github.com/aws/aws-sdk-go/aws"
    "github.com/aws/aws-sdk-go/aws/credentials"
    "github.com/aws/aws-sdk-go/aws/session"
    "github.com/aws/aws-sdk-go/service/ec2"
)

func main() {
    mySession := session.Must(session.NewSession())
    svc := ec2.New(mySession,
        aws.NewConfig().
            WithCredentials(credentials.NewStaticCredentials(ak, sk, "")).
            WithRegion("us-east-1"),
    )

    resp, err := svc.DescribeInstances(&ec2.DescribeInstancesInput{})
    log.Printf("DescribeInstances resp: %+v, err: %+v", resp, err)
}

然后运行时发生了错误

aws> go run .
2024/02/20 10:07:59 DescribeInstances resp: {

}, err: RequestError: send request failed
caused by: Post "https://ec2.us-east-1.amazonaws.com/": read tcp 192.168.100.18:54712->52.46.147.69:443: wsarecv: An existing connection was forcibly closed by the remote host.

在同一台电脑的 aws 的 cli 能正常工作

PS C:\Users\dev> $Env:AWS_ACCESS_KEY_ID="xxx"
PS C:\Users\dev> $Env:AWS_SECRET_ACCESS_KEY="xxx"
PS C:\Users\dev> $Env:AWS_DEFAULT_REGION="us-east-1"
PS C:\Users\dev> aws --debug ec2 describe-instances

2024-02-20 10:09:42,489 - MainThread - awscli.clidriver - DEBUG - CLI version: aws-cli/2.15.21 Python/3.11.6 Windows/10 exe/AMD64
2024-02-20 10:09:42,489 - MainThread - awscli.clidriver - DEBUG - Arguments entered to CLI: ['--debug', 'ec2', 'describe-instances']
2024-02-20 10:09:42,548 - MainThread - botocore.hooks - DEBUG - Event building-command-table.main: calling handler <function add_s3 at 0x0000025FC9E423E0>
2024-02-20 10:09:42,548 - MainThread - botocore.hooks - DEBUG - Event building-command-table.main: calling handler <function add_ddb at 0x0000025FC9C7A2A0>
2024-02-20 10:09:42,548 - MainThread - botocore.hooks - DEBUG - Event building-command-table.main: calling handler <bound method BasicCommand.add_command of <class 'awscli.customizations.configure.configure.ConfigureCommand'>>
2024-02-20 10:09:42,548 - MainThread - botocore.hooks - DEBUG - Event building-command-table.main: calling handler <function change_name at 0x0000025FC9BF8540>
2024-02-20 10:09:42,548 - MainThread - botocore.hooks - DEBUG - Event building-command-table.main: calling handler <function change_name at 0x0000025FC9BF9BC0>
2024-02-20 10:09:42,549 - MainThread - botocore.hooks - DEBUG - Event building-command-table.main: calling handler <function alias_opsworks_cm at 0x0000025FC9E5CEA0>
2024-02-20 10:09:42,549 - MainThread - botocore.hooks - DEBUG - Event building-command-table.main: calling handler <function add_history_commands at 0x0000025FC9CC0CC0>
2024-02-20 10:09:42,549 - MainThread - botocore.hooks - DEBUG - Event building-command-table.main: calling handler <bound method BasicCommand.add_command of <class 'awscli.customizations.devcommands.CLIDevCommand'>>
2024-02-20 10:09:42,549 - MainThread - botocore.hooks - DEBUG - Event building-command-table.main: calling handler <function add_waiters at 0x0000025FC9E5CD60>
2024-02-20 10:09:42,549 - MainThread - botocore.hooks - DEBUG - Event building-command-table.main: calling handler <bound method AliasSubCommandInjector.on_building_command_table of <awscli.alias.AliasSubCommandInjector object at 0x0000025FC9F0D810>>
2024-02-20 10:09:42,549 - MainThread - botocore.loaders - DEBUG - Loading JSON file: C:\Program Files\Amazon\AWSCLIV2\awscli\data\cli.json
2024-02-20 10:09:42,550 - MainThread - botocore.hooks - DEBUG - Event top-level-args-parsed: calling handler <function resolve_types at 0x0000025FC9D7A700>
2024-02-20 10:09:42,550 - MainThread - botocore.hooks - DEBUG - Event top-level-args-parsed: calling handler <function no_sign_request at 0x0000025FC9D7AA20>
2024-02-20 10:09:42,550 - MainThread - botocore.hooks - DEBUG - Event top-level-args-parsed: calling handler <function resolve_verify_ssl at 0x0000025FC9D7A980>
2024-02-20 10:09:42,551 - MainThread - botocore.hooks - DEBUG - Event top-level-args-parsed: calling handler <function resolve_cli_read_timeout at 0x0000025FC9D7AB60>
2024-02-20 10:09:42,551 - MainThread - botocore.hooks - DEBUG - Event top-level-args-parsed: calling handler <function resolve_cli_connect_timeout at 0x0000025FC9D7AAC0>
2024-02-20 10:09:42,551 - MainThread - botocore.hooks - DEBUG - Event top-level-args-parsed: calling handler <built-in method update of dict object at 0x0000025FC9F070C0>
2024-02-20 10:09:42,551 - MainThread - awscli.clidriver - DEBUG - CLI version: aws-cli/2.15.21 Python/3.11.6 Windows/10 exe/AMD64 prompt/off
2024-02-20 10:09:42,551 - MainThread - awscli.clidriver - DEBUG - Arguments entered to CLI: ['--debug', 'ec2', 'describe-instances']
2024-02-20 10:09:42,551 - MainThread - botocore.hooks - DEBUG - Event session-initialized: calling handler <function add_timestamp_parser at 0x0000025FC9E42D40>
2024-02-20 10:09:42,551 - MainThread - botocore.hooks - DEBUG - Event session-initialized: calling handler <function register_uri_param_handler at 0x0000025FC9A42FC0>
2024-02-20 10:09:42,551 - MainThread - botocore.hooks - DEBUG - Event session-initialized: calling handler <function add_binary_formatter at 0x0000025FC9ED6660>
2024-02-20 10:09:42,551 - MainThread - botocore.hooks - DEBUG - Event session-initialized: calling handler <function no_pager_handler at 0x0000025FC98BB060>
2024-02-20 10:09:42,552 - MainThread - botocore.hooks - DEBUG - Event session-initialized: calling handler <function inject_assume_role_provider_cache at 0x0000025FC9A568E0>
2024-02-20 10:09:42,553 - MainThread - botocore.utils - DEBUG - IMDS ENDPOINT: http://169.254.169.254/
2024-02-20 10:09:42,554 - MainThread - botocore.hooks - DEBUG - Event session-initialized: calling handler <function attach_history_handler at 0x0000025FC9CA9440>
2024-02-20 10:09:42,554 - MainThread - botocore.hooks - DEBUG - Event session-initialized: calling handler <function inject_json_file_cache at 0x0000025FC9C56520>
2024-02-20 10:09:42,620 - MainThread - botocore.loaders - DEBUG - Loading JSON file: C:\Program Files\Amazon\AWSCLIV2\awscli\botocore\data\ec2\2016-11-15\service-2.json
2024-02-20 10:09:42,656 - MainThread - botocore.hooks - DEBUG - Event building-command-table.ec2: calling handler functools.partial(<function _remove_commands at 0x0000025FC9DA9D00>, commands_to_remove=['import-instance', 'import-volume'])
2024-02-20 10:09:42,657 - MainThread - awscli.customizations.removals - DEBUG - Removing operation: import-instance
2024-02-20 10:09:42,657 - MainThread - awscli.customizations.removals - DEBUG - Removing operation: import-volume
2024-02-20 10:09:42,657 - MainThread - botocore.hooks - DEBUG - Event building-command-table.ec2: calling handler <function add_waiters at 0x0000025FC9E5CD60>
2024-02-20 10:09:42,724 - MainThread - botocore.loaders - DEBUG - Loading JSON file: C:\Program Files\Amazon\AWSCLIV2\awscli\botocore\data\ec2\2016-11-15\waiters-2.json
2024-02-20 10:09:42,724 - MainThread - botocore.hooks - DEBUG - Event building-command-table.ec2: calling handler <bound method AliasSubCommandInjector.on_building_command_table of <awscli.alias.AliasSubCommandInjector object at 0x0000025FC9F0D810>>
2024-02-20 10:09:42,725 - MainThread - awscli.clidriver - DEBUG - OrderedDict([('filters', <awscli.arguments.ListArgument object at 0x0000025FCB032710>), ('instance-ids', <awscli.arguments.ListArgument object at 0x0000025FCB032810>), ('dry-run', <awscli.arguments.BooleanArgument object at 0x0000025FCB032950>), ('no-dry-run', <awscli.arguments.BooleanArgument object at 0x0000025FC9F0FB90>), ('max-results', <awscli.arguments.CLIArgument object at 0x0000025FCB032A90>), ('next-token', <awscli.arguments.CLIArgument object at 0x0000025FCB032B90>)])
2024-02-20 10:09:42,725 - MainThread - botocore.hooks - DEBUG - Event building-argument-table.ec2.describe-instances: calling handler <function add_streaming_output_arg at 0x0000025FC9E43240>
2024-02-20 10:09:42,726 - MainThread - botocore.hooks - DEBUG - Event building-argument-table.ec2.describe-instances: calling handler <function rename_arg.<locals>._rename_arg at 0x0000025FC9ED7240>
2024-02-20 10:09:42,726 - MainThread - botocore.hooks - DEBUG - Event building-argument-table.ec2.describe-instances: calling handler <function rename_arg.<locals>._rename_arg at 0x0000025FC9ED72E0>
2024-02-20 10:09:42,726 - MainThread - botocore.hooks - DEBUG - Event building-argument-table.ec2.describe-instances: calling handler functools.partial(<function pull_up_bool at 0x0000025FC9E5C5E0>, event_handler=<botocore.hooks.HierarchicalEmitter object at 0x0000025FC8435550>)
2024-02-20 10:09:42,726 - MainThread - botocore.hooks - DEBUG - Event building-argument-table.ec2.describe-instances: calling handler <function add_cli_input_json at 0x0000025FC9A57240>
2024-02-20 10:09:42,726 - MainThread - botocore.hooks - DEBUG - Event building-argument-table.ec2.describe-instances: calling handler <function add_cli_input_yaml at 0x0000025FC9A572E0>
2024-02-20 10:09:42,726 - MainThread - botocore.hooks - DEBUG - Event building-argument-table.ec2.describe-instances: calling handler <function unify_paging_params at 0x0000025FC9C7A8E0>
2024-02-20 10:09:42,791 - MainThread - botocore.loaders - DEBUG - Loading JSON file: C:\Program Files\Amazon\AWSCLIV2\awscli\botocore\data\ec2\2016-11-15\paginators-1.json
2024-02-20 10:09:42,792 - MainThread - botocore.loaders - DEBUG - Loading JSON file: C:\Program Files\Amazon\AWSCLIV2\awscli\botocore\data\ec2\2016-11-15\paginators-1.sdk-extras.json
2024-02-20 10:09:42,792 - MainThread - awscli.customizations.paginate - DEBUG - Modifying paging parameters for operation: DescribeInstances
2024-02-20 10:09:42,792 - MainThread - botocore.hooks - DEBUG - Event building-argument-table.ec2.describe-instances: calling handler <function add_generate_skeleton at 0x0000025FC9D78F40>
2024-02-20 10:09:42,793 - MainThread - botocore.hooks - DEBUG - Event before-building-argument-table-parser.ec2.describe-instances: calling handler <bound method OverrideRequiredArgsArgument.override_required_args of <awscli.customizations.cliinput.CliInputJSONArgument object at 0x0000025FCB032E50>>
2024-02-20 10:09:42,793 - MainThread - botocore.hooks - DEBUG - Event before-building-argument-table-parser.ec2.describe-instances: calling handler <bound method OverrideRequiredArgsArgument.override_required_args of <awscli.customizations.cliinput.CliInputYAMLArgument object at 0x0000025FCB033750>>
2024-02-20 10:09:42,793 - MainThread - botocore.hooks - DEBUG - Event before-building-argument-table-parser.ec2.describe-instances: calling handler <bound method GenerateCliSkeletonArgument.override_required_args of <awscli.customizations.generatecliskeleton.GenerateCliSkeletonArgument object at 0x0000025FCB066C10>>
2024-02-20 10:09:42,793 - MainThread - botocore.hooks - DEBUG - Event building-command-table.ec2_describe-instances: calling handler <function add_waiters at 0x0000025FC9E5CD60>
2024-02-20 10:09:42,793 - MainThread - botocore.hooks - DEBUG - Event building-command-table.ec2_describe-instances: calling handler <bound method AliasSubCommandInjector.on_building_command_table of <awscli.alias.AliasSubCommandInjector object at 0x0000025FC9F0D810>>
2024-02-20 10:09:42,794 - MainThread - botocore.hooks - DEBUG - Event operation-args-parsed.ec2.describe-instances: calling handler functools.partial(<function validate_boolean_mutex_groups at 0x0000025FC9E5C680>, boolean_pairs=[])
2024-02-20 10:09:42,794 - MainThread - botocore.hooks - DEBUG - Event operation-args-parsed.ec2.describe-instances: calling handler functools.partial(<function check_should_enable_pagination at 0x0000025FC9C7AA20>, ['next-token', 'max-results'], {}, OrderedDict([('filters', <awscli.arguments.ListArgument object at 0x0000025FCB032710>), ('instance-ids', <awscli.arguments.ListArgument object at 0x0000025FCB032810>), ('dry-run', <awscli.arguments.BooleanArgument object at 0x0000025FCB032950>), ('no-dry-run', <awscli.arguments.BooleanArgument object at 0x0000025FC9F0FB90>), ('max-results', <awscli.arguments.CLIArgument object at 0x0000025FCB032A90>), ('next-token', <awscli.arguments.CLIArgument object at 0x0000025FCB032B90>), ('cli-input-json', <awscli.customizations.cliinput.CliInputJSONArgument object at 0x0000025FCB032E50>), ('cli-input-yaml', <awscli.customizations.cliinput.CliInputYAMLArgument object at 0x0000025FCB033750>), ('starting-token', <awscli.customizations.paginate.PageArgument object at 0x0000025FCB006950>), ('page-size', <awscli.customizations.paginate.PageArgument object at 0x0000025FCA012450>), ('max-items', <awscli.customizations.paginate.PageArgument object at 0x0000025FCB066810>), ('generate-cli-skeleton', <awscli.customizations.generatecliskeleton.GenerateCliSkeletonArgument object at 0x0000025FCB066C10>)]))
2024-02-20 10:09:42,794 - MainThread - botocore.hooks - DEBUG - Event load-cli-arg.ec2.describe-instances.filters: calling handler <awscli.paramfile.URIArgumentHandler object at 0x0000025FC9F43710>
2024-02-20 10:09:42,794 - MainThread - botocore.hooks - DEBUG - Event load-cli-arg.ec2.describe-instances.instance-ids: calling handler <awscli.paramfile.URIArgumentHandler object at 0x0000025FC9F43710>
2024-02-20 10:09:42,794 - MainThread - botocore.hooks - DEBUG - Event load-cli-arg.ec2.describe-instances.dry-run: calling handler <awscli.paramfile.URIArgumentHandler object at 0x0000025FC9F43710>
2024-02-20 10:09:42,795 - MainThread - botocore.hooks - DEBUG - Event load-cli-arg.ec2.describe-instances.max-results: calling handler <awscli.paramfile.URIArgumentHandler object at 0x0000025FC9F43710>
2024-02-20 10:09:42,795 - MainThread - botocore.hooks - DEBUG - Event load-cli-arg.ec2.describe-instances.next-token: calling handler <awscli.paramfile.URIArgumentHandler object at 0x0000025FC9F43710>
2024-02-20 10:09:42,795 - MainThread - botocore.hooks - DEBUG - Event load-cli-arg.ec2.describe-instances.cli-input-json: calling handler <awscli.paramfile.URIArgumentHandler object at 0x0000025FC9F43710>
2024-02-20 10:09:42,795 - MainThread - botocore.hooks - DEBUG - Event load-cli-arg.ec2.describe-instances.cli-input-yaml: calling handler <awscli.paramfile.URIArgumentHandler object at 0x0000025FC9F43710>
2024-02-20 10:09:42,795 - MainThread - botocore.hooks - DEBUG - Event load-cli-arg.ec2.describe-instances.starting-token: calling handler <awscli.paramfile.URIArgumentHandler object at 0x0000025FC9F43710>
2024-02-20 10:09:42,795 - MainThread - botocore.hooks - DEBUG - Event load-cli-arg.ec2.describe-instances.page-size: calling handler <awscli.paramfile.URIArgumentHandler object at 0x0000025FC9F43710>
2024-02-20 10:09:42,795 - MainThread - botocore.hooks - DEBUG - Event load-cli-arg.ec2.describe-instances.max-items: calling handler <awscli.paramfile.URIArgumentHandler object at 0x0000025FC9F43710>
2024-02-20 10:09:42,795 - MainThread - botocore.hooks - DEBUG - Event load-cli-arg.ec2.describe-instances.generate-cli-skeleton: calling handler <awscli.paramfile.URIArgumentHandler object at 0x0000025FC9F43710>
2024-02-20 10:09:42,795 - MainThread - botocore.hooks - DEBUG - Event calling-command.ec2.describe-instances: calling handler <bound method CliInputArgument.add_to_call_parameters of <awscli.customizations.cliinput.CliInputJSONArgument object at 0x0000025FCB032E50>>
2024-02-20 10:09:42,795 - MainThread - botocore.hooks - DEBUG - Event calling-command.ec2.describe-instances: calling handler <bound method CliInputArgument.add_to_call_parameters of <awscli.customizations.cliinput.CliInputYAMLArgument object at 0x0000025FCB033750>>
2024-02-20 10:09:42,795 - MainThread - botocore.hooks - DEBUG - Event calling-command.ec2.describe-instances: calling handler <bound method GenerateCliSkeletonArgument.generate_skeleton of <awscli.customizations.generatecliskeleton.GenerateCliSkeletonArgument object at 0x0000025FCB066C10>>
2024-02-20 10:09:42,795 - MainThread - botocore.hooks - DEBUG - Event calling-command.ec2.describe-instances: calling handler functools.partial(<function check_should_enable_pagination_call_parameters at 0x0000025FC9C7AE80>, ['NextToken', 'MaxResults'])
2024-02-20 10:09:42,795 - MainThread - botocore.credentials - DEBUG - Looking for credentials via: env
2024-02-20 10:09:42,795 - MainThread - botocore.credentials - INFO - Found credentials in environment variables.
2024-02-20 10:09:42,796 - MainThread - botocore.loaders - DEBUG - Loading JSON file: C:\Program Files\Amazon\AWSCLIV2\awscli\botocore\data\endpoints.json
2024-02-20 10:09:42,804 - MainThread - botocore.hooks - DEBUG - Event choose-service-name: calling handler <function handle_service_name_alias at 0x0000025FC8F8B740>
2024-02-20 10:09:42,869 - MainThread - botocore.loaders - DEBUG - Loading JSON file: C:\Program Files\Amazon\AWSCLIV2\awscli\botocore\data\ec2\2016-11-15\endpoint-rule-set-1.json
2024-02-20 10:09:42,870 - MainThread - botocore.loaders - DEBUG - Loading JSON file: C:\Program Files\Amazon\AWSCLIV2\awscli\botocore\data\partitions.json
2024-02-20 10:09:42,876 - MainThread - botocore.hooks - DEBUG - Event creating-client-class.ec2: calling handler <function add_generate_presigned_url at 0x0000025FC86DD760>
2024-02-20 10:09:42,877 - MainThread - botocore.configprovider - DEBUG - Looking for endpoint for ec2 via: environment_service
2024-02-20 10:09:42,877 - MainThread - botocore.configprovider - DEBUG - Looking for endpoint for ec2 via: environment_global
2024-02-20 10:09:42,877 - MainThread - botocore.configprovider - DEBUG - Looking for endpoint for ec2 via: config_service
2024-02-20 10:09:42,878 - MainThread - botocore.configprovider - DEBUG - Looking for endpoint for ec2 via: config_global
2024-02-20 10:09:42,878 - MainThread - botocore.configprovider - DEBUG - No configured endpoint found.
2024-02-20 10:09:42,879 - MainThread - botocore.endpoint - DEBUG - Setting ec2 timeout as (60, 60)
2024-02-20 10:09:42,880 - MainThread - botocore.regions - DEBUG - Calling endpoint provider with parameters: {'Region': 'us-east-1', 'UseDualStack': False, 'UseFIPS': False}
2024-02-20 10:09:42,880 - MainThread - botocore.regions - DEBUG - Endpoint provider result: https://ec2.us-east-1.amazonaws.com
2024-02-20 10:09:42,881 - MainThread - botocore.hooks - DEBUG - Event provide-client-params.ec2.DescribeInstances: calling handler <function base64_decode_input_blobs at 0x0000025FC9ED6700>
2024-02-20 10:09:42,881 - MainThread - botocore.hooks - DEBUG - Event before-parameter-build.ec2.DescribeInstances: calling handler <bound method ParameterAlias.alias_parameter_in_call of <botocore.handlers.ParameterAlias object at 0x0000025FC8FB5E50>>
2024-02-20 10:09:42,881 - MainThread - botocore.hooks - DEBUG - Event before-parameter-build.ec2.DescribeInstances: calling handler <function generate_idempotent_uuid at 0x0000025FC8FADB20>
2024-02-20 10:09:42,881 - MainThread - botocore.hooks - DEBUG - Event before-call.ec2.DescribeInstances: calling handler <function inject_api_version_header_if_needed at 0x0000025FC8FAF600>
2024-02-20 10:09:42,881 - MainThread - botocore.endpoint - DEBUG - Making request for OperationModel(name=DescribeInstances) with params: {'url_path': '/', 'query_string': '', 'method': 'POST', 'headers': {'Content-Type': 'application/x-www-form-urlencoded; charset=utf-8', 'User-Agent': 'aws-cli/2.15.21 Python/3.11.6 Windows/10 exe/AMD64 prompt/off command/ec2.describe-instances'}, 'body': {'Action': 'DescribeInstances', 'Version': '2016-11-15'}, 'url': 'https://ec2.us-east-1.amazonaws.com/', 'context': {'client_region': 'us-east-1', 'client_config': <botocore.config.Config object at 0x0000025FCAA21990>, 'has_streaming_input': False, 'auth_type': None}}
2024-02-20 10:09:42,881 - MainThread - botocore.hooks - DEBUG - Event request-created.ec2.DescribeInstances: calling handler <bound method RequestSigner.handler of <botocore.signers.RequestSigner object at 0x0000025FCAFFF290>>
2024-02-20 10:09:42,881 - MainThread - botocore.hooks - DEBUG - Event choose-signer.ec2.DescribeInstances: calling handler <function set_operation_specific_signer at 0x0000025FC8FAD9E0>
2024-02-20 10:09:42,882 - MainThread - botocore.auth - DEBUG - Calculating signature using v4 auth.
2024-02-20 10:09:42,882 - MainThread - botocore.auth - DEBUG - CanonicalRequest:
POST
/

content-type:application/x-www-form-urlencoded; charset=utf-8
host:ec2.us-east-1.amazonaws.com
x-amz-date:20240220T020942Z

content-type;host;x-amz-date
6171eb09865e32b0602af0f7957e26573a51f53caaedff02ff88883cb0275885
2024-02-20 10:09:42,882 - MainThread - botocore.auth - DEBUG - StringToSign:
AWS4-HMAC-SHA256
20240220T020942Z
20240220/us-east-1/ec2/aws4_request
05fad798439634579b2f290d9833722bd6168bbde917c19d17c43537b19eaed2
2024-02-20 10:09:42,882 - MainThread - botocore.auth - DEBUG - Signature:
076a5639b6a04a80a03c898dc49e92031a856ff50f1f189608145c8a78c29b4a
2024-02-20 10:09:42,882 - MainThread - botocore.endpoint - DEBUG - Sending http request: <AWSPreparedRequest stream_output=False, method=POST, url=https://ec2.us-east-1.amazonaws.com/, headers={'Content-Type': b'application/x-www-form-urlencoded; charset=utf-8', 'User-Agent': b'aws-cli/2.15.21 Python/3.11.6 Windows/10 exe/AMD64 prompt/off command/ec2.describe-instances', 'X-Amz-Date': b'20240220T020942Z', 'Authorization': b'AWS4-HMAC-SHA256 Credential=AKIARPHHISE24R3UQZXT/20240220/us-east-1/ec2/aws4_request, SignedHeaders=content-type;host;x-amz-date, Signature=076a5639b6a04a80a03c898dc49e92031a856ff50f1f189608145c8a78c29b4a', 'Content-Length': '43'}>
2024-02-20 10:09:42,883 - MainThread - botocore.httpsession - DEBUG - Certificate path: C:\Program Files\Amazon\AWSCLIV2\awscli\botocore\cacert.pem
2024-02-20 10:09:42,883 - MainThread - urllib3.connectionpool - DEBUG - Starting new HTTPS connection (1): ec2.us-east-1.amazonaws.com:443
2024-02-20 10:09:44,624 - MainThread - urllib3.connectionpool - DEBUG - https://ec2.us-east-1.amazonaws.com:443 "POST / HTTP/1.1" 200 7764
2024-02-20 10:09:44,629 - MainThread - botocore.parsers - DEBUG - Response headers: {'x-amzn-RequestId': 'e9a715eb-6fdd-423a-9bbb-c825d909a263', 'Cache-Control': 'no-cache, no-store', 'Strict-Transport-Security': 'max-age=31536000; includeSubDomains', 'vary': 'accept-encoding', 'Content-Type': 'text/xml;charset=UTF-8', 'Content-Length': '7764', 'Date': 'Tue, 20 Feb 2024 02:09:44 GMT', 'Server': 'AmazonEC2'}
2024-02-20 10:09:44,629 - MainThread - botocore.parsers - DEBUG - Response body:
b'<?xml version="1.0" encoding="UTF-8"?>\n<DescribeInstancesResponse xmlns="http://ec2.amazonaws.com/doc/2016-11-15/">\n    <requestId>e9a715eb-6fdd-423a-9bbb-c825d909a263</requestId>\n    <reservationSet>\n        <item>\n            <reservationId>r-05158578b758a2d6c</reservationId>\n            <ownerId>101416735029</ownerId>\n            <groupSet/>\n            <instancesSet>\n                <item>\n
         <instanceId>i-08b7fbf84d9047357</instanceId>\n                    <imageId>ami-0c7217cdde317cfec</imageId>\n                    <instanceState>\n                        <code>80</code>\n
         <name>stopped</name>\n                    </instanceState>\n                    <privateDnsName>ip-172-31-85-44.ec2.internal</privateDnsName>\n                    <dnsName/>\n                    <reason>User initiated (2024-02-19 10:01:32 GMT)</reason>\n                    <amiLaunchIndex>0</amiLaunchIndex>\n                    <productCodes/>\n                    <instanceType>t2.micro</instanceType>\n                    <launchTime>2024-02-19T09:35:58.000Z</launchTime>\n                    <placement>\n                        <availabilityZone>us-east-1a</availabilityZone>\n                        <groupName/>\n                        <tenancy>default</tenancy>\n                    </placement>\n                    <monitoring>\n                        <state>disabled</state>\n                    </monitoring>\n                    <subnetId>subnet-03f665ddf3428e681</subnetId>\n                    <vpcId>vpc-044cd9537253daef2</vpcId>\n                    <privateIpAddress>172.31.85.44</privateIpAddress>\n
<sourceDestCheck>true</sourceDestCheck>\n                    <groupSet>\n                        <item>\n                            <groupId>sg-0eae671e2ceb0a51a</groupId>\n                            <groupName>launch-wizard-1</groupName>\n                        </item>\n                    </groupSet>\n                    <stateReason>\n

Steps to reproduce

1.按照如上步骤

Logs / stacktrace (if applicable)

aws> go run .
2024/02/20 10:23:42 DEBUG: Request ec2/DescribeInstances Details:
---[ REQUEST POST-SIGN ]-----------------------------
POST / HTTP/1.1
Host: ec2.us-east-1.amazonaws.com
User-Agent: aws-sdk-go/1.50.20 (go1.20.12; windows; amd64)
Content-Length: 43
Authorization: AWS4-HMAC-SHA256 Credential=AKIARPHHISE24R3UQZXT/20240220/us-east-1/ec2/aws4_request, SignedHeaders=content-length;content-type;host;x-amz-date, Signature=d53a5a0904bef432a63c22cd65f8cb9d507fe71b58172d1a321b99995559f834
Content-Type: application/x-www-form-urlencoded; charset=utf-8
X-Amz-Date: 20240220T022342Z
Accept-Encoding: gzip

-----------------------------------------------------
2024/02/20 10:23:42 DescribeInstances resp: {

}, err: RequestError: send request failed
caused by: Post "https://ec2.us-east-1.amazonaws.com/": read tcp 192.168.100.18:55455->209.54.182.97:443: wsarecv: An existing connection was forcibly closed by the remote host.

Which SDK were you using?

Go (v2)

Which OS were you using?

Windows

SDK version

1.50.20

OS version

win11

PaiHL commented 8 months ago

测试发现 ec2 服务需要设置代理访问,其余服务不需要设置代理