Use AWS roles instead of AWS_ACCESS_KEY_ID/AWS_SECRET_ACCESS_KEY
See original GitHub issueIf the server is compromised, the attacker can easily get AWS_ACCESS_KEY_ID
and AWS_SECRET_ACCESS_KEY
from the environment, with which they can do anything.
In stead, the AWS best practice is to create an IAM role and attach the IAM to the instance that requires the specific permissions, like for example in the default cookiecutter-django
setup, it’s the S3FullPermission
for writing the static files.
Then we can safely remove the following:
env.example: https://github.com/pydanny/cookiecutter-django/blob/master/{{cookiecutter.project_slug}}/env.example?#L18:L19
production.py: https://github.com/pydanny/cookiecutter-django/blob/master/{{cookiecutter.project_slug}}/env.example?#L18:L19
Issue Analytics
- State:
- Created 6 years ago
- Reactions:1
- Comments:8 (3 by maintainers)
Top Results From Across the Web
Extend AWS IAM roles to workloads outside of ... - Amazon AWS
AWS Identity and Access Management (IAM) has now made it easier for you to use IAM roles for your workloads that are running...
Read more >Switching to an IAM role (AWS API)
Use the AWS API to switch to an IAM role that provides temporary access to resources in an AWS account.
Read more >Using an IAM role to grant permissions to applications running ...
When you use a role, you don't have to distribute long-term credentials (such as a user name and password or access keys) to...
Read more >Switching to an IAM role (AWS CLI)
Use the AWS Command Line Interface to switch to an IAM role that provides temporary access to resources in an AWS account.
Read more >Managing access keys for IAM users - AWS Documentation
As a best practice, use temporary security credentials (IAM roles) instead of creating long-term credentials like access keys, and don't create AWS account ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@browniebroke Yes, I have used it in one of my production projects.
Happy to provide some background, according boto3 doc here, if no credentials are provided, boto3 will search for IAM role attached to the EC2 instance automatically.
I guess this really comes down to the question of IAM user V.S. IAM role. Here is an excerpt from the AWS [FAQ]:(https://aws.amazon.com/iam/faqs/)
So I think if we don’t want to give long-term credentials and just granting access to certain AWS service (like S3), IAM role is more suitable for this job. What do you think?
This will only work on AWS, though. We are currently supporting a wide range of different deployments.
Creating an IAM role and giving it only prrmissions for s3 is the better approach in this regard.