S3 bucket access on EC2 Instance using boto3
I have a flask application that needs to access some configuration files stored in s3 and I don't want to stored these in my git repo as there are sensitive information. I want to use boto3 to read in these files into the ec2 instance.
I need to know how I will be able to access those files on s3 using boto3. The ec2 instance is authorized to access the s3 bucket and since the application will be running on the ec2 (that is authorized) is it safe to say that any code run on that instance will also have these access. Note that I am going to run these script to read in these "config files" from my codedeploy "appspec.yml".
In summary will my codeploy instance be able to use the authorization on my ec2 instance to access the said s3 bucket or I need to give the codedeploy instance access too? I am aware I can add my access keys in my environment on my computer to run this script but how does it work on codedeploy?
CodeDeploy is using a service role. This service role must have read access to the S3 bucket/object (and it's KMS key, if used) as well as permission to your EC2 instance. So, in the scenario you mentioned, the credential of your EC2 role will not be used to access the S3 object.
I was able to add the needed permissions as you advised.
Relevant questions
S3 bucket access on EC2 Instance using boto3
Accepted Answerasked 2 months agoUse S3 as a git repo
asked 6 days agoAccess denied error uploading to s3 bucket
asked 7 days agoDiplay pictures stored in s3 to web page
Accepted Answerasked 3 years agoWhere can I found the uri of my Bucket to connect my Symfony application with S3 and upload files?
asked 3 months agoCan I see and move the actual content of data (Files& Folders) stored on Virtual Tape and move to S3 Storage to spin the EC2 using vmdk file
asked 6 months agoHow to set up cross-account deploymetn fromCodeCommit repo to EC2 instance in another account
asked a month agounable to access S3 log files owned by "s3-log-service"
asked 3 years agoAccess to Public S3 within private subnet in VPC without Internet
asked 3 years agoConnect my bucket as a Network Unit in Windows Explorer
asked 11 days ago
Thought as much. I will test it out and let you know.