When you create an AWS account with an user name, that user is called Root user, this user is the super user and has access to all resources on AWS, so it is very important to keep this account safe and secure and not share with any other users for accessing AWS.

Secure

It is important to keep your AWS accounts safe and secure as these accounts will have access to AWS resources. Below are some best practices to keep the accounts safe and secure.

Do not use root account for creating resources on AWS, instead create separate AWS user accounts and assign previleges as required.
User Groups

User Groups are a way of organizing different users who needs different level of access permissions based on job duties or role in the company. You can create different user groups to meet these needs like admin group, developers group, devops group or support group etc.

For example, say if there are two different teams in your oraganization Developers and DevOps, then you would typically create two user groups, Developers team who requires access to all development and debugging tools etc. and DevOps group may need different set of access permissions.

An user can belong to more than one group, in the below example David belongs to developers group, but also does DevOps work, in this case you can add David to both groups.

IAM users and groups example

You can also Create User Groups using AWS CLI and Create User Groups using AWS SDK.

User Accounts

In order to access AWS resources for different use cases like development, deployment, support or accessing an API/SDK, it is always a best practice to create user accounts for each of the users who needs access.

You can also Create Users using AWS CLI and Create Users using AWS SDK (Java).

IAM Policies

An IAM Policy is a fine granular level definition where you define access permissions to an AWS resource, think of it as a placeholder where you actually define the access permissions and assign these policies to individual users, users group, systems or other AWS services. IAM Policy definition is a JSON document that describes the access permissions to AWS resources, within one IAM policy JSON document you can define access permissions to more than one AWS resource.

For example, you can define who can access an EC2 resource, read access or write access including further granular level access like you may want to give all write access except detaching a volume. All this is possible through IAM Policies.

There are several AWS managed IAM Policies that are already built by AWS that we can simply pick and choose based on the need. These AWS managed policies comes handy when you are going to start from scratch, below is an example of AWS managed policy, AmazonEC2FullAccess it has all the access privileges pre-defined for EC2 resource full access. AWS Managed Policies

Note: Please note that AWS managed policies are not editable, if you are going to use AWS managed policies and in case if AWS changed these policies or accidentally added or removed underlying permissions (which may not be the case) you may get affected. So, consider this point when using AWS managed policies, you can also clone a managed policy and make additional changes as per your need.

You can also create your own Policies and assign access permissions, below steps outlines how to create a new IAM Policy.

Creating your own new policy using AWS Console
Cloning an AWS managed policy

For complete reference of the JSON elements, please refer to this link https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_elements.html

{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": "ec2:*", "Resource": "*" }, { "Effect": "Allow", "Action": "cloudwatch:*", "Resource": "*" }, { "Effect": "Allow", "Action": "autoscaling:*", "Resource": "*" } ] }

You can also Create IAM Policy using AWS CLI and Create IAM Policy using AWS SDK.

Note: If an user or service has access permissions coming from different policies assigned, and for an AWS resource (for example Database access) if there is 'Allow' permission in one policy and 'Deny' in another policy, then the resultant will become 'Deny'.
IAM Roles

IAM role is an identity that you can create in your account and provide access permissions to AWS Services, other AWS accounts and third party applications such as OpenID providers or your own organization SAML provider.

IAM create role

You can also Create IAM Role using AWS CLI and Create IAM Role using AWS SDK.

Access Analyzer

Access Analyzer is a tool available under IAM which helps in analyzing access permissions to AWS resource within an AWS Region.

While IAM service is a Global service, but Access Analyzer is bound a specific AWS region, so if you are planning to use this tool, then you need to create one per AWS Region.

In order to create Access Analyzer report, go to IAM console and choose the option Access Analyzer under Access reports and click on 'Create analyzer'

IAM create access analyzer

In the next step, give a name to the access analyzer report and create analyzer.

IAM create access analyzer