amazon-ssm-agent icon indicating copy to clipboard operation
amazon-ssm-agent copied to clipboard

S3 Endpoint : Error when querying S3 bucket

Open Menahem1 opened this issue 8 years ago • 4 comments

Hello,

When i use a Endpoint to S3, the process is taking (timeouting / slow-down) 5mn to find the bucket for log (output S3 bucket) Example of error:

2018-03-23 14:56:40 INFO [ssm-document-worker] [21d1413d-0448-48d4-9415-a31955e4e003] [DataBackend] [pluginName=aws:runShellScript] Error when querying S3 bucket using address http://bucket-log.s3.eu-central-1.amazonaws.com. Error details: Failed to fetch region from the header - %!s(<nil>). Retrying with the generic regional endpoint s3.amazonaws.com... 
2018-03-23 14:57:51 INFO [instanceID=i-015a8c2253d14d707] [MessagingDeliveryService] [Association] Schedule manager refreshed with 0 associations, 0 new assocations associated 
2018-03-23 14:59:10 INFO [ssm-document-worker] [21d1413d-0448-48d4-9415-a31955e4e003] [DataBackend] [pluginName=aws:runShellScript] Error when querying S3 bucket using address http://bucket-log.s3.amazonaws.com. Error details: Failed to fetch region from the header - %!s(<nil>) 

After that the process continue normally (and is working but withslow-down) , when i don't use an Endpoint and use an Internet Gateway it's working immediately. Do you know why ? Maybe a bug in SSM for finding quickly the Output S3 Bucket ?

Agent: amazon-ssm-agent - v2.2.392.0

Thanks

Menahem1 avatar Mar 28 '18 14:03 Menahem1

Hi @Menahem1 , Thank you for posting here. Could you please provide repro steps for this issue?

AmyZhangAmz avatar Apr 04 '18 21:04 AmyZhangAmz

Hi @AmyZhangAmz After discusion with AWS Support, the problem was on Security Group that need to allow in outbound port 80 to the Endpoint (with of course 443). curious to know why the agent can not start in 443 directly

Menahem1 avatar Apr 05 '18 10:04 Menahem1

Hello,

I'm using version 2.2.325.0 and also got that error when the instance is not in the same region as the S3 bucket. But I don't get this error consistently, it occurs randomly. I have HTTP (port 80) OutBound open without limitations.

It seems that SSM agent is failing to get the region from the x-amz-bucket-region header. Output log below:

2018-04-05 11:39:34 INFO [ssm-document-worker] [ef8008be-527f-4bf5-8ae2-06da0e94b796] [DataBackend] [pluginName=aws:runPowerShellScript] Error when querying S3 bucket using address http://bucketname.s3.eu-west-2.amazonaws.com. Error details: Failed to fetch region from the header - %!s(<nil>). Retrying with the generic regional endpoint s3.amazonaws.com...
2018-04-05 11:39:42 INFO [ssm-document-worker] [ef8008be-527f-4bf5-8ae2-06da0e94b796] [DataBackend] [pluginName=aws:runPowerShellScript] Error when querying S3 bucket using address http://bucketname.s3.amazonaws.com. Error details: Failed to fetch region from the header - %!s(<nil>)
2018-04-05 11:39:42 INFO [instanceID=i-000000000000] [MessagingDeliveryService] [EngineProcessor] sending reply for plugin update: aws:runPowerShellScript
2018-04-05 11:39:42 INFO [ssm-document-worker] [ef8008be-527f-4bf5-8ae2-06da0e94b796] [DataBackend] [pluginName=aws:runPowerShellScript] Uploading C:\ProgramData\Amazon\SSM\InstanceData\i-0000000000000\document\orchestration\ef8008be-527f-4bf5-8ae2-06da0e94b796\awsrunPowerShellScript\0.awsrunPowerShellScript\stdout to s3://bucketname/hostname/Request55660/ef8008be-527f-4bf5-8ae2-06da0e94b796/i-0000000000/awsrunPowerShellScript/0.awsrunPowerShellScript/stdout
2018-04-05 11:39:42 ERROR [ssm-document-worker] [ef8008be-527f-4bf5-8ae2-06da0e94b796] [DataBackend] [pluginName=aws:runPowerShellScript] Failed uploading C:\ProgramData\Amazon\SSM\InstanceData\i-0000000000\document\orchestration\ef8008be-527f-4bf5-8ae2-06da0e94b796\awsrunPowerShellScript\0.awsrunPowerShellScript\stdout to s3://bucketname/hostname/Request55660/ef8008be-527f-4bf5-8ae2-06da0e94b796/i-0000000000/awsrunPowerShellScript/0.awsrunPowerShellScript/stdout err:BucketRegionError: incorrect region, the bucket is not in 'eu-west-2' region
	status code: 301, request id: , host id: 

Any thoughts?

Thanks

Cheers

migueljoao avatar Apr 05 '18 14:04 migueljoao

Hi @migueljoao, I'm going to close this issue as a lot of time has pass. Many agent versions have been released since the last comment date. Feel free to open up another issue if you are still running into issues. Thanks!

hiimtu avatar Jul 02 '19 22:07 hiimtu