This repository has been archived by the owner on Jul 26, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 74
/
aws-refarch-drupal-03-efs.yaml
95 lines (85 loc) · 2.83 KB
/
aws-refarch-drupal-03-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
---
AWSTemplateFormatVersion: 2010-09-09
Description: Reference Architecture to host Drupal on AWS - Creates EFS file system
Metadata:
AWS::CloudFormation::Interface:
ParameterGroups:
- Label:
default: File System Parameters
Parameters:
- EfsSecurityGroup
- DataSubnet0
- DataSubnet1
- DataSubnet2
ParameterLabels:
EfsSecurityGroup:
default: EFS Security Group
DataSubnet0:
default: Data Subnet for AZ 0
DataSubnet1:
default: Data Subnet for AZ 1
DataSubnet2:
default: Data Subnet for AZ 2
Parameters:
EfsSecurityGroup:
Description: Select the EFS security group.
Type: AWS::EC2::SecurityGroup::Id
DataSubnet0:
Description: Select an existing data subnet for AZ 0.
Type: AWS::EC2::Subnet::Id
DataSubnet1:
Description: Select an existing data subnet for AZ 1.
Type: AWS::EC2::Subnet::Id
DataSubnet2:
Description: Select an existing data subnet for AZ 2.
Type: AWS::EC2::Subnet::Id
Conditions:
MoreThan2AZ:
!Or [
!Equals [ !Ref 'AWS::Region', us-east-1 ],
!Equals [ !Ref 'AWS::Region', us-east-2 ],
!Equals [ !Ref 'AWS::Region', us-west-2 ],
!Equals [ !Ref 'AWS::Region', eu-west-1 ],
!Equals [ !Ref 'AWS::Region', sa-east-1 ],
!Equals [ !Ref 'AWS::Region', ap-northeast-1 ],
!Equals [ !Ref 'AWS::Region', ap-southeast-2 ]
]
Resources:
ElasticFileSystem:
Type: AWS::EFS::FileSystem
Properties:
FileSystemTags:
- Key: Name
Value: !Join [ '', [ 'Drupal / ', !Ref 'AWS::StackName' ] ]
PerformanceMode: generalPurpose
ElasticFileSystemMountTarget0:
Type: AWS::EFS::MountTarget
Properties:
FileSystemId: !Ref ElasticFileSystem
SecurityGroups:
- !Ref EfsSecurityGroup
SubnetId: !Ref DataSubnet0
ElasticFileSystemMountTarget1:
Type: AWS::EFS::MountTarget
Properties:
FileSystemId: !Ref ElasticFileSystem
SecurityGroups:
- !Ref EfsSecurityGroup
SubnetId: !Ref DataSubnet1
ElasticFileSystemMountTarget2:
Condition: MoreThan2AZ
Type: AWS::EFS::MountTarget
Properties:
FileSystemId: !Ref ElasticFileSystem
SecurityGroups:
- !Ref EfsSecurityGroup
SubnetId: !Ref DataSubnet2
Outputs:
ElasticFileSystem:
Value: !Ref ElasticFileSystem
ElasticFileSystemDnsName:
Description: DNS name for the EFS file system.
Value: !Join [ '.', [ !Ref ElasticFileSystem, 'efs', !Ref 'AWS::Region', 'amazonaws', 'com' ] ]
ElasticFileSystemMountCommand:
Description: Mount command for mounting the 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:/ /var/www/drupal' ] ] ] ]