-
Notifications
You must be signed in to change notification settings - Fork 0
/
master.yaml
155 lines (154 loc) · 5.15 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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
---
# Copyright 2019 cabcookie.de
#
# Licensed under the GNU GENERAL PUBLIC LICENSE Version 3.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://raw.githubusercontent.com/cabcookie/wordpress-cloudformation-template/master/LICENSE
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
AWSTemplateFormatVersion: '2010-09-09'
Description: 'Master CloudFormation Template (nested) to create a reliable Wordpress page'
Metadata:
'AWS::CloudFormation::Interface':
ParameterGroups:
- Label:
default: 'Settings for templates'
Parameters:
- TemplateBucket
- Label:
default: 'Settings for networking'
Parameters:
- Domain
- SubdomainWordpress
- CertificateARNCloudFront
- CertificateARNLoadBalancer
- ClassBIP
- Label:
default: 'Settings for EC2 instances'
Parameters:
- KeyPairName
- Label:
default: 'Settings for alarming or notifications'
Parameters:
- Email
- Phone
Parameters:
TemplateBucket:
Description: 'S3 Bucket where to find the templates for CloudFormation'
Type: String
Default: cabcookie-templates
Domain:
Description: 'Domain to be used for the Wordpress blog'
Type: String
Default: wp.cabcookie.de
SubdomainWordpress:
Description: 'Subdomain being used for the Wordpress page (i.e. **blog**.domain.com)'
Type: String
Default: 'blog'
CertificateARNCloudFront:
Description: 'The ARN for the certificate used for CloudFront'
Type: String
Default: arn:aws:acm:us-east-1:876314442006:certificate/f1bba997-847a-46a3-a564-015c30e9301b
CertificateARNLoadBalancer:
Description: 'The ARN for the certificate used for Elastic Load Balancer'
Type: String
Default: arn:aws:acm:eu-west-1:876314442006:certificate/5a000fa5-5aa8-40df-a7a8-bba9f4c5d9f4
ClassBIP:
Description: 'Class B of VPC (10.XXX.0.0/16)'
Type: Number
Default: 0
ConstraintDescription: 'Must be in the range [0-255]'
MinValue: 0
MaxValue: 255
KeyPairName:
Description: 'Name of the security key pair generated in the EC2 console'
Type: AWS::EC2::KeyPair::KeyName
Default: Wordpress
Email:
Description: 'Email address to receive notifications'
Type: String
Default: ''
Phone:
Description: 'Phone number to receive notifications'
Type: String
Default: ''
Conditions:
HasEmail: !Not [!Equals [!Ref Email, '']]
HasPhone: !Not [!Equals [!Ref Phone, '']]
HasEmailOrPhone: !Or [!Condition HasEmail, !Condition HasPhone]
Resources:
# TODO: CreateNotificationARNs
# TODO: CreateIAMRoles:
# TODO: CreateIAMGroups:
# TODO: Do I need to create IAM Users?
Notification:
Type: AWS::CloudFormation::Stack
Condition: HasEmailOrPhone
Properties:
TemplateURL: !Sub 'https://${TemplateBucket}.s3-${AWS::Region}.amazonaws.com/notifications.yaml'
Parameters:
Email: !Ref Email
Phone: !Ref Phone
Alarms:
Type: AWS::CloudFormation::Stack
Condition: HasEmailOrPhone
Properties:
TemplateURL: !Sub 'https://${TemplateBucket}.s3-${AWS::Region}.amazonaws.com/notifications.yaml'
Parameters:
Email: !Ref Email
Phone: !Ref Phone
VPC:
Type: AWS::CloudFormation::Stack
Properties:
NotificationARNs:
- !GetAtt Notification.Outputs.NotificationARNId
TemplateURL: !Sub 'https://${TemplateBucket}.s3-${AWS::Region}.amazonaws.com/vpc.yaml'
Parameters:
IPNetwork: !Sub 10.${ClassBIP}
Subnets:
Type: AWS::CloudFormation::Stack
Properties:
NotificationARNs:
- !GetAtt Notification.Outputs.NotificationARNId
TemplateURL: !Sub 'https://${TemplateBucket}.s3-${AWS::Region}.amazonaws.com/subnets.yaml'
Parameters:
IPNetwork: !GetAtt VPC.Outputs.VPCClassBNetwork
VPC: !GetAtt VPC.Outputs.VPCId
Outputs:
TemplateID:
Description: 'Master Template Create Wordpress Blog'
Value: 'master'
TemplateVersion:
Description: 'Master Template Version'
Value: '0.0.1'
StackName:
Description: 'Stack name'
Value: !Sub '${AWS::StackName}'
VPCId:
Description: 'VPC ID'
Value: !GetAtt VPC.Outputs.VPCId
SubnetPublicAId:
Description: 'Subnet Public A ID'
Value: !GetAtt Subnets.Outputs.SubnetPublicAId
SubnetPublicBId:
Description: 'Subnet Public B ID'
Value: !GetAtt Subnets.Outputs.SubnetPublicBId
SubnetPublicCId:
Description: 'Subnet Public C ID'
Value: !GetAtt Subnets.Outputs.SubnetPublicCId
SubnetPrivateAId:
Description: 'Subnet Private A ID'
Value: !GetAtt Subnets.Outputs.SubnetPrivateAId
SubnetPrivateBId:
Description: 'Subnet Private B ID'
Value: !GetAtt Subnets.Outputs.SubnetPrivateBId
SubnetPrivateCId:
Description: 'Subnet Private C ID'
Value: !GetAtt Subnets.Outputs.SubnetPrivateCId
# TODO: Create more templates to create Wordpress page