mardi 1 septembre 2015

How do I set permissions so an IAM can upload to an Amazon S3 bucket in C#?

I've created a user in IAM, and attached 2 managed policies: AmazonS3FullAccess and AdministratorAccess. I would like to upload files to an S3 bucket called "pscfront".

I am using the following code to do the upload:

AWSCredentials credentials = new BasicAWSCredentials(Constants.AmazonWebServices.AccessKey, Constants.AmazonWebServices.SecretKey);
            using (var client = new AmazonS3Client(credentials, RegionEndpoint.USEast1))
            {
                var loc = client.GetBucketLocation("http://ift.tt/1UpfQ0q");
                var tu = new TransferUtility(client);
                tu.Upload(filename, Constants.AmazonWebServices.BucketName, keyName);
 }

This fails with the exception "AccessDenied" (inner exception "The remote server returned an error: (403) Forbidden.") at the call to GetBucketLocation, or at the tu.Upload call if I comment that line out.

Any idea what gives?




Aucun commentaire:

Enregistrer un commentaire