How to restrict S3 access to users of Active Directory - amazon-web-services

Need to create S3 bucket and few objects which are intranet facing. But users may not be having AWS access.
How to restrict S3 access to users of my companies Active Directory.

You need to do two things,
Connective Active Directory to AWS IAM
Create Roles for users to whichever the way you want it to S3
AD to IAM:
https://aws.amazon.com/blogs/security/how-to-connect-your-on-premises-active-directory-to-aws-using-ad-connector/
S3 IAM Role based Access:
https://aws.amazon.com/blogs/security/writing-iam-policies-grant-access-to-user-specific-folders-in-an-amazon-s3-bucket/
Hope it helps.

Related

I am a AWS IAM user and I have created a bucket, and I want no other IAM users to access my bucket. How can I achieve it

I am a AWS IAM user having "S3FullPermissions". I have created a bucket, and I want no other IAM users to access my buckets. How can I achieve it. Please help me with bucket policy..
S3 buckets and their objects are by default private. No one has access to them unless given explicit permissions to do so. So if you are the only one with S3 buckets permissions, no other IAM user will be able to access your buckets and objects.

AWS S3 ACL for allowing access for all users or roles, etc. in a specific account

According to the Documentation: Granting permissions to multiple accounts with added conditions it is possible to create with the entry:
Principal": {"AWS": ["arn:aws:iam::111122223333:root","arn:aws:iam::444455556666:root"]}
just access for all the users inside this account. But unfortunately it is not working. When putting single users there the access for that User from that different account is working. But with all and the root option is does not work.
But with all and the root option is does not work.
This is because the admins of these accounts also have to add permissions to IAM users/roles to access the bucket. In other words, adding arn:aws:iam::111122223333:root to a bucket policy is not enough. The individual IAM users or roles from 111122223333 also need IAM permissions to access the bucket.

AWS access to S3 bucket's folder for user groups

I understand that in AWS we can control access to AWS S3 bucket as well as to contained folders for each user by using username variable in the bucket IAM policy. I followed this blog:
Writing IAM Policies: Grant Access to User-Specific Folders in an Amazon S3 Buckete
The question is that I do not see how this can be possible also for groups. Because I want to create folders for groups rather than folders for users. According to this IAM Policy Elements: Variables and Tags I understand that there is NO variable group that I can use in the policy.
Any idea? thanks
I don't think this would be possible because an IAM User an be in multiple IAM Groups, so the name of the folder would not be predictable.
Instead, you would need to add a policy to each group that grants access to a specific bucket + path.

GCP, only list buckets where user has permissions

I am trying to figure out a way to allow a GCP user to list buckets but only those where the user has permissions (through ACL). The reason is because it can be overwhelming the number of buckets and the user experience would not be the best. Any ideas ?
Thanks!
I am trying to figure out a way to allow a GCP user to list buckets
but only those where the user has permissions (through ACL).
You cannot accomplish your goal using either Bucket ACLs or IAM permissions.
To list Google Cloud Storage buckets, you need the IAM permission storage.buckets.list.
This permission grants the IAM member account permission to list all buckets in the project. You cannot restrict this permission further to list only specific bucket names. This permission does not allow listing the objects in a bucket.
For a future design decision, you can use different projects and organize your buckets under projects. This will limit access to only IAM members of that project.
When you create a bucket you permanently define its name, location and the project it is part of. These characteristics cannot be changed later.
If you're using the CLI, you can write a script that gets the permissions for each listed bucket, and only displays it if the user account is in the permission list:
for bucket in $(gsutil ls); do
if gsutil acl get $bucket|grep -q $(gcloud config get-value account) ; then
echo $bucket;
fi;
done
Note that inherited permissions (e.g. at the project level) will not appear with this script.
This can't be accomplished with the console, but if you need a web interface listing only certain buckets, then you can build it yourself by calling the API and doing the same thing that the CLI script does.

How to restrict folders to user

Thanks for previous replies.
Is it possible to restrict the user to view particular folder in a bucket. let us take example, i have a bucket and it contains 2 folder, User A have only privilege to view first folder of the bucket, if he tries to access another folder it has to show access denied. is this possible to do in amazon S3.
You can do this using AWS Identity and Access Management (IAM). You can use this to create multiple identities and assign various permissions to those identities.
Here's a relevant example taken from the Amazon docs:
Example 1: Allow each user to have a home directory in Amazon S3
In this example, we create a policy that we'll attach to the user
named Bob. The policy gives Bob access to the following home directory
in Amazon S3: my_corporate_bucket/home/bob. Bob is allowed to access
only the specific Amazon S3 actions shown in the policy, and only with
the objects in his home directory.
{
"Statement":[{
"Effect":"Allow",
"Action":["s3:PutObject","s3:GetObject","s3:GetObjectVersion",
"s3:DeleteObject","s3:DeleteObjectVersion"],
"Resource":"arn:aws:s3:::my_corporate_bucket/home/bob/*"
}
]
}