Are you Struggling to Access your AWS S3 bucket, if yes then this tutorial is for you.
In this quick tutorial you will learn how you can grant read-write access to an Amazon S3 bucket by assigning S3 policy to the role.
Lets get started.
Prerequsites
- AWS account
- One AWS Bucket named sagarbucket2023
Creating IAM S3 Policy
The below policy is useful when you want any of your application intending to use the AWS S3 bucket may be for reading the data from a website or storing the data i.e. writing it to AWS S3 bucket.
The below policy contains following attributes
- Version is Policy version which is fixed.
- Effect is Allow in each statement as we want to allow users or group be able to work with AWS S3.
- Actions: We have different actions such as ListAllbuckets to list the buckets etc.
- Resource is my AWS S3 bucket named sagarbucket2023
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"s3:GetBucketLocation",
"s3:ListAllMyBuckets"
],
"Resource": "*"
},
{
"Effect": "Allow",
"Action": ["s3:ListBucket"],
"Resource": ["arn:aws:s3:::sagarbucket2023"]
},
{
"Effect": "Allow",
"Action": [
"s3:PutObject",
"s3:GetObject",
"s3:DeleteObject"
],
"Resource": ["arn:aws:s3:::sagarbucket2023/*"]
}
]
}
Conclusion
This tutorial demonstrated that if you need to read or write data in AWS S3 bucket then your policy either attached to IAM user or IAM role should be defined as we showed.