I am having an S3 bucket which is not publicly accessible . I need to access it from my Ec2 instances which are having an IAM role attached for get/put s3 object policies.
Lets say my IAM role is - S3AccessRole, what could be the s3 bucket policy that can enable this access for all instances having that particular role.
FYI, if I enable the public access on s3 bucket, I am able to copy objects in ec2.