Complete AWS IAM Reference
Writing IAM policies is hard. Following the principle of least privilege is even harder. To write a secure IAM policy you need to know:
- What actions are needed?
- Are resource-level permissions supported and on what levels?
- Are conditions supported to restrict access?
That’s a lot of stuff and the information is spread all across the AWS documentation.
Example
For example, you want to allow the launch of new EC2 instances.
First you need to find out what action is needed. You can use the Complete AWS IAM Reference to search for launch in the description field. Now you know, that the action is called ec2:RunInstances
.
{ |
Now you can restrict access further. What options do you have? The Complete AWS IAM Reference shows you that you can use many resource-level permissions. For example, you can restrict that it is only allowed to use a certain AMI like Amazon Linux 2016.03.3 (64bit, gp2).
{ |
You can take it even further. The Complete AWS IAM Reference shows that you can use a condition to restrict based on instance type. To save money in your dev account you may only allow t2.micro
instances.
{ |
Keep in mind that different resource-level permissions support different service specific conditions. That’s why the following policy is not working:
{ |
Summary
For every AWS service, different actions are available. Depending on the action you can use resource-level permissions and sometimes also conditions.
Further reading
- Article Your AWS Account is a mess? Learn how to fix it!
- Article The Life of a Serverless Microservice on AWS
- Article 5 AWS mistakes you should avoid
- Article Event Driven Security Automation on AWS
- Article Introducing the Object Store: S3
- Tag security
- Tag iam