forked from OHDSI/OHDSIonAWS
-
Notifications
You must be signed in to change notification settings - Fork 0
/
02-databases-ohdsi.yaml
204 lines (193 loc) · 6.4 KB
/
02-databases-ohdsi.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
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
# Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with the License.
# A copy of the License is located at
# http://aws.amazon.com/apache2.0/
# or in the "license" file accompanying this file. This file 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: This CloudFormation Template deploys a complete OHDSI environment. It
depends on the OHDSI-VPC CloudFormation Template.
Parameters:
MultiAZDatabase:
AllowedValues:
- true
- false
Default: false
Description: Specifies whether a to deploy the AWS Aurora MySQL Database in Multi-AZ configuration.
Type: String
DatabaseInstanceType:
AllowedValues:
- db.t3.medium
- db.r4.large
- db.r4.xlarge
- db.r4.2xlarge
- db.r4.4xlarge
- db.r4.8xlarge
- db.r4.16xlarge
ConstraintDescription: Must be a valid RDS instance class.
Default: db.r4.large
Description: The Amazon RDS database instance class.
Type: String
DatabaseMasterPassword:
Description: Must be letters (upper or lower), numbers, spaces, and these special characters `~#$%^&*()_+,-
Type: String
NoEcho: true
AllowedPattern: ^([a-zA-Z0-9`~#$%^&*()_+,\\-])*$
ConstraintDescription: The Amazon RDS master password. Letters, numbers, spaces, and these special characters `~#$%^&*()_+,-
RedshiftInstanceType:
Type: String
Description: DC instance types provide faster, but smaller storage. DS instance types provide larger, but slower storage.
AllowedValues:
- dc2.large
- dc2.8xlarge
- ds2.xlarge
- ds2.8xlarge
- dc1.large
Default: dc2.large
NumRedshiftNodes:
AllowedPattern: ^((?!0$)[1-2]?[0-9]|32)$
ConstraintDescription: Must be a number between 1 and 32.
Default: 1
Description: Specifies the number of nodes in your Redshift cluster.
Type: String
SubnetDataA:
Type: AWS::EC2::Subnet::Id
SubnetDataB:
Type: AWS::EC2::Subnet::Id
SGData:
Type: AWS::EC2::SecurityGroup::Id
RSRoleArn:
Type: String
Conditions:
DeployMultiAZDB:
!Equals [ true, !Ref MultiAZDatabase ]
NotDeployMultiAZDB:
!Equals [ false, !Ref MultiAZDatabase ]
SingleNodeRedshift:
!Equals [ '1', !Ref NumRedshiftNodes ]
MultiNodeRedshift:
!Not [ !Equals [ '1', !Ref NumRedshiftNodes ] ]
Resources:
# Deploys the RDS Aurora Postgres cluster used to store the application data for WebAPI.
RDSCluster:
Type: AWS::RDS::DBCluster
Properties:
MasterUsername: 'master'
MasterUserPassword: !Ref DatabaseMasterPassword
Engine: aurora-postgresql
EngineVersion: 10.7
StorageEncrypted: 'True'
Port: 5432
DBSubnetGroupName:
Ref: RDSDBSubnets
DBClusterParameterGroupName:
Ref: RDSDBClusterParameterGroup
VpcSecurityGroupIds:
- !Ref SGData
RDSDBInstance1:
Type: AWS::RDS::DBInstance
Properties:
DBSubnetGroupName:
Ref: RDSDBSubnets
DBParameterGroupName:
Ref: RDSDBParameterGroup
Engine: aurora-postgresql
EngineVersion: 10.7
DBClusterIdentifier:
Ref: RDSCluster
PubliclyAccessible: 'false'
DBInstanceClass: !Ref DatabaseInstanceType
# Only create the second instance if the user specified a Multi-AZ Database
RDSDBInstance2:
Condition: DeployMultiAZDB
Type: AWS::RDS::DBInstance
Properties:
DBSubnetGroupName:
Ref: RDSDBSubnets
DBParameterGroupName:
Ref: RDSDBParameterGroup
Engine: aurora-postgresql
EngineVersion: 10.7
DBClusterIdentifier:
Ref: RDSCluster
PubliclyAccessible: 'false'
DBInstanceClass: !Ref DatabaseInstanceType
RDSDBClusterParameterGroup:
Type: AWS::RDS::DBClusterParameterGroup
Properties:
Description: CloudFormation Sample Aurora Cluster Parameter Group
Family: aurora-postgresql10
Parameters:
rds.force_ssl: 1
RDSDBParameterGroup:
Type: AWS::RDS::DBParameterGroup
Properties:
Description: CloudFormation Sample Aurora Parameter Group
Family: aurora-postgresql10
Parameters:
log_rotation_age: 60
RDSDBSubnets:
Type: AWS::RDS::DBSubnetGroup
Properties:
DBSubnetGroupDescription: Subnet Group for RDS
SubnetIds:
- !Ref SubnetDataA
- !Ref SubnetDataB
RedshiftClusterSingle:
Condition: SingleNodeRedshift
Type: "AWS::Redshift::Cluster"
Properties:
DBName: "mycdm"
MasterUsername: "master"
MasterUserPassword: !Ref DatabaseMasterPassword
NodeType: !Ref RedshiftInstanceType
ClusterType: "single-node"
Encrypted: "True"
PubliclyAccessible: "False"
ClusterParameterGroupName: !Ref RedshiftClusterParameterGroup
IamRoles:
- !Ref RSRoleArn
VpcSecurityGroupIds:
- !Ref SGData
ClusterSubnetGroupName:
Ref: RedshiftSubnetGroup
RedshiftClusterMulti:
Condition: MultiNodeRedshift
Type: "AWS::Redshift::Cluster"
Properties:
DBName: "mycdm"
MasterUsername: "master"
MasterUserPassword: !Ref DatabaseMasterPassword
NodeType: !Ref RedshiftInstanceType
ClusterType: "multi-node"
NumberOfNodes: !Ref NumRedshiftNodes
Encrypted: "True"
PubliclyAccessible: "False"
ClusterParameterGroupName: !Ref RedshiftClusterParameterGroup
IamRoles:
- !Ref RSRoleArn
VpcSecurityGroupIds:
- !Ref SGData
ClusterSubnetGroupName:
Ref: RedshiftSubnetGroup
RedshiftSubnetGroup:
Type: 'AWS::Redshift::ClusterSubnetGroup'
Properties:
Description: "Redshift Security Groups"
SubnetIds:
- !Ref SubnetDataA
RedshiftClusterParameterGroup:
Type: "AWS::Redshift::ClusterParameterGroup"
Properties:
Description: "My parameter group"
ParameterGroupFamily: "redshift-1.0"
Parameters:
-
ParameterName: "require_ssl"
ParameterValue: "true"
Outputs:
RDSEndpoint:
Value: !GetAtt RDSCluster.Endpoint.Address
RedshiftEndpoint:
Value: !If [ MultiNodeRedshift, !GetAtt RedshiftClusterMulti.Endpoint.Address, !GetAtt RedshiftClusterSingle.Endpoint.Address ]