[Django]-Use Django-Storages with IAM Instance Profiles

9👍

You simply omit these parameters from your settings.

The Django-Storages documentation now explains this:

If AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY are not set, boto3 internally looks up IAM credentials.

The way this works under the hood is that if you do not provide them, Django-Storages passes None to boto3, which uses the machine’s privileges instead of a key pair. If the machine has an associated Instance Profile, this is what gets used. (See the boto3 docs for more on boto3’s credential hierarchy)


Thanks to @ChrisShenton for pointing out that the Django-Storages docs had been updated. The Django-Storages docs previously listed these configuration parameters as required, which was incorrect.

👤Zags

1👍

The docs now explain this:

If AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY are not set, boto3 internally looks up IAM credentials.

Leave a comment