This repository has been archived by the owner on Sep 3, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
master.yaml
121 lines (105 loc) · 4.12 KB
/
master.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
Description: >
This cloud formation template deploys the ghost blogging platform across
multiple available zones(AZ) utilizing docker containers with a multi AZ
rds setup, efs backend for content storage, and an application load balancer.
link to project source: https://github.com/TryGhost/Ghost
Author: Cameron Sumpter <cameron[at]sumpter[dot]xyz>
Repo: https://github.com/csumpter/ops-challenge
Parameters:
DatabaseUsername:
Description: provide the name of the database username
Type: String
Default: 'awsuser'
DatabasePassword:
Description: provide the database password
Type: String
NoEcho: true
# password validation, must be at least 8 but no more than 41 chars
MinLength: 8
MaxLength: 41
DatabaseName:
Type: String
Description: provide the name you want to call the rds database
Default: 'ghostdb'
Resources:
VPC:
Type: AWS::CloudFormation::Stack
Properties:
TemplateURL: https://s3.amazonaws.com/ghost-service/infrastructure/vpc.yaml
Parameters:
EnvironmentName: !Ref AWS::StackName
VpcCIDR: 10.190.0.0/16
# subnet for resources in the first availability zone
Subnet1CIDR: 10.190.1.0/24
# subnet for resources in the second availability zone
Subnet2CIDR: 10.190.2.0/24
SecurityGroups:
Type: AWS::CloudFormation::Stack
Properties:
TemplateURL: https://s3.amazonaws.com/ghost-service/infrastructure/security-groups.yaml
Parameters:
EnvironmentName: !Ref AWS::StackName
VPC: !GetAtt VPC.Outputs.VPC
ALB:
Type: AWS::CloudFormation::Stack
Properties:
TemplateURL: https://s3.amazonaws.com/ghost-service/infrastructure/load-balancer.yaml
Parameters:
EnvironmentName: !Ref AWS::StackName
VPC: !GetAtt VPC.Outputs.VPC
Subnets: !GetAtt VPC.Outputs.Subnets
SecurityGroup: !GetAtt SecurityGroups.Outputs.LoadBalancerSecurityGroup
Path: /
S3:
Type: AWS::CloudFormation::Stack
Properties:
TemplateURL: https://s3.amazonaws.com/ghost-service/infrastructure/s3.yaml
Parameters:
EnvironmentName: !Ref AWS::StackName
S3UserName: !Sub ${AWS::StackName}-s3-user
DB:
Type: AWS::CloudFormation::Stack
Properties:
TemplateURL: https://s3.amazonaws.com/ghost-service/infrastructure/database.yaml
Parameters:
EnvironmentName: !Ref AWS::StackName
DatabaseUsername: !Ref DatabaseUsername
SecurityGroup: !GetAtt SecurityGroups.Outputs.DatabaseSecurityGroup
DatabasePassword: !Ref DatabasePassword
Subnets: !GetAtt VPC.Outputs.Subnets
DatabaseName: !Ref DatabaseName
ECS:
Type: AWS::CloudFormation::Stack
Properties:
TemplateURL: https://s3.amazonaws.com/ghost-service/infrastructure/ecs-cluster.yaml
Parameters:
EnvironmentName: !Ref AWS::StackName
InstanceType: t2.micro
ClusterSize: 2
VPC: !GetAtt VPC.Outputs.VPC
SecurityGroup: !GetAtt SecurityGroups.Outputs.EC2HostSecurityGroup
Subnets: !GetAtt VPC.Outputs.Subnets
TargetGroup: !GetAtt ALB.Outputs.LoadBalancerTargetGroup
GhostService:
Type: AWS::CloudFormation::Stack
Properties:
TemplateURL: https://s3.amazonaws.com/ghost-service/service/ghost.yaml
Parameters:
VPC: !GetAtt VPC.Outputs.VPC
Cluster: !GetAtt ECS.Outputs.Cluster
DesiredCount: 2
GhostServiceUrl: !GetAtt ALB.Outputs.LoadBalancerUrl
DatabaseUsername: !Ref DatabaseUsername
DatabasePassword: !Ref DatabasePassword
DatabaseHostname: !GetAtt DB.Outputs.DatabaseAddress
DatabaseName: !Ref DatabaseName
S3BucketName: !GetAtt S3.Outputs.S3BucketName
S3Url: !GetAtt S3.Outputs.S3Url
S3UserName: !GetAtt S3.Outputs.S3UserName
S3UserAccessKey: !GetAtt S3.Outputs.S3UserAccessKey
S3UserSecretKey: !GetAtt S3.Outputs.S3UserSecretKey
TargetGroup: !GetAtt ALB.Outputs.LoadBalancerTargetGroup
Outputs:
GhostServiceUrl:
Description: The URL endpoint for the ghost service
Value: !GetAtt ALB.Outputs.LoadBalancerUrl