- Lab
- A Cloud Guru
Preventing Deletion of an Amazon S3 Bucket Using a Resource-Based Policy
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.
Path Info
Table of Contents
-
Challenge
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.
-
Challenge
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.
-
Challenge
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.)
What's a lab?
Hands-on Labs are real environments created by industry experts to help you learn. These environments help you gain knowledge and experience, practice without compromising your system, test without risk, destroy without fear, and let you learn from your mistakes. Hands-on Labs: practice your skills before delivering in the real world.
Provided environment for hands-on practice
We will provide the credentials and environment necessary for you to practice right within your browser.
Guided walkthrough
Follow along with the author’s guided walkthrough and build something new in your provided environment!
Did you know?
On average, you retain 75% more of your learning if you get time for practice.