Cloud Vendor | Amazon AWS |
Proficiency Level | Cloud Enthusiast |
Tags | AutomationCI/CDCloudFormationS3 |
Summary
In this lab, you will create an AWS S3 Bucket using AWS CloudFormation template. You will use the AWS Management Console to upload the template and create the bucket.
Each exercise below builds upon the previous one. You should start each new exercise from the last step of the previous exercise unless it is explicitly written otherwise.
Learning Objectives
After completion of this lab, you will be able to:
- Understand AWS CloudFormation templates
- Write a CloudFormation template to create an AWS S3 Bucket
- Use the AWS Management Console to upload and deploy CloudFormation templates
Prerequisites
To complete this lab, you will need the following:
- Reliable internet connection
- AWS account used to access Amazon AWS Management Console
Exercise #1: Create an AWS CloudFormation Template
In this exercise, you will create an AWS CloudFormation Template in YAML format.
Steps
- Open a code editor and paste the following code in it
Resources: S3Bucket: Type: AWS::S3::Bucket Properties: AccessControl: PublicRead BucketName: [first_name_and_initials]-static-website MetricsConfigurations: - Id: EntireBucket WebsiteConfiguration: IndexDocument: index.html ErrorDocument: error.html RoutingRules: - RoutingRuleCondition: HttpErrorCodeReturnedEquals: '404' KeyPrefixEquals: out1/ RedirectRule: HostName: ec2-11-22-333-44.compute-1.amazonaws.com ReplaceKeyPrefixWith: report-404/ DeletionPolicy: Retain Outputs: WebsiteURL: Value: !GetAtt [S3Bucket, WebsiteURL] Description: URL for website hosted on S3 S3BucketSecureURL: Value: !Join ['', ['https://', !GetAtt [S3Bucket, DomainName]]] Description: Name of S3 bucket to hold website content
- Make the following modifications to the code
Line 6 → Replace[first_name_and_initials]
with your first name and initials - Milestone step: At this point, you have learned how to create a new AWS CloudFormation template
- Save the file in your home folder with the following name
cf-template.yaml
Exercise #2: Create a Stack Using the AWS CloudFormation Template
In this exercise, you will create an AWS CloudFormation Template in YAML format.
Steps
- Sign in to the AWS Management Console at https://aws.amazon.com/console/ using your AWS Account
- In the Find Services search box, type CloudFormation, and press Enter
- On the new page, click on the
button
- On the next screen, in the section Prerequisites – Prepare template, select the
radio button
- In the section Specify template, select the
radio button and click on the
button
- Select the
cf-template.yaml
template file from the home folder on your local machine, and click on thebutton
- On the next screen, in the section Stack name, type the following for the stack name
automationlab01-stack
- Click on the
button
- On the next screen, in the Tags section, add the following tags
Name →automationlab01-stack
Role →web
Lab →automationlab01
Owner →<your name>
OwnerEmail →<your email>
- Click on the
button
- On the next screen, review the information and click on the
button
- Wait until the deployment is complete
- Milestone step: At this point, you have learned how to create a new stack using AWS CloudFormation template and AWS Management console
- Click on the
button in the upper left corner of the AWS Management Console
- In the Find Services search box, type S3, and press Enter
- Verify that your static web site bucket is in the list of buckets
- Milestone step: At this point, you have learned how to verify the AWS CloudFormation template is successful using the AWS Management console
Last Update: November 5, 2019
You must be logged in to post a comment.