Skip to content

Commit f1c334f

Browse files
committed
Finish workshop outline
1 parent 45d19ea commit f1c334f

File tree

1 file changed

+102
-3
lines changed

1 file changed

+102
-3
lines changed

README.md

Lines changed: 102 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,8 @@ lot of time can be spent on building tools to assist with the automation (ie. wr
5858

5959
Examples:
6060

61-
- Logging into the AWS console and manually provisioning servers.
62-
- SSH into each server to apply system upgrades.
61+
- Logging into the AWS console and manually provisioning servers.
62+
- SSH into each server to apply system upgrades.
6363

6464
We could save some time by writing some scripts and it'll get the job done and this will generally work fine at a small scale.
6565

@@ -434,20 +434,119 @@ templates supports.
434434

435435
> Parameters enable you to input custom values to your template each time you create or update a stack.
436436

437+
Why are parameters useful? It allows us to reuse templates across different
438+
environments, as we can pass in parameters to specify customizations.
439+
440+
`Parameters` is a top level key, where it maps a parameter name to a parameter
441+
object.
442+
443+
**Here's an example:**
444+
445+
```json
446+
{
447+
"AWSTemplateFormatVersion": "2010-09-09",
448+
"Description": "Workshop stack.",
449+
"Parameters": {
450+
"Project": {
451+
"Type": "String",
452+
"Description": "This is a string!",
453+
"Default": "my_project_name"
454+
},
455+
"SecurityGroups": {
456+
"Type": "List<AWS::EC2::SecurityGroup::Id>",
457+
"Description": "Security groups",
458+
"Default": ["sg-123456"]
459+
}
460+
}
461+
}
462+
```
463+
464+
```yaml
465+
---
466+
AWSTemplateFormatVersion: '2010-09-09'
467+
Description: Workshop stack.
468+
Parameters:
469+
Project:
470+
Type: String
471+
Description: This is a string!
472+
Default: my_project_name
473+
```
474+
475+
Review the references to learn more about parameters!
476+
477+
#### References
478+
437479
- [Parameters](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/parameters-section-structure.html)
438480

439481
### Resource Types
440482

483+
Review the references to see the resources CloudFormation supports creating.
484+
485+
Custom resources can be created through Lambda Functions.
486+
487+
This section is for reference only.
488+
441489
#### References
442490

443491
- [AWS Resource Types Reference](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-template-resource-type-ref.html)
444492

445493
### Functions
446494

495+
CloudFormation also supports several functions, such as being able to reference
496+
another resource we've created, or splitting a list, joining, a list, etc.
497+
498+
Review the references to see them all.
499+
500+
For this workshop, we will focus on `Ref`. You saw this function back when we
501+
were writing the snippet for the auto scaling group. We used a `Ref` function
502+
to pass in the name of the launch configuration.
503+
504+
```json
505+
...
506+
"LaunchConfigurationName": {
507+
"Ref": "WorkshopLaunchConfig"
508+
},
509+
```
510+
511+
```yaml
512+
...
513+
LaunchConfigurationName:
514+
Ref: WorkshopLaunchConfig
515+
```
516+
447517
#### References
448518

449519
- [Intrinsic Function Reference](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/intrinsic-function-reference.html)
520+
- [Ref](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/intrinsic-function-reference-ref.html)
450521

451522
## Lab
452523

453-
Using our existing CloudFormation template, configure it to accept a parameter to change the instance type, AMI (typed), and add another security group rule that allows incoming traffic on port 443.
524+
Write a CloudFormation template that does the following:
525+
526+
- `AWSTemplateFormatVersion` defined to `2010-09-09`.
527+
- `Description` defined to `Lab stack.`.
528+
- Accepts a parameter called `DesiredCapacity`, that is a `Number`, and defaults to 0.
529+
- Accepts a parameter called `MinSize`, that is a `Number`, and defaults to 0.
530+
- Accepts a parameter called `MaxSize`, that is a `Number`, that defaults to 1.
531+
- Accepts a parameter called `AmiId`, that is a `AWS::EC2::Image::Id`, that defaults to `ami-f2d3638a `.
532+
- Accepts a parameter called `InstanceType`, that is a `String`, that defaults to `t2.micro`. It should restrict the options to `["t2.micro", "t2.medium"]`.
533+
- Accepts a parameter called `VpcId`, that is a `AWS::EC2::VPC::Id`.
534+
- Accepts a parameter called `DefaultKeyPair` that is a `AWS::EC2::KeyPair::KeyName`.
535+
- Accepts a parameter called `SubnetIds`, that is a `List<AWS::EC2::Subnet::Id>`.
536+
- Creates a security group named `LabSg` which has:
537+
+ Egress rule to MySQL (3306) on CIDR block `0.0.0.0/0`.
538+
+ Egress rule to HTTP (80) on CIDR block `0.0.0.0/0`.
539+
+ Egress rule to HTTPS (443) on CIDR block `0.0.0.0/0`.
540+
+ Ingress rule to HTTP (80) on CIDR block `0.0.0.0/0`.
541+
+ Ingress rule to HTTP (443) on CIDR block `0.0.0.0/0`.
542+
- Create a launch configuration named `LabLaunchConfig` which:
543+
+ References `DefaultKeyPair`
544+
+ References `AmiId`
545+
+ References `LabSg`
546+
+ References `InstanceType`
547+
- Create a auto scaling group named `LabAsg` which:
548+
+ References `DesiredCapacity`
549+
+ References `LabLaunchConfig`
550+
+ References `MaxSize`
551+
+ References `MinSize`
552+
+ References `SubnetIds`

0 commit comments

Comments
 (0)