@aws-cdk/aws-glue-alpha 2.176.0-alpha.0 → 2.178.0-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.jsii +6187 -3907
- package/.jsii.tabl.json.gz +0 -0
- package/.warnings.jsii.js +525 -235
- package/README.md +422 -159
- package/awslint.json +5 -5
- package/lib/code.js +4 -5
- package/lib/connection.js +15 -3
- package/lib/constants.d.ts +261 -0
- package/lib/constants.js +281 -0
- package/lib/data-format.js +5 -5
- package/lib/data-quality-ruleset.js +6 -3
- package/lib/database.js +5 -2
- package/lib/external-table.js +20 -2
- package/lib/index.d.ts +13 -2
- package/lib/index.js +14 -3
- package/lib/jobs/job.d.ts +393 -0
- package/lib/jobs/job.js +298 -0
- package/lib/jobs/pyspark-etl-job.d.ts +81 -0
- package/lib/jobs/pyspark-etl-job.js +130 -0
- package/lib/jobs/pyspark-flex-etl-job.d.ts +83 -0
- package/lib/jobs/pyspark-flex-etl-job.js +137 -0
- package/lib/jobs/pyspark-streaming-job.d.ts +81 -0
- package/lib/jobs/pyspark-streaming-job.js +130 -0
- package/lib/jobs/python-shell-job.d.ts +55 -0
- package/lib/jobs/python-shell-job.js +99 -0
- package/lib/jobs/ray-job.d.ts +44 -0
- package/lib/jobs/ray-job.js +89 -0
- package/lib/jobs/scala-spark-etl-job.d.ts +78 -0
- package/lib/jobs/scala-spark-etl-job.js +134 -0
- package/lib/jobs/scala-spark-flex-etl-job.d.ts +109 -0
- package/lib/jobs/scala-spark-flex-etl-job.js +143 -0
- package/lib/jobs/scala-spark-streaming-job.d.ts +77 -0
- package/lib/jobs/scala-spark-streaming-job.js +131 -0
- package/lib/jobs/spark-ui-utils.d.ts +53 -0
- package/lib/jobs/spark-ui-utils.js +26 -0
- package/lib/s3-table.d.ts +4 -4
- package/lib/s3-table.js +20 -2
- package/lib/schema.d.ts +1 -1
- package/lib/schema.js +2 -2
- package/lib/security-configuration.js +5 -2
- package/lib/storage-parameter.js +1 -1
- package/lib/table-base.d.ts +1 -1
- package/lib/table-base.js +2 -2
- package/lib/table-deprecated.js +1 -1
- package/lib/triggers/trigger-options.d.ts +205 -0
- package/lib/triggers/trigger-options.js +39 -0
- package/lib/triggers/workflow.d.ts +203 -0
- package/lib/triggers/workflow.js +371 -0
- package/package.json +8 -8
- package/rosetta/default.ts-fixture +1 -1
- package/lib/job-executable.d.ts +0 -384
- package/lib/job-executable.js +0 -348
- package/lib/job.d.ts +0 -574
- package/lib/job.js +0 -531
package/README.md
CHANGED
|
@@ -17,116 +17,332 @@
|
|
|
17
17
|
|
|
18
18
|
This module is part of the [AWS Cloud Development Kit](https://github.com/aws/aws-cdk) project.
|
|
19
19
|
|
|
20
|
-
##
|
|
20
|
+
## README
|
|
21
|
+
|
|
22
|
+
[AWS Glue](https://aws.amazon.com/glue/) is a serverless data integration
|
|
23
|
+
service that makes it easier to discover, prepare, move, and integrate data
|
|
24
|
+
from multiple sources for analytics, machine learning (ML), and application
|
|
25
|
+
development.
|
|
26
|
+
|
|
27
|
+
The Glue L2 construct has convenience methods working backwards from common
|
|
28
|
+
use cases and sets required parameters to defaults that align with recommended
|
|
29
|
+
best practices for each job type. It also provides customers with a balance
|
|
30
|
+
between flexibility via optional parameter overrides, and opinionated
|
|
31
|
+
interfaces that discouraging anti-patterns, resulting in reduced time to develop
|
|
32
|
+
and deploy new resources.
|
|
33
|
+
|
|
34
|
+
### References
|
|
35
|
+
|
|
36
|
+
* [Glue Launch Announcement](https://aws.amazon.com/blogs/aws/launch-aws-glue-now-generally-available/)
|
|
37
|
+
* [Glue Documentation](https://docs.aws.amazon.com/glue/index.html)
|
|
38
|
+
* [Glue L1 (CloudFormation) Constructs](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/AWS_Glue.html)
|
|
39
|
+
* Prior version of the [@aws-cdk/aws-glue-alpha module](https://github.com/aws/aws-cdk/blob/v2.51.1/packages/%40aws-cdk/aws-glue/README.md)
|
|
40
|
+
|
|
41
|
+
## Create a Glue Job
|
|
42
|
+
|
|
43
|
+
A Job encapsulates a script that connects to data sources, processes
|
|
44
|
+
them, and then writes output to a data target. There are four types of Glue
|
|
45
|
+
Jobs: Spark (ETL and Streaming), Python Shell, Ray, and Flex Jobs. Most
|
|
46
|
+
of the required parameters for these jobs are common across all types,
|
|
47
|
+
but there are a few differences depending on the languages supported
|
|
48
|
+
and features provided by each type. For all job types, the L2 defaults
|
|
49
|
+
to AWS best practice recommendations, such as:
|
|
50
|
+
|
|
51
|
+
* Use of Secrets Manager for Connection JDBC strings
|
|
52
|
+
* Glue job autoscaling
|
|
53
|
+
* Default parameter values for Glue job creation
|
|
54
|
+
|
|
55
|
+
This iteration of the L2 construct introduces breaking changes to
|
|
56
|
+
the existing glue-alpha-module, but these changes streamline the developer
|
|
57
|
+
experience, introduce new constants for defaults, and replacing synth-time
|
|
58
|
+
validations with interface contracts for enforcement of the parameter combinations
|
|
59
|
+
that Glue supports. As an opinionated construct, the Glue L2 construct does
|
|
60
|
+
not allow developers to create resources that use non-current versions
|
|
61
|
+
of Glue or deprecated language dependencies (e.g. deprecated versions of Python).
|
|
62
|
+
As always, L1s allow you to specify a wider range of parameters if you need
|
|
63
|
+
or want to use alternative configurations.
|
|
64
|
+
|
|
65
|
+
Optional and required parameters for each job are enforced via interface
|
|
66
|
+
rather than validation; see [Glue's public documentation](https://docs.aws.amazon.com/glue/latest/dg/aws-glue-api.html)
|
|
67
|
+
for more granular details.
|
|
21
68
|
|
|
22
|
-
|
|
69
|
+
### Spark Jobs
|
|
23
70
|
|
|
24
|
-
|
|
71
|
+
1. **ETL Jobs**
|
|
25
72
|
|
|
26
|
-
|
|
73
|
+
ETL jobs support pySpark and Scala languages, for which there are separate but
|
|
74
|
+
similar constructors. ETL jobs default to the G2 worker type, but you can
|
|
75
|
+
override this default with other supported worker type values (G1, G2, G4
|
|
76
|
+
and G8). ETL jobs defaults to Glue version 4.0, which you can override to 3.0.
|
|
77
|
+
The following ETL features are enabled by default:
|
|
78
|
+
`—enable-metrics, —enable-spark-ui, —enable-continuous-cloudwatch-log.`
|
|
79
|
+
You can find more details about version, worker type and other features in
|
|
80
|
+
[Glue's public documentation](https://docs.aws.amazon.com/glue/latest/dg/aws-glue-api-jobs-job.html).
|
|
27
81
|
|
|
28
|
-
|
|
82
|
+
Reference the pyspark-etl-jobs.test.ts and scalaspark-etl-jobs.test.ts unit tests
|
|
83
|
+
for examples of required-only and optional job parameters when creating these
|
|
84
|
+
types of jobs.
|
|
29
85
|
|
|
30
|
-
|
|
86
|
+
For the sake of brevity, examples are shown using the pySpark job variety.
|
|
31
87
|
|
|
32
|
-
|
|
88
|
+
Example with only required parameters:
|
|
89
|
+
|
|
90
|
+
```ts
|
|
91
|
+
import * as cdk from 'aws-cdk-lib';
|
|
92
|
+
import * as iam from 'aws-cdk-lib/aws-iam';
|
|
93
|
+
declare const stack: cdk.Stack;
|
|
94
|
+
declare const role: iam.IRole;
|
|
95
|
+
declare const script: glue.Code;
|
|
96
|
+
new glue.PySparkEtlJob(stack, 'PySparkETLJob', {
|
|
97
|
+
role,
|
|
98
|
+
script,
|
|
99
|
+
jobName: 'PySparkETLJob',
|
|
100
|
+
});
|
|
101
|
+
```
|
|
33
102
|
|
|
34
|
-
|
|
103
|
+
Example with optional override parameters:
|
|
104
|
+
|
|
105
|
+
```ts
|
|
106
|
+
import * as cdk from 'aws-cdk-lib';
|
|
107
|
+
import * as iam from 'aws-cdk-lib/aws-iam';
|
|
108
|
+
declare const stack: cdk.Stack;
|
|
109
|
+
declare const role: iam.IRole;
|
|
110
|
+
declare const script: glue.Code;
|
|
111
|
+
new glue.PySparkEtlJob(stack, 'PySparkETLJob', {
|
|
112
|
+
jobName: 'PySparkETLJobCustomName',
|
|
113
|
+
description: 'This is a description',
|
|
114
|
+
role,
|
|
115
|
+
script,
|
|
116
|
+
glueVersion: glue.GlueVersion.V3_0,
|
|
117
|
+
continuousLogging: { enabled: false },
|
|
118
|
+
workerType: glue.WorkerType.G_2X,
|
|
119
|
+
maxConcurrentRuns: 100,
|
|
120
|
+
timeout: cdk.Duration.hours(2),
|
|
121
|
+
connections: [glue.Connection.fromConnectionName(stack, 'Connection', 'connectionName')],
|
|
122
|
+
securityConfiguration: glue.SecurityConfiguration.fromSecurityConfigurationName(stack, 'SecurityConfig', 'securityConfigName'),
|
|
123
|
+
tags: {
|
|
124
|
+
FirstTagName: 'FirstTagValue',
|
|
125
|
+
SecondTagName: 'SecondTagValue',
|
|
126
|
+
XTagName: 'XTagValue',
|
|
127
|
+
},
|
|
128
|
+
numberOfWorkers: 2,
|
|
129
|
+
maxRetries: 2,
|
|
130
|
+
});
|
|
131
|
+
```
|
|
35
132
|
|
|
36
|
-
|
|
133
|
+
**Streaming Jobs**
|
|
37
134
|
|
|
38
|
-
|
|
135
|
+
Streaming jobs are similar to ETL jobs, except that they perform ETL on data
|
|
136
|
+
streams using the Apache Spark Structured Streaming framework. Some Spark
|
|
137
|
+
job features are not available to Streaming ETL jobs. They support Scala
|
|
138
|
+
and pySpark languages. PySpark streaming jobs default Python 3.9,
|
|
139
|
+
which you can override with any non-deprecated version of Python. It
|
|
140
|
+
defaults to the G2 worker type and Glue 4.0, both of which you can override.
|
|
141
|
+
The following best practice features are enabled by default:
|
|
142
|
+
`—enable-metrics, —enable-spark-ui, —enable-continuous-cloudwatch-log`.
|
|
143
|
+
|
|
144
|
+
Reference the pyspark-streaming-jobs.test.ts and scalaspark-streaming-jobs.test.ts
|
|
145
|
+
unit tests for examples of required-only and optional job parameters when creating
|
|
146
|
+
these types of jobs.
|
|
147
|
+
|
|
148
|
+
Example with only required parameters:
|
|
149
|
+
|
|
150
|
+
```ts
|
|
151
|
+
import * as cdk from 'aws-cdk-lib';
|
|
152
|
+
import * as iam from 'aws-cdk-lib/aws-iam';
|
|
153
|
+
declare const stack: cdk.Stack;
|
|
154
|
+
declare const role: iam.IRole;
|
|
155
|
+
declare const script: glue.Code;
|
|
156
|
+
new glue.PySparkStreamingJob(stack, 'ImportedJob', { role, script });
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
Example with optional override parameters:
|
|
39
160
|
|
|
40
161
|
```ts
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
162
|
+
import * as cdk from 'aws-cdk-lib';
|
|
163
|
+
import * as iam from 'aws-cdk-lib/aws-iam';
|
|
164
|
+
declare const stack: cdk.Stack;
|
|
165
|
+
declare const role: iam.IRole;
|
|
166
|
+
declare const script: glue.Code;
|
|
167
|
+
new glue.PySparkStreamingJob(stack, 'PySparkStreamingJob', {
|
|
168
|
+
jobName: 'PySparkStreamingJobCustomName',
|
|
169
|
+
description: 'This is a description',
|
|
170
|
+
role,
|
|
171
|
+
script,
|
|
172
|
+
glueVersion: glue.GlueVersion.V3_0,
|
|
173
|
+
continuousLogging: { enabled: false },
|
|
174
|
+
workerType: glue.WorkerType.G_2X,
|
|
175
|
+
maxConcurrentRuns: 100,
|
|
176
|
+
timeout: cdk.Duration.hours(2),
|
|
177
|
+
connections: [glue.Connection.fromConnectionName(stack, 'Connection', 'connectionName')],
|
|
178
|
+
securityConfiguration: glue.SecurityConfiguration.fromSecurityConfigurationName(stack, 'SecurityConfig', 'securityConfigName'),
|
|
179
|
+
tags: {
|
|
180
|
+
FirstTagName: 'FirstTagValue',
|
|
181
|
+
SecondTagName: 'SecondTagValue',
|
|
182
|
+
XTagName: 'XTagValue',
|
|
183
|
+
},
|
|
184
|
+
numberOfWorkers: 2,
|
|
185
|
+
maxRetries: 2,
|
|
51
186
|
});
|
|
52
187
|
```
|
|
53
188
|
|
|
54
|
-
|
|
189
|
+
**Flex Jobs**
|
|
190
|
+
|
|
191
|
+
The flexible execution class is appropriate for non-urgent jobs such as
|
|
192
|
+
pre-production jobs, testing, and one-time data loads. Flexible jobs default
|
|
193
|
+
to Glue version 3.0 and worker type `G_2X`. The following best practice
|
|
194
|
+
features are enabled by default:
|
|
195
|
+
`—enable-metrics, —enable-spark-ui, —enable-continuous-cloudwatch-log`
|
|
55
196
|
|
|
56
|
-
|
|
197
|
+
Reference the pyspark-flex-etl-jobs.test.ts and scalaspark-flex-etl-jobs.test.ts
|
|
198
|
+
unit tests for examples of required-only and optional job parameters when creating
|
|
199
|
+
these types of jobs.
|
|
200
|
+
|
|
201
|
+
Example with only required parameters:
|
|
57
202
|
|
|
58
203
|
```ts
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
204
|
+
import * as cdk from 'aws-cdk-lib';
|
|
205
|
+
import * as iam from 'aws-cdk-lib/aws-iam';
|
|
206
|
+
declare const stack: cdk.Stack;
|
|
207
|
+
declare const role: iam.IRole;
|
|
208
|
+
declare const script: glue.Code;
|
|
209
|
+
new glue.PySparkFlexEtlJob(stack, 'ImportedJob', { role, script });
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
Example with optional override parameters:
|
|
213
|
+
|
|
214
|
+
```ts
|
|
215
|
+
import * as cdk from 'aws-cdk-lib';
|
|
216
|
+
import * as iam from 'aws-cdk-lib/aws-iam';
|
|
217
|
+
declare const stack: cdk.Stack;
|
|
218
|
+
declare const role: iam.IRole;
|
|
219
|
+
declare const script: glue.Code;
|
|
220
|
+
new glue.PySparkEtlJob(stack, 'pySparkEtlJob', {
|
|
221
|
+
jobName: 'pySparkEtlJob',
|
|
222
|
+
description: 'This is a description',
|
|
223
|
+
role,
|
|
224
|
+
script,
|
|
225
|
+
glueVersion: glue.GlueVersion.V3_0,
|
|
226
|
+
continuousLogging: { enabled: false },
|
|
227
|
+
workerType: glue.WorkerType.G_2X,
|
|
228
|
+
maxConcurrentRuns: 100,
|
|
229
|
+
timeout: cdk.Duration.hours(2),
|
|
230
|
+
connections: [glue.Connection.fromConnectionName(stack, 'Connection', 'connectionName')],
|
|
231
|
+
securityConfiguration: glue.SecurityConfiguration.fromSecurityConfigurationName(stack, 'SecurityConfig', 'securityConfigName'),
|
|
232
|
+
tags: {
|
|
233
|
+
FirstTagName: 'FirstTagValue',
|
|
234
|
+
SecondTagName: 'SecondTagValue',
|
|
235
|
+
XTagName: 'XTagValue',
|
|
236
|
+
},
|
|
237
|
+
numberOfWorkers: 2,
|
|
238
|
+
maxRetries: 2,
|
|
66
239
|
});
|
|
67
240
|
```
|
|
68
241
|
|
|
69
242
|
### Python Shell Jobs
|
|
70
243
|
|
|
71
|
-
|
|
72
|
-
|
|
244
|
+
Python shell jobs support a Python version that depends on the AWS Glue
|
|
245
|
+
version you use. These can be used to schedule and run tasks that don't
|
|
246
|
+
require an Apache Spark environment. Python shell jobs default to
|
|
247
|
+
Python 3.9 and a MaxCapacity of `0.0625`. Python 3.9 supports pre-loaded
|
|
248
|
+
analytics libraries using the `library-set=analytics` flag, which is
|
|
249
|
+
enabled by default.
|
|
250
|
+
|
|
251
|
+
Reference the pyspark-shell-job.test.ts unit tests for examples of
|
|
252
|
+
required-only and optional job parameters when creating these types of jobs.
|
|
73
253
|
|
|
74
|
-
|
|
75
|
-
* PythonVersion.THREE (3.6)
|
|
76
|
-
* PythonVersion.THREE_NINE (3.9)
|
|
254
|
+
Example with only required parameters:
|
|
77
255
|
|
|
78
256
|
```ts
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
257
|
+
import * as cdk from 'aws-cdk-lib';
|
|
258
|
+
import * as iam from 'aws-cdk-lib/aws-iam';
|
|
259
|
+
declare const stack: cdk.Stack;
|
|
260
|
+
declare const role: iam.IRole;
|
|
261
|
+
declare const script: glue.Code;
|
|
262
|
+
new glue.PythonShellJob(stack, 'ImportedJob', { role, script });
|
|
263
|
+
```
|
|
264
|
+
|
|
265
|
+
Example with optional override parameters:
|
|
266
|
+
|
|
267
|
+
```ts
|
|
268
|
+
import * as cdk from 'aws-cdk-lib';
|
|
269
|
+
import * as iam from 'aws-cdk-lib/aws-iam';
|
|
270
|
+
declare const stack: cdk.Stack;
|
|
271
|
+
declare const role: iam.IRole;
|
|
272
|
+
declare const script: glue.Code;
|
|
273
|
+
new glue.PythonShellJob(stack, 'PythonShellJob', {
|
|
274
|
+
jobName: 'PythonShellJobCustomName',
|
|
275
|
+
description: 'This is a description',
|
|
276
|
+
pythonVersion: glue.PythonVersion.TWO,
|
|
277
|
+
maxCapacity: glue.MaxCapacity.DPU_1,
|
|
278
|
+
role,
|
|
279
|
+
script,
|
|
280
|
+
glueVersion: glue.GlueVersion.V2_0,
|
|
281
|
+
continuousLogging: { enabled: false },
|
|
282
|
+
workerType: glue.WorkerType.G_2X,
|
|
283
|
+
maxConcurrentRuns: 100,
|
|
284
|
+
timeout: cdk.Duration.hours(2),
|
|
285
|
+
connections: [glue.Connection.fromConnectionName(stack, 'Connection', 'connectionName')],
|
|
286
|
+
securityConfiguration: glue.SecurityConfiguration.fromSecurityConfigurationName(stack, 'SecurityConfig', 'securityConfigName'),
|
|
287
|
+
tags: {
|
|
288
|
+
FirstTagName: 'FirstTagValue',
|
|
289
|
+
SecondTagName: 'SecondTagValue',
|
|
290
|
+
XTagName: 'XTagValue',
|
|
291
|
+
},
|
|
292
|
+
numberOfWorkers: 2,
|
|
293
|
+
maxRetries: 2,
|
|
87
294
|
});
|
|
88
295
|
```
|
|
89
296
|
|
|
90
297
|
### Ray Jobs
|
|
91
298
|
|
|
92
|
-
|
|
299
|
+
Glue Ray jobs use worker type Z.2X and Glue version 4.0. These are not
|
|
300
|
+
overrideable since these are the only configuration that Glue Ray jobs
|
|
301
|
+
currently support. The runtime defaults to Ray2.4 and min workers defaults to 3.
|
|
302
|
+
|
|
303
|
+
Reference the ray-job.test.ts unit tests for examples of required-only and
|
|
304
|
+
optional job parameters when creating these types of jobs.
|
|
305
|
+
|
|
306
|
+
Example with only required parameters:
|
|
93
307
|
|
|
94
308
|
```ts
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
}),
|
|
102
|
-
workerType: glue.WorkerType.Z_2X,
|
|
103
|
-
workerCount: 2,
|
|
104
|
-
description: 'an example Ray job'
|
|
105
|
-
});
|
|
309
|
+
import * as cdk from 'aws-cdk-lib';
|
|
310
|
+
import * as iam from 'aws-cdk-lib/aws-iam';
|
|
311
|
+
declare const stack: cdk.Stack;
|
|
312
|
+
declare const role: iam.IRole;
|
|
313
|
+
declare const script: glue.Code;
|
|
314
|
+
new glue.RayJob(stack, 'ImportedJob', { role, script });
|
|
106
315
|
```
|
|
107
316
|
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
Enable Spark UI setting the `sparkUI` property.
|
|
317
|
+
Example with optional override parameters:
|
|
111
318
|
|
|
112
319
|
```ts
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
320
|
+
import * as cdk from 'aws-cdk-lib';
|
|
321
|
+
import * as iam from 'aws-cdk-lib/aws-iam';
|
|
322
|
+
declare const stack: cdk.Stack;
|
|
323
|
+
declare const role: iam.IRole;
|
|
324
|
+
declare const script: glue.Code;
|
|
325
|
+
new glue.RayJob(stack, 'ImportedJob', {
|
|
326
|
+
role,
|
|
327
|
+
script,
|
|
328
|
+
jobName: 'RayCustomJobName',
|
|
329
|
+
description: 'This is a description',
|
|
330
|
+
workerType: glue.WorkerType.Z_2X,
|
|
331
|
+
numberOfWorkers: 5,
|
|
332
|
+
runtime: glue.Runtime.RAY_TWO_FOUR,
|
|
333
|
+
maxRetries: 3,
|
|
334
|
+
maxConcurrentRuns: 100,
|
|
335
|
+
timeout: cdk.Duration.hours(2),
|
|
336
|
+
connections: [glue.Connection.fromConnectionName(stack, 'Connection', 'connectionName')],
|
|
337
|
+
securityConfiguration: glue.SecurityConfiguration.fromSecurityConfigurationName(stack, 'SecurityConfig', 'securityConfigName'),
|
|
338
|
+
tags: {
|
|
339
|
+
FirstTagName: 'FirstTagValue',
|
|
340
|
+
SecondTagName: 'SecondTagValue',
|
|
341
|
+
XTagName: 'XTagValue',
|
|
117
342
|
},
|
|
118
|
-
executable: glue.JobExecutable.pythonEtl({
|
|
119
|
-
glueVersion: glue.GlueVersion.V3_0,
|
|
120
|
-
pythonVersion: glue.PythonVersion.THREE,
|
|
121
|
-
script: glue.Code.fromAsset(path.join(__dirname, 'job-script', 'hello_world.py')),
|
|
122
|
-
}),
|
|
123
343
|
});
|
|
124
344
|
```
|
|
125
345
|
|
|
126
|
-
The `sparkUI` property also allows the specification of an s3 bucket and a bucket prefix.
|
|
127
|
-
|
|
128
|
-
See [documentation](https://docs.aws.amazon.com/glue/latest/dg/add-job.html) for more information on adding jobs in Glue.
|
|
129
|
-
|
|
130
346
|
### Enable Job Run Queuing
|
|
131
347
|
|
|
132
348
|
AWS Glue job queuing monitors your account level quotas and limits. If quotas or limits are insufficient to start a Glue job run, AWS Glue will automatically queue the job and wait for limits to free up. Once limits become available, AWS Glue will retry the job run. Glue jobs will queue for limits like max concurrent job runs per account, max concurrent Data Processing Units (DPU), and resource unavailable due to IP address exhaustion in Amazon Virtual Private Cloud (Amazon VPC).
|
|
@@ -134,20 +350,93 @@ AWS Glue job queuing monitors your account level quotas and limits. If quotas or
|
|
|
134
350
|
Enable job run queuing by setting the `jobRunQueuingEnabled` property to `true`.
|
|
135
351
|
|
|
136
352
|
```ts
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
353
|
+
import * as cdk from 'aws-cdk-lib';
|
|
354
|
+
import * as iam from 'aws-cdk-lib/aws-iam';
|
|
355
|
+
declare const stack: cdk.Stack;
|
|
356
|
+
declare const role: iam.IRole;
|
|
357
|
+
declare const script: glue.Code;
|
|
358
|
+
new glue.PySparkEtlJob(stack, 'PySparkETLJob', {
|
|
359
|
+
role,
|
|
360
|
+
script,
|
|
361
|
+
jobName: 'PySparkETLJob',
|
|
362
|
+
jobRunQueuingEnabled: true
|
|
145
363
|
});
|
|
146
364
|
```
|
|
147
365
|
|
|
148
|
-
|
|
366
|
+
### Uploading scripts from the CDK app repository to S3
|
|
367
|
+
|
|
368
|
+
Similar to other L2 constructs, the Glue L2 automates uploading / updating
|
|
369
|
+
scripts to S3 via an optional fromAsset parameter pointing to a script
|
|
370
|
+
in the local file structure. You provide the existing S3 bucket and
|
|
371
|
+
path to which you'd like the script to be uploaded.
|
|
149
372
|
|
|
150
|
-
|
|
373
|
+
Reference the unit tests for examples of repo and S3 code target examples.
|
|
374
|
+
|
|
375
|
+
### Workflow Triggers
|
|
376
|
+
|
|
377
|
+
You can use Glue workflows to create and visualize complex
|
|
378
|
+
extract, transform, and load (ETL) activities involving multiple crawlers,
|
|
379
|
+
jobs, and triggers. Standalone triggers are an anti-pattern, so you must
|
|
380
|
+
create triggers from within a workflow using the L2 construct.
|
|
381
|
+
|
|
382
|
+
Within a workflow object, there are functions to create different
|
|
383
|
+
types of triggers with actions and predicates. You then add those triggers
|
|
384
|
+
to jobs.
|
|
385
|
+
|
|
386
|
+
StartOnCreation defaults to true for all trigger types, but you can
|
|
387
|
+
override it if you prefer for your trigger not to start on creation.
|
|
388
|
+
|
|
389
|
+
Reference the workflow-triggers.test.ts unit tests for examples of creating
|
|
390
|
+
workflows and triggers.
|
|
391
|
+
|
|
392
|
+
1. **On-Demand Triggers**
|
|
393
|
+
|
|
394
|
+
On-demand triggers can start glue jobs or crawlers. This construct provides
|
|
395
|
+
convenience functions to create on-demand crawler or job triggers. The constructor
|
|
396
|
+
takes an optional description parameter, but abstracts the requirement of an
|
|
397
|
+
actions list using the job or crawler objects using conditional types.
|
|
398
|
+
|
|
399
|
+
1. **Scheduled Triggers**
|
|
400
|
+
|
|
401
|
+
You can create scheduled triggers using cron expressions. This construct
|
|
402
|
+
provides daily, weekly, and monthly convenience functions,
|
|
403
|
+
as well as a custom function that allows you to create your own
|
|
404
|
+
custom timing using the [existing event Schedule class](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_events.Schedule.html)
|
|
405
|
+
without having to build your own cron expressions. The L2 extracts
|
|
406
|
+
the expression that Glue requires from the Schedule object. The constructor
|
|
407
|
+
takes an optional description and a list of jobs or crawlers as actions.
|
|
408
|
+
|
|
409
|
+
#### **3. Notify Event Triggers**
|
|
410
|
+
|
|
411
|
+
There are two types of notify event triggers: batching and non-batching.
|
|
412
|
+
For batching triggers, you must specify `BatchSize`. For non-batching
|
|
413
|
+
triggers, `BatchSize` defaults to 1. For both triggers, `BatchWindow`
|
|
414
|
+
defaults to 900 seconds, but you can override the window to align with
|
|
415
|
+
your workload's requirements.
|
|
416
|
+
|
|
417
|
+
#### **4. Conditional Triggers**
|
|
418
|
+
|
|
419
|
+
Conditional triggers have a predicate and actions associated with them.
|
|
420
|
+
The trigger actions are executed when the predicateCondition is true.
|
|
421
|
+
|
|
422
|
+
### Connection Properties
|
|
423
|
+
|
|
424
|
+
A `Connection` allows Glue jobs, crawlers and development endpoints to access
|
|
425
|
+
certain types of data stores.
|
|
426
|
+
|
|
427
|
+
***Secrets Management
|
|
428
|
+
**You must specify JDBC connection credentials in Secrets Manager and
|
|
429
|
+
provide the Secrets Manager Key name as a property to the job connection.
|
|
430
|
+
|
|
431
|
+
* **Networking - the CDK determines the best fit subnet for Glue connection
|
|
432
|
+
configuration
|
|
433
|
+
**The prior version of the glue-alpha-module requires the developer to
|
|
434
|
+
specify the subnet of the Connection when it’s defined. Now, you can still
|
|
435
|
+
specify the specific subnet you want to use, but are no longer required
|
|
436
|
+
to. You are only required to provide a VPC and either a public or private
|
|
437
|
+
subnet selection. Without a specific subnet provided, the L2 leverages the
|
|
438
|
+
existing [EC2 Subnet Selection](https://docs.aws.amazon.com/cdk/api/v2/python/aws_cdk.aws_ec2/SubnetSelection.html)
|
|
439
|
+
library to make the best choice selection for the subnet.
|
|
151
440
|
|
|
152
441
|
```ts
|
|
153
442
|
declare const securityGroup: ec2.SecurityGroup;
|
|
@@ -377,20 +666,20 @@ If you have a table with a large number of partitions that grows over time, cons
|
|
|
377
666
|
```ts
|
|
378
667
|
declare const myDatabase: glue.Database;
|
|
379
668
|
new glue.S3Table(this, 'MyTable', {
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
669
|
+
database: myDatabase,
|
|
670
|
+
columns: [{
|
|
671
|
+
name: 'col1',
|
|
672
|
+
type: glue.Schema.STRING,
|
|
673
|
+
}],
|
|
674
|
+
partitionKeys: [{
|
|
675
|
+
name: 'year',
|
|
676
|
+
type: glue.Schema.SMALL_INT,
|
|
677
|
+
}, {
|
|
678
|
+
name: 'month',
|
|
679
|
+
type: glue.Schema.SMALL_INT,
|
|
680
|
+
}],
|
|
681
|
+
dataFormat: glue.DataFormat.JSON,
|
|
682
|
+
enablePartitionFiltering: true,
|
|
394
683
|
});
|
|
395
684
|
```
|
|
396
685
|
|
|
@@ -488,7 +777,7 @@ new glue.S3Table(this, 'MyTable', {
|
|
|
488
777
|
declare const myDatabase: glue.Database;
|
|
489
778
|
// KMS key is created automatically
|
|
490
779
|
new glue.S3Table(this, 'MyTable', {
|
|
491
|
-
encryption: glue.TableEncryption.CLIENT_SIDE_KMS,
|
|
780
|
+
encryption: glue.TableEncryption.CLIENT_SIDE_KMS,
|
|
492
781
|
// ...
|
|
493
782
|
database: myDatabase,
|
|
494
783
|
columns: [{
|
|
@@ -546,69 +835,43 @@ new glue.S3Table(this, 'MyTable', {
|
|
|
546
835
|
// ...
|
|
547
836
|
database: myDatabase,
|
|
548
837
|
dataFormat: glue.DataFormat.JSON,
|
|
549
|
-
});
|
|
550
|
-
```
|
|
551
|
-
|
|
552
|
-
### Primitives
|
|
553
|
-
|
|
554
|
-
#### Numeric
|
|
555
|
-
|
|
556
|
-
| Name | Type | Comments |
|
|
557
|
-
|----------- |---------- |------------------------------------------------------------------------------------------------------------------ |
|
|
558
|
-
| FLOAT | Constant | A 32-bit single-precision floating point number |
|
|
559
|
-
| INTEGER | Constant | A 32-bit signed value in two's complement format, with a minimum value of -2^31 and a maximum value of 2^31-1 |
|
|
560
|
-
| DOUBLE | Constant | A 64-bit double-precision floating point number |
|
|
561
|
-
| BIG_INT | Constant | A 64-bit signed INTEGER in two’s complement format, with a minimum value of -2^63 and a maximum value of 2^63 -1 |
|
|
562
|
-
| SMALL_INT | Constant | A 16-bit signed INTEGER in two’s complement format, with a minimum value of -2^15 and a maximum value of 2^15-1 |
|
|
563
|
-
| TINY_INT | Constant | A 8-bit signed INTEGER in two’s complement format, with a minimum value of -2^7 and a maximum value of 2^7-1 |
|
|
564
|
-
|
|
565
|
-
#### Date and time
|
|
566
|
-
|
|
567
|
-
| Name | Type | Comments |
|
|
568
|
-
|----------- |---------- |------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
569
|
-
| DATE | Constant | A date in UNIX format, such as YYYY-MM-DD. |
|
|
570
|
-
| TIMESTAMP | Constant | Date and time instant in the UNiX format, such as yyyy-mm-dd hh:mm:ss[.f...]. For example, TIMESTAMP '2008-09-15 03:04:05.324'. This format uses the session time zone. |
|
|
571
|
-
|
|
572
|
-
#### String
|
|
573
|
-
|
|
574
|
-
| Name | Type | Comments |
|
|
575
|
-
|-------------------------------------------- |---------- |--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
576
|
-
| STRING | Constant | A string literal enclosed in single or double quotes |
|
|
577
|
-
| decimal(precision: number, scale?: number) | Function | `precision` is the total number of digits. `scale` (optional) is the number of digits in fractional part with a default of 0. For example, use these type definitions: decimal(11,5), decimal(15) |
|
|
578
|
-
| char(length: number) | Function | Fixed length character data, with a specified length between 1 and 255, such as char(10) |
|
|
579
|
-
| varchar(length: number) | Function | Variable length character data, with a specified length between 1 and 65535, such as varchar(10) |
|
|
580
|
-
|
|
581
|
-
#### Miscellaneous
|
|
582
|
-
|
|
583
|
-
| Name | Type | Comments |
|
|
584
|
-
|--------- |---------- |------------------------------- |
|
|
585
|
-
| BOOLEAN | Constant | Values are `true` and `false` |
|
|
586
|
-
| BINARY | Constant | Value is in binary |
|
|
587
|
-
|
|
588
|
-
### Complex
|
|
589
|
-
|
|
590
|
-
| Name | Type | Comments |
|
|
591
|
-
|------------------------------------- |---------- |------------------------------------------------------------------- |
|
|
592
|
-
| array(itemType: Type) | Function | An array of some other type |
|
|
593
|
-
| map(keyType: Type, valueType: Type) | Function | A map of some primitive key type to any value type |
|
|
594
|
-
| struct(collumns: Column[]) | Function | Nested structure containing individually named and typed collumns |
|
|
595
|
-
|
|
596
|
-
## Data Quality Ruleset
|
|
597
|
-
|
|
598
|
-
A `DataQualityRuleset` specifies a data quality ruleset with DQDL rules applied to a specified AWS Glue table. For example, to create a data quality ruleset for a given table:
|
|
599
|
-
|
|
600
|
-
```ts
|
|
601
|
-
new glue.DataQualityRuleset(this, 'MyDataQualityRuleset', {
|
|
602
|
-
clientToken: 'client_token',
|
|
603
|
-
description: 'description',
|
|
604
|
-
rulesetName: 'ruleset_name',
|
|
605
|
-
rulesetDqdl: 'ruleset_dqdl',
|
|
606
|
-
tags: {
|
|
607
|
-
key1: 'value1',
|
|
608
|
-
key2: 'value2',
|
|
609
|
-
},
|
|
610
|
-
targetTable: new glue.DataQualityTargetTable('database_name', 'table_name'),
|
|
611
|
-
});
|
|
838
|
+
});
|
|
612
839
|
```
|
|
613
840
|
|
|
614
|
-
|
|
841
|
+
## Public FAQ
|
|
842
|
+
|
|
843
|
+
### What are we launching today?
|
|
844
|
+
|
|
845
|
+
We’re launching new features to an AWS CDK Glue L2 Construct to provide
|
|
846
|
+
best-practice defaults and convenience methods to create Glue Jobs, Connections,
|
|
847
|
+
Triggers, Workflows, and the underlying permissions and configuration.
|
|
848
|
+
|
|
849
|
+
### Why should I use this Construct?
|
|
850
|
+
|
|
851
|
+
Developers should use this Construct to reduce the amount of boilerplate
|
|
852
|
+
code and complexity each individual has to navigate, and make it easier to
|
|
853
|
+
create best-practice Glue resources.
|
|
854
|
+
|
|
855
|
+
### What’s not in scope?
|
|
856
|
+
|
|
857
|
+
Glue Crawlers and other resources that are now managed by the AWS LakeFormation
|
|
858
|
+
team are not in scope for this effort. Developers should use existing methods
|
|
859
|
+
to create these resources, and the new Glue L2 construct assumes they already
|
|
860
|
+
exist as inputs. While best practice is for application and infrastructure code
|
|
861
|
+
to be as close as possible for teams using fully-implemented DevOps mechanisms,
|
|
862
|
+
in practice these ETL scripts are likely managed by a data science team who
|
|
863
|
+
know Python or Scala and don’t necessarily own or manage their own
|
|
864
|
+
infrastructure deployments. We want to meet developers where they are, and not
|
|
865
|
+
assume that all of the code resides in the same repository, Developers can
|
|
866
|
+
automate this themselves via the CDK, however, if they do own both.
|
|
867
|
+
|
|
868
|
+
Validating Glue version and feature use per AWS region at synth time is also
|
|
869
|
+
not in scope. AWS’ intention is for all features to eventually be propagated to
|
|
870
|
+
all Global regions, so the complexity involved in creating and updating region-
|
|
871
|
+
specific configuration to match shifting feature sets does not out-weigh the
|
|
872
|
+
likelihood that a developer will use this construct to deploy resources to a
|
|
873
|
+
region without a particular new feature to a region that doesn’t yet support
|
|
874
|
+
it without researching or manually attempting to use that feature before
|
|
875
|
+
developing it via IaC. The developer will, of course, still get feedback from
|
|
876
|
+
the underlying Glue APIs as CloudFormation deploys the resources similar to the
|
|
877
|
+
current CDK L1 Glue experience.
|