-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path02-wordpress-efs.yaml
167 lines (158 loc) · 4.82 KB
/
02-wordpress-efs.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
156
157
158
159
160
161
162
163
164
165
166
167
---
AWSTemplateFormatVersion: 2010-09-09
Description: Stack to create EFS
Metadata:
Authors:
Description: https://github.com/lzrocha
AWS::CloudFormation::Interface:
ParameterGroups:
- Label:
default: Amazon EFS Parameters
Parameters:
- VpcId
- Subnet
- NumberOfSubnets
- EfsSecurityGroup
- PerformanceMode
ParameterLabels:
EfsSecurityGroup:
default: EFS Security Group
Subnet:
default: Subnets
VpcId:
default: Vpc Id
NumberOfSubnets:
default: Number of Subnets
PerformanceMode:
default: Performance Mode
Conditions:
NumberOfSubnets1:
!Equals [ 1, !Ref NumberOfSubnets ]
NumberOfSubnets2:
!Equals [ 2, !Ref NumberOfSubnets ]
NumberOfSubnets3:
!Equals [ 3, !Ref NumberOfSubnets ]
NumberOfSubnets4:
!Equals [ 4, !Ref NumberOfSubnets ]
NumberOfSubnets5:
!Equals [ 5, !Ref NumberOfSubnets ]
NumberOfSubnets6:
!Equals [ 6, !Ref NumberOfSubnets ]
Subnet0: !Or
- !Condition NumberOfSubnets1
- !Condition NumberOfSubnets2
- !Condition NumberOfSubnets3
- !Condition NumberOfSubnets4
- !Condition NumberOfSubnets5
- !Condition NumberOfSubnets6
Subnet1: !Or
- !Condition NumberOfSubnets2
- !Condition NumberOfSubnets3
- !Condition NumberOfSubnets4
- !Condition NumberOfSubnets5
- !Condition NumberOfSubnets6
Subnet2: !Or
- !Condition NumberOfSubnets3
- !Condition NumberOfSubnets4
- !Condition NumberOfSubnets5
- !Condition NumberOfSubnets6
Subnet3: !Or
- !Condition NumberOfSubnets4
- !Condition NumberOfSubnets5
- !Condition NumberOfSubnets6
Subnet4: !Or
- !Condition NumberOfSubnets5
- !Condition NumberOfSubnets6
Subnet5: !Condition NumberOfSubnets6
Parameters:
VpcId:
Description: The Vpc Id of an existing Vpc.
Type: AWS::EC2::VPC::Id
ConstraintDescription: must be the VPC Id of an existing Virtual Private Cloud.
Subnet:
Description: The Subnet ID of existing subnets.
Type: List<AWS::EC2::Subnet::Id>
ConstraintDescription: It is recommended to include all available subnets.
EfsSecurityGroup:
Description: Select the Amazon EFS security group.
Type: AWS::EC2::SecurityGroup::Id
NumberOfSubnets:
AllowedValues:
- 1
- 2
- 3
- 4
- 5
- 6
Default: 3
Description: Number of subnets. This must match your selections in the list of Subnets below.
Type: String
PerformanceMode:
AllowedValues:
- generalPurpose
- maxIO
Default: generalPurpose
Description: Select the performance mode of the file system.
Type: String
Resources:
ElasticFileSystem:
Type: AWS::EFS::FileSystem
Properties:
PerformanceMode: !Ref PerformanceMode
ElasticFileSystemMountTarget0:
Condition: Subnet0
Type: AWS::EFS::MountTarget
Properties:
FileSystemId: !Ref ElasticFileSystem
SecurityGroups:
- !Ref EfsSecurityGroup
SubnetId: !Select [ 0, !Ref Subnet ]
ElasticFileSystemMountTarget1:
Condition: Subnet1
Type: AWS::EFS::MountTarget
Properties:
FileSystemId: !Ref ElasticFileSystem
SecurityGroups:
- !Ref EfsSecurityGroup
SubnetId: !Select [ 1, !Ref Subnet ]
ElasticFileSystemMountTarget2:
Condition: Subnet2
Type: AWS::EFS::MountTarget
Properties:
FileSystemId: !Ref ElasticFileSystem
SecurityGroups:
- !Ref EfsSecurityGroup
SubnetId: !Select [ 2, !Ref Subnet ]
ElasticFileSystemMountTarget3:
Condition: Subnet3
Type: AWS::EFS::MountTarget
Properties:
FileSystemId: !Ref ElasticFileSystem
SecurityGroups:
- !Ref EfsSecurityGroup
SubnetId: !Select [ 3, !Ref Subnet ]
ElasticFileSystemMountTarget4:
Condition: Subnet4
Type: AWS::EFS::MountTarget
Properties:
FileSystemId: !Ref ElasticFileSystem
SecurityGroups:
- !Ref EfsSecurityGroup
SubnetId: !Select [ 4, !Ref Subnet ]
ElasticFileSystemMountTarget5:
Condition: Subnet5
Type: AWS::EFS::MountTarget
Properties:
FileSystemId: !Ref ElasticFileSystem
SecurityGroups:
- !Ref EfsSecurityGroup
SubnetId: !Select [ 5, !Ref Subnet ]
Outputs:
ElasticFileSystem:
Value: !Ref ElasticFileSystem
ElasticFileSystemDnsName:
Description: DNS name for the Amazon EFS file system.
Value: !Join [ '.', [ !Ref ElasticFileSystem, 'efs', !Ref 'AWS::Region', 'amazonaws', 'com' ] ]
ElasticFileSystemMountCommand:
Description: Mount command for mounting the Amazon EFS file system.
Value: !Join [ '', [ 'sudo mount -t nfs4 -o nfsvers=4.1,rsize=1048576,wsize=1048576,hard,timeo=600,retrans=2 ', !Join [ '.', [ !Ref ElasticFileSystem, 'efs', !Ref 'AWS::Region', 'amazonaws', 'com:/', '/', !Ref ElasticFileSystem ] ] ] ]