Hi Dipayan. The S3 resource in different regions needs to be allowed to be accessed in the EC2 role. Then, you will be able to access the mentioned S3 resource.
@@surojbera can you pls explain. First of all, I am trying to restrict s3 access by ec2 only to same region ie if ec2 and s3 are in same region then only ec2 can access s3 otherwise not. How can i do that
@@dipayonghosh8236 S3 is a global service. Try creating one S3 bucket in a different region than where your EC2 is there. Provide the EC2 instance a role with S3 full access. Then from within the EC2 run the command "aws s3 ls" You will be able to see your S3 bucket created in different region.
@@surojbera that is ok!! Using s3 full access policy, every ec2 (same or diff region as s3) are able to access s3. But i want to restrict access so that only those ec2s which are in same region as s3 can only access and no other. How to do that?
@@dipayonghosh8236 You can restrict that in the IAM Policy. Create the below s3full access policy and attach the same to your EC2 instance role. { "Version": "2012-10-17", "Statement": [ {
"Effect": "Allow", "Action": "s3:*", "Resource": "*", "Condition": { "StringEquals": { "aws:RequestedRegion": "us-east-1" } } } ] } Here, "us-east-1" is the region where your S3 bucket is there. Let me know if that does not work.
Thank you Suroj, your video was very thorough and easy to follow. I was able to recreate the steps in my own environment.
Glad it helped. 😊
Great simple and clear
Thank you very much for your efforts for video
Thank you Aditya for your valuable feedback. Keep learning. 🤞
Thank you very much for this vídeo! This helped me so much!!
You are always welcome. 😊 Keep learning.
thank you so much!
very good
Appreciate your valuable feedback. Keep learning. 😊
@@surojbera keep teaching
noice
Thank you. Appreciate your valuable feedback 😊
Command to print the file content ?please
Hi Biswajeet. The command is "cat filename". Ex - cat xyz.txt
How to access s3 object from ec2 in different region
Hi Dipayan. The S3 resource in different regions needs to be allowed to be accessed in the EC2 role. Then, you will be able to access the mentioned S3 resource.
@@surojbera can you pls explain. First of all, I am trying to restrict s3 access by ec2 only to same region ie if ec2 and s3 are in same region then only ec2 can access s3 otherwise not. How can i do that
@@dipayonghosh8236 S3 is a global service. Try creating one S3 bucket in a different region than where your EC2 is there. Provide the EC2 instance a role with S3 full access. Then from within the EC2 run the command "aws s3 ls" You will be able to see your S3 bucket created in different region.
@@surojbera that is ok!! Using s3 full access policy, every ec2 (same or diff region as s3) are able to access s3. But i want to restrict access so that only those ec2s which are in same region as s3 can only access and no other. How to do that?
@@dipayonghosh8236 You can restrict that in the IAM Policy. Create the below s3full access policy and attach the same to your EC2 instance role.
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": "s3:*",
"Resource": "*",
"Condition": {
"StringEquals": {
"aws:RequestedRegion": "us-east-1"
}
}
}
]
}
Here, "us-east-1" is the region where your S3 bucket is there. Let me know if that does not work.