How do I define the principal for an AWS policy statement

0 votes

I started from http://awspolicygen.s3.amazonaws.com/policygen.html in order to create a policy that will grant upload rights to a specific S3 bucket for a list of users.
I'm not clear on how I define who those users should be.

The docs refer to a principal as "a person or persons" without an example of how to refer to said person(s). One assumes "email address" and the policy generator will accept it, but when I paste the generated statement to the bucket policy editor, I get:

Invalid principal in policy - "AWS" : "geek@here.com"

Full statement:

{
  "Id": "myPol",
  "Statement": [
    {
      "Sid": "Stmt130",
      "Action": "s3:*",
      "Effect": "Allow",
      "Resource": "arn:aws:s3:::myBucketName",
      "Principal": {
        "AWS": [
          "steve@here.com"
        ]
      }
    } ]
}
Jun 26, 2018 in AWS by Flying geek
• 3,280 points

edited Jun 26, 2018 by Flying geek 883 views

2 answers to this question.

0 votes
Please help me in this  ASAP, anyone?
answered Jun 26, 2018 by Flying geek
• 3,280 points
0 votes

Check with AWS Policy Documentations once, rest you can try this code if it doesn't work then feel free to reach me, cheers:  

Code:

[HttpPost]
public ActionResult Uploaddemo(HttpPostedFileBase file) {
    try {
        IAmazonS3 client;
        using (client = Amazon.AWSClientFactory.CreateAmazonS3Client(_awsAccessKey, _awsSecretKey,RegionEndpoint.USWest2)) {
            var request = new PutObjectRequest() {
                BucketName = _bucketName,
                CannedACL = S3CannedACL.PublicRead, ACCESIBLE
                Key = string.Format("visumes/{0}", file.FileName),
                InputStream = file.InputStream,//SEND THE FILE STREAM
            };

            Amazon.S3.AmazonS3Config s3Config = new Amazon.S3.AmazonS3Config() { 
                ServiceURL = "http://s3.amazonaws.com"  
            };
            string HOST ="http://s3-website-us-west-2.amazonaws.com";
            client.PutObject(request);
        }
    } catch (Exception ex) {

    }
    return View();
}
answered Jun 26, 2018 by Cloud gunner
• 4,670 points

edited Jun 26, 2018 by Cloud gunner

Related Questions In AWS

0 votes
1 answer
0 votes
2 answers

How do I add python libraries to an AWS lambda function for Alexa?

If you get lucky (it depends what ...READ MORE

answered Nov 3, 2020 in AWS by anonymous
15,141 views
0 votes
1 answer

How do I create an alarm for my load balancer using the Amazon EC2 console?

Follow these steps: Open the Amazon EC2 console On ...READ MORE

answered May 17, 2019 in AWS by Rhea
1,345 views
+1 vote
2 answers

AWS CloudWatch Logs in Docker

The awslogs works without using ECS. you need to configure ...READ MORE

answered Sep 7, 2018 in AWS by bug_seeker
• 15,520 points
1,738 views
+2 votes
1 answer

Deploy Docker Containers from Docker Cloud

To solve this problem, I followed advice ...READ MORE

answered Sep 3, 2018 in AWS by Priyaj
• 58,090 points
2,469 views
+1 vote
4 answers

How do I cache my images which are stored in Amazon S3?

when caching ec2 instance these can be ...READ MORE

answered Oct 23, 2018 in AWS by Nabarupa
8,475 views
0 votes
1 answer

AWS Cloudtrail API for Go SDK showing an error mesage.

You  must add S3 Policy in your ...READ MORE

answered Jun 27, 2018 in AWS by Flying geek
• 3,280 points
1,018 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP