Use input parameters to be able to re-use CloudFormation templates.
- Create a CloudFormation template using build-in functions
Fn::Base64
andFn::Sub
. - Create a CloudFormation stack based on your template.
- Open
stub.yaml
with an editor of your choice. The stub file contains a skeleton to start from. - Use functions
Fn::Base64
andFn::Sub
to combine the following Bash script and inject it into the EC2 instance with the help ofUserData
. $URL needs to be replaced with the template parameter namedURL
(see Build-in functions).
Bash script installing httpd-tools and running a small HTTP load test.
#!/bin/bash -ex
yum install -y httpd-tools
ab -n 1000 -c 4 $URL
- Open CloudFormation in AWS Management Console.
- Click Create Stack button.
- Select Upload a template to Amazon S3.
- Choose the template file you created for this lab.
- Click Next button.
- Insert
lab3-$username
as stack name. Replace$username
with your username (e.g. lab3-awittig). - Select a random subnet as parameter for Subnet.
- Insert
t2.micro
as parameter for InstanceType. - Insert
ami-bff32ccc
(eu-west-1) orami-bc5b48d0
(eu-central-1) as parameter for AMI. - Insert
http://widdix.net/
or a website you own for URL. - Click Next button.
- Skip next step by clicking on Next button.
- Review your input and click Create button.
- Wait until your stack reaches status CREATE_COMPLETE.
- Select your stack by clicking on row of the table.
- Select Delete Stack from the Actions menu.
- Confirm the deletion of your stack.
- Congratulations! You are done with the lab!
This lab includes a sample solution sample-solution.yaml
. Use it if you are stuck during the creation of your template of if you want to review your results.