Hey Fellas, I was working with a backup script today on AWS and there it had a step where an artifact is to be backed up to AWS S3 service. On copying, I started receiving the error below:
upload failed: <source_file> to s3://<bucket>/<key> Connection was closed before we received a valid response from endpoint URL: "<s3 bucket public url>/<object key name>".
If you have also got into this problem then please be with me. I started looking into a lot of things and realized that the IAM role which had the policy attached was missing a single clause in the Resource definition.
I missed specifying the recursive objects on the bucket. Effectively this is achieved by appending /* to the bucket name in the resource section of the policy. Look at the resource definition below:
"Resource": "arn:aws:s3:::<bucket-name>/*"
There you are. It is the right was to specify permissions for an IAM role or the S3 Bucket Policy.
Good Luck using AWS CLI.
