简体   繁体   中英

Accessing S3 bucket from a script using IAM Role

We are trying to upload and display a file to and from S3 bucket through our .Net Script.

We are currently using the user's access key and secret key in our code, Which is a bad practice.

Could anyone let me if there is a way that we can use roles in the pace of these keys directly? If there is then how ?

If you run your application in EC2, try to attach the role to EC2 directly.

If you are run on your local server, try to save your credentials on your server by using aws configure command

As you're going to run this on EC2 the answer is yes you can attach an IAM role to an EC2 host.

This is indeed the best practice for running your scripts on your EC2 host. Once attached the EC2 your script will have access to all permissions that your EC2 has as long as you do not provide an IAM key/secret in the credentials of the SDK or have any of the environment variables set as these will override the IAM role.

More information is available in the IAM roles for Amazon EC2 documentation.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM