How to Create an Access key and secret key to access the S3 Bucket?

  • Under 'Access management', click Users and then 'Create user'.

  • Specify the IAM user name (read the other instructions properly and grant permissions as desired).

  • Click 'Next'.

  • The next step involves granting permissions to the user-specified.

    • One can add this new user to the existing groups by selecting 'Add user to group' or to copy the policies from an existing user, select 'Copy permissions' options.

OR

  • You can create a custom policy with the necessary permissions to restrict access to a single Amazon S3 bucket when creating an IAM policy for an IAM user using JSON. Select 'Attach policies directly' and click 'Create policy'.

  • Select 'JSON" from the displayed options.

  • This displays the 'Policy editor window' where you can define the policy.

  • Below is an example of a JSON policy that allows read access to a single S3 bucket named "my-example-bucket" (you can modify it to fit your specific requirements).

Editable Example

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Effect": "Allow",
            "Action": [
                "s3:*",
                "s3-object-lambda:*"
            ],
            "Resource": [
                "arn:aws:s3:::your-bucket",
				"arn:aws:s3:::your-bucket/*"
            ]
        }
    ]
}

To create and attach this policy to an existing IAM user, follow these steps:

  1. Sign in to the AWS Management Console.

  2. Navigate to the IAM service.

  3. Create or select the IAM user to restrict access to.

  4. In the "Permissions" tab for the user, click "Add permissions."

  5. Choose "Attach existing policies directly."

  6. Click the "JSON" tab and paste the JSON policy into the text box.

  7. Review and click "Next: Review" to proceed.

  8. Review the permissions and the policy you attached to the user.

  9. Click "Add permissions" to attach the policy to the user.

You can modify the JSON policy to include additional actions or restrict access according to your requirements.

  • Once you have defined the permissions accordingly, click 'Next'.

  • Review the details specified and click 'Create user'.

  • Once the user is created successfully, identify and click on the name to proceed.

  • Click Security credentials, and under Access Keys, click 'Create access key'.

  • This takes you to a screen which prompts you to consider use cases and alternatives.

  • Click 'Other' (read the best practices for managing the access key).

  • Click 'Next'.

  • Specify the description tag value and click 'Create access key'.

  • This generates your Access and Secure Access keys.

  • Once the access key and the secret access keys are generated, copy and paste them to a secure location, as you can view the Secret access key only once.

  • Click 'Done' to complete the process.

Last updated