This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FirstInstance: # (1) | |
Type: AWS::EC2::Instance # (2) | |
Properties: | |
ImageId: ami-0389b2a3c4948b1a0 # (3) | |
InstanceType: t2.micro # (4) | |
UserData: | |
Fn::Base64: | |
Fn::Sub: | # (5) | |
#!/bin/bash -xe | |
yum update -y |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FirstInstance: | |
Type: AWS::EC2::Instance | |
Properties: | |
ImageId: ami-0389b2a3c4948b1a0 | |
InstanceType: t2.micro | |
SecurityGroups: | |
- !Ref InstanceSecurityGroup # (1) | |
UserData: | |
Fn::Base64: | |
Fn::Sub: | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
AppLaunchConfig: # (2) | |
Type: AWS::AutoScaling::LaunchConfiguration # (2) | |
Properties: | |
ImageId: ami-0389b2a3c4948b1a0 | |
InstanceType: t2.micro | |
SecurityGroups: | |
- !Ref InstanceSecurityGroup | |
UserData: | |
Fn::Base64: | |
Fn::Sub: | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
AppLaunchConfig: # (1) | |
Type: AWS::AutoScaling::LaunchConfiguration # (2) | |
Properties: | |
ImageId: ami-0389b2a3c4948b1a0 | |
InstanceType: t2.micro | |
SecurityGroups: | |
- !Ref InstanceSecurityGroup | |
AssociatePublicIpAddress: true | |
UserData: | |
Fn::Base64: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
AutoScalingGroup: | |
Type: AWS::AutoScaling::AutoScalingGroup | |
Properties: | |
LaunchConfigurationName: !Ref AppLaunchConfig | |
# AvailabilityZones: | |
# - !Select [0, !GetAZs ] | |
# - !Select [1, !GetAZs ] | |
VPCZoneIdentifier: # (1) | |
- !Ref PublicSubnetA | |
- !Ref PublicSubnetB |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
InternetGateway: # (1) | |
Type: AWS::EC2::InternetGateway # (2) | |
DependsOn: VPC | |
AttachGateway: # (2) | |
Type: AWS::EC2::VPCGatewayAttachment # (4) | |
Properties: | |
VpcId: !Ref VPC # (5) | |
InternetGatewayId: !Ref InternetGateway # (6 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
PublicRouteTable: # (1) | |
Type: AWS::EC2::RouteTable # (2) | |
Properties: | |
VpcId: !Ref VPC # (3) | |
PublicRoute: # (4) | |
Type: AWS::EC2::Route # (5) | |
DependsOn: AttachGateway | |
Properties: | |
RouteTableId: !Ref PublicRouteTable # (6) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ApplicationLoadBalancerSecurityGroup: | |
Type: AWS::EC2::SecurityGroup # (4) | |
Properties: | |
GroupDescription: SSH and HTTP | |
VpcId: !Ref VPC | |
SecurityGroupIngress: # (5) | |
- CidrIp: 0.0.0.0/0 | |
FromPort: 80 | |
IpProtocol: tcp | |
ToPort: 80 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ApplicationLoadBalancer: | |
Type: AWS::ElasticLoadBalancingV2::LoadBalancer # (1) | |
Properties: | |
SecurityGroups: | |
- !Ref ApplicationLoadBalancerSecurityGroup # (2) | |
Subnets: # (3) | |
- !Ref PublicSubnetA | |
- !Ref PublicSubnetB | |
ApplicationLoadBalancerSecurityGroup: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
InstanceSecurityGroup: | |
Type: AWS::EC2::SecurityGroup | |
Properties: | |
GroupDescription: Letting HTTP into our instance | |
VpcId: !Ref VPC | |
SecurityGroupIngress: | |
- FromPort: 80 | |
IpProtocol: tcp | |
ToPort: 80 | |
SourceSecurityGroupId: !Ref ApplicationLoadBalancerSecurityGroup # (1) |