In this hands-on lab, you are a software engineer working for a new startup that is launching an online bookstore for rare and antique books. The founder, Kia, needs your help with protecting her data. Since her technical lead is out sick, she’s calling on you for assistance. In order to protect the book data stored in S3, you will use a resource-based policy in AWS Identity & Access Management (IAM) to prevent an Amazon S3 bucket from being deleted.
Learning Objectives
Successfully complete this lab by achieving the following learning objectives:
- Use the AWS Policy Generator to Generate a Resource Policy
- Navigate to AWS Policy Generator.
- Set the following values:
- Select Type of Policy: S3 Bucket Policy
- Effect: Deny
- Principal: *
- AWS Service: Amazon S3
- Actions: DeleteBucket
- Amazon Resource Name (ARN): *
- Click Add Statement.
- Click Generate Policy.
- Copy the newly generated policy JSON document to the clipboard.
- Set the following values:
- Navigate to AWS Policy Generator.
- Attach a Resource Policy to an S3 Bucket
- Navigate back to the AWS Management Console.
- Navigate to S3.
- There should be an existing bucket. Click on the bucket name.
- Click the Permissions tab.
- Scroll down to the Bucket policy section and click Edit.
- Paste the previously generated policy in the Policy section.
- Copy the Bucket ARN number.
- In the bucket policy, locate
"Resource"
in line 11 and replace*
with the copied Bucket ARN number. - Click Save changes.
- Test the Resource Policy
- Navigate back to S3.
- Click on the bucket name.
- Click Delete.
- In the Delete bucket section, copy the bucket name and paste it in the confirm deletion field.
- Click Delete bucket. (NOTE: You will encounter a permission denied message.)
- Click Create bucket.
- Set a Bucket name as "mytestforacg".
- Click Create bucket.
- Select the newly created bucket
mytestforacg
and click Delete. - In the Delete bucket section enter the bucket name,
mytestforacg
and click Delete Bucket. (NOTE: This bucket should be successfully deleted.)