0

When I SSH into my EC2 instance - I can use aws s3 ls --profile myprofile and can see data in S3 since at that point of time - I assumed myprofile which has access to specific buckets in S3. In that very moment - I do not provide any secret and access key (just --profile myprofile).

How to achieve the same using Python? So far I've seen only by using Boto library but it ask for Secret/Access keys. Trying to avoid that but just use profile if possible (as it is possible by using aws cli).

Thanks.

Joe
  • 11,983
  • 31
  • 109
  • 183
  • aws cli stores your access key and secret key. You don't have to specify it since it is retrieved automatically when required – Ninad Gaikwad Apr 15 '19 at 15:44
  • Does Python library support - automatic grabbing of passwords? – Joe Apr 15 '19 at 17:06
  • No but you can store the credentials as environment variables to keep them safe. – Ninad Gaikwad Apr 15 '19 at 17:08
  • So how come AWS CLI can do it (just assume profile) but Python can not do it? What is so special about AWS CLI? – Joe Apr 15 '19 at 18:28
  • AWS CLI is an iterface built by AWS to do this. You can write a python program that will store and retrieve credentials from OS enviornment or a config file just like AWS does if you want. You will have to program this yourself though. – Ninad Gaikwad Apr 15 '19 at 18:54
  • When you install aws cli on your system you have to configure it with your access key and secret key. It is just saving them and fetching them later – Ninad Gaikwad Apr 15 '19 at 18:55
  • The AWS CLI is a Python program that also uses boto3. See linked answer for example of how to specify the profile with using boto3. The profile option will use credentials stored in the `~.aws/credentials` file. – John Rotenstein Apr 15 '19 at 21:09

0 Answers0