-
Notifications
You must be signed in to change notification settings - Fork 0
/
redshift-serverless.yaml
203 lines (200 loc) · 6.15 KB
/
redshift-serverless.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
AWSTemplateFormatVersion: 2010-09-09
Parameters:
DatabaseName:
Description: The name of the first database in the Amazon Redshift Serverless environment.
Type: String
Default: dev
MaxLength: 127
AllowedPattern: '[a-zA-Z][a-zA-Z_0-9+.@-]*'
AdminUsername:
Description: The administrator's user name for Redshift Serverless Namespace being created.
Type: String
Default: admin
AllowedPattern: '[a-zA-Z][a-zA-Z_0-9+.@-]*'
AdminUserPassword:
Description: The password associated with admin user.
Type: String
NoEcho: 'true'
Default: Admin123
MinLength: 8
MaxLength: 64
# AllowedPattern: '^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)[^\x00-\x20\x22\x27\x2f\x40\x5c\x7f-\uffff]+'
NamespaceName:
Description: A unique identifier that defines the Namespace.
Default: rswg
Type: String
MinLength: 3
MaxLength: 64
AllowedPattern: '^[a-z0-9-]+$'
WorkgroupName:
Description: A unique identifier that defines the Workspace.
Default: redshiftworkgroup
Type: String
MinLength: 3
MaxLength: 64
AllowedPattern: '^[a-z0-9-]*$'
BaseRPU:
Description: Base RPU for Redshift Serverless Workgroup.
Type: Number
MinValue: 8
MaxValue: 512
Default: 8
AllowedValues: [8,16,32,40,48,56,64,72,80,88,96,104,112,120,128,136,144,152,160,168,176,184,192,200,208,216,224,232,240,248,256,264,272,280,288,296,304,312,320,328,336,344,352,360,368,376,384,392,400,408,416,424,432,440,448,456,464,472,480,488,496,504,512]
PubliclyAccessible:
Description: Redshift Serverless instance to be publicly accessible.
Type: String
Default: true
AllowedValues:
- true
- false
SubnetId:
Description: You must have at least three subnets, and they must span across three Availability Zones
Type: List<AWS::EC2::Subnet::Id>
Default: "subnet-0078d85f44b658f02, subnet-04f90c9f41457f7da, subnet-07e405277b9ac63ad, subnet-067f80379cb9e796e"
SecurityGroupIds:
Description: The list of SecurityGroupIds in your Virtual Private Cloud (VPC).
Type: List<AWS::EC2::SecurityGroup::Id>
Default: "sg-04ef94234f45a4715"
LogExportsList:
Description: Provide comma seperate values from list "userlog","connectionlog","useractivitylog". E.g userlog,connectionlog,useractivitylog. If left blank, LogExport is turned off.
Type: CommaDelimitedList
Default: userlog,connectionlog,useractivitylog
EnhancedVpcRouting:
Description: The value that specifies whether to enable enhanced virtual private cloud (VPC) routing, which forces Amazon Redshift Serverless to route traffic through your VPC.
Type: String
AllowedValues:
- true
- false
Default: false
Metadata:
'AWS::CloudFormation::Interface':
ParameterGroups:
- Label:
default: Namespace parameters
Parameters:
- NamespaceName
- DatabaseName
- AdminUsername
- AdminUserPassword
- IAMRole
- LogExportsList
- Label:
default: Workgroup parameters
Parameters:
- WorkgroupName
- BaseRPU
- PubliclyAccessible
- SubnetId
- SecurityGroupIds
- EnhancedVpcRouting
ParameterLabels:
DatabaseName:
default: "Database Name"
AdminUsername:
default: "Admin User Name"
AdminUserPassword:
default: "Admin User Password"
NamespaceName:
default: "Namespace"
WorkgroupName:
default: "Workgroup"
BaseRPU:
default: "Base RPU"
PubliclyAccessible:
default: "Publicly accessible"
SubnetId:
default: "Subnet Ids (Select 3 Subnet Ids spanning 3 AZs)"
SecurityGroupIds:
default: "Security Group Id"
IAMRole:
default: "Associate IAM Role"
EnhancedVpcRouting:
default: "Enhanced VPC Routing"
LogExportsList:
default: "Log Export List"
Resources:
RedshiftAccessRole:
Type: AWS::IAM::Role
Properties:
ManagedPolicyArns:
- arn:aws:iam::aws:policy/service-role/AWSGlueServiceRole
- arn:aws:iam::aws:policy/AmazonRedshiftAllCommandsFullAccess
AssumeRolePolicyDocument:
Version: 2012-10-17
Statement:
-
Effect: Allow
Principal:
Service:
- redshift.amazonaws.com
Action:
- sts:AssumeRole
RedshiftRolePolicy:
Type: AWS::IAM::Policy
Properties:
PolicyName: RedshiftRolePolicy
PolicyDocument:
Version: 2012-10-17
Statement:
-
Effect: Allow
Action: s3:ListAllMyBuckets
Resource: arn:aws:s3:::*
-
Effect: Allow
Action:
- 's3:Get*'
- 's3:List*'
Resource: '*'
-
Effect: Allow
Action: cloudwatch:*
Resource: "*"
-
Effect: Allow
Action: kinesis:*
Resource: "*"
Roles:
- !Ref RedshiftAccessRole
RedshiftServerlessNamespace:
DependsOn: RedshiftAccessRole
Type: 'AWS::RedshiftServerless::Namespace'
Properties:
AdminUsername:
Ref: AdminUsername
AdminUserPassword:
Ref: AdminUserPassword
DbName:
Ref: DatabaseName
NamespaceName:
Ref: NamespaceName
IamRoles:
- !GetAtt [ RedshiftAccessRole, Arn ]
LogExports:
Ref: LogExportsList
RedshiftServerlessWorkgroup:
Type: 'AWS::RedshiftServerless::Workgroup'
Properties:
WorkgroupName:
Ref: WorkgroupName
NamespaceName:
Ref: NamespaceName
BaseCapacity:
Ref: BaseRPU
PubliclyAccessible:
Ref: PubliclyAccessible
SubnetIds:
Ref: SubnetId
SecurityGroupIds:
Ref: SecurityGroupIds
EnhancedVpcRouting:
Ref: EnhancedVpcRouting
DependsOn:
- RedshiftServerlessNamespace
Outputs:
ServerlessNamespace:
Description: Name of the namespace
Value: !Ref NamespaceName
ServerlessWorkgroup:
Description: Name of the workgroup
Value: !Ref WorkgroupName