IAM Dev User
To create a new IAM user called “awsdev” with full EC2 and AWS Secrets Manager access using the AWS Management Console, follow these steps:
- Open the IAM console: https://console.aws.amazon.com/iam/
- In the navigation pane, click on “Users”.
- Click on “Add user”.
- Enter the user name as “awsdev”.
- Select “Programmatic access” and “AWS Management Console access” for the access type.
- Set a custom password or choose to auto-generate a password.
- Uncheck the “Require password reset” option if you don’t want to enforce a password change on the first login.
- Click on “Next: Permissions”.
- Click on “Attach existing policies directly”.
- In the search box, enter “EC2FullAccess” and select the “AmazonEC2FullAccess” policy.
- In the search box, enter “SecretsManagerFullAccess” and select the “SecretsManagerReadWrite” policy.
- Click on “Next: Tags”.
- Add any tags for the user if needed (Optional).
- Click on “Next: Review”.
- Review the user details and click on “Create user”.
- On the success screen, you will see the user’s access key ID and secret access key. Make sure to download or copy the credentials securely, as you won’t be able to access the secret access key again.
- Click on “Close”.
The “awsdev” IAM user will now be created with full access to EC2 and AWS Secrets Manager.
Custom IAM Policy
Alternatively, if you want to create a custom IAM policy for the user, you can follow these steps:
- Open the IAM console: https://console.aws.amazon.com/iam/
- In the navigation pane, click on “Policies”.
- Click on “Create Policy”.
- Select the “JSON” tab and paste the following JSON policy into the editor:
- Click on “Review policy”.
- Give the policy a name (e.g., “IAMDevUserPolicy”) and an optional description.
- Click on “Create policy”.
- Follow the steps from the previous list (steps 1-17) to create the “awsdev” IAM user, but in step 10, instead of selecting the “AmazonEC2FullAccess” and “SecretsManagerReadWrite” policies, search for and select the custom policy you just created (e.g., “IAMDevUserPolicy”).
The “awsdev” IAM user will now be created with the custom policy attached, granting full access to EC2 and AWS Secrets Manager.
Pre-defined vs Custom IAM Policy
The custom IAM policy allows for more precise control over the permissions granted to the user, adhering to the principle of least privilege. On the other hand, using pre-defined AWS managed policies may include additional permissions that may not be necessary for the user’s specific tasks.