Skip to content

Commit c40e1f7

Browse files
knihitbiffgaut
andauthored
Fix(Set outputBucket property on aws-kinesisstreams-gluejob): Issue #448 to include S3 bucket for Glue Job that the consturct creates (#452)
* update glue max allocation units to 2 * update glue max allocation units to 2 * resolving workerType and maxCapacity config related rules * resolving workerType and maxCapacity config related rules * resolving workerType and maxCapacity config related rules * removing additional lines from the file * fix snapshots for glue helper * fix snapshots for glue helper * fix snapshots for glue helper * fix snapshots for glue helper * fix snapshots for glue helper * fix snapshots for glue helper * documentation rephrase * new construct first commit with README and architecture * adding minimal deployable code to README * adding minimal deployable code to README * fix for github issue #448 Co-authored-by: nihitkas <[email protected]> Co-authored-by: biffgaut <[email protected]>
1 parent e10394d commit c40e1f7

File tree

3 files changed

+15
-6
lines changed

3 files changed

+15
-6
lines changed

source/patterns/@aws-solutions-constructs/aws-kinesisstreams-gluejob/lib/index.ts

+6-1
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,11 @@ export class KinesisstreamsToGluejob extends Construct {
126126
public readonly glueJobRole: IRole;
127127
public readonly database: glue.CfnDatabase;
128128
public readonly table: glue.CfnTable;
129+
/**
130+
* This property is only set if the Glue Job is created by the construct. If an exisiting Glue Job
131+
* configuraton is supplied, the construct does not create an S3 bucket and hence the @outputBucket
132+
* property is undefined
133+
*/
129134
public readonly outputBucket?: [Bucket, (Bucket | undefined)?];
130135
public readonly cloudwatchAlarms?: cloudwatch.Alarm[];
131136

@@ -159,7 +164,7 @@ export class KinesisstreamsToGluejob extends Construct {
159164
});
160165
}
161166

162-
[ this.glueJob, this.glueJobRole ] = defaults.buildGlueJob(this, {
167+
[ this.glueJob, this.glueJobRole, this.outputBucket ] = defaults.buildGlueJob(this, {
163168
existingCfnJob: props.existingGlueJob,
164169
glueJobProps: props.glueJobProps,
165170
table: this.table!,

source/patterns/@aws-solutions-constructs/core/lib/glue-job-helper.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ export interface BuildGlueJobProps {
7878
readonly outputDataStore?: SinkDataStoreProps
7979
}
8080

81-
export function buildGlueJob(scope: Construct, props: BuildGlueJobProps): [glue.CfnJob, IRole] {
81+
export function buildGlueJob(scope: Construct, props: BuildGlueJobProps): [glue.CfnJob, IRole, [Bucket, (Bucket | undefined)?]?] {
8282
if (!props.existingCfnJob) {
8383
if (props.glueJobProps) {
8484
if (props.glueJobProps.glueVersion === '2.0' && props.glueJobProps.maxCapacity) {
@@ -101,7 +101,7 @@ export function buildGlueJob(scope: Construct, props: BuildGlueJobProps): [glue.
101101
}
102102

103103
export function deployGlueJob(scope: Construct, glueJobProps: glue.CfnJobProps, database: glue.CfnDatabase, table: glue.CfnTable,
104-
outputDataStore: SinkDataStoreProps): [glue.CfnJob, IRole] {
104+
outputDataStore: SinkDataStoreProps): [glue.CfnJob, IRole, [Bucket, (Bucket | undefined)?]] {
105105

106106
let _glueSecurityConfigName: string;
107107

@@ -183,7 +183,7 @@ export function deployGlueJob(scope: Construct, glueJobProps: glue.CfnJobProps,
183183
_scriptBucketLocation.grantRead(_jobRole);
184184

185185
const _glueJob: glue.CfnJob = new glue.CfnJob(scope, 'KinesisETLJob', _newGlueJobProps);
186-
return [_glueJob, _jobRole];
186+
return [_glueJob, _jobRole, _outputLocation];
187187
}
188188

189189
/**

source/patterns/@aws-solutions-constructs/core/test/glue-job-helper.test.ts

+6-2
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ test('Test deployment with role creation', () => {
4242

4343
const _database = defaults.createGlueDatabase(stack, defaults.DefaultGlueDatabaseProps());
4444

45-
defaults.buildGlueJob(stack, {
45+
const _glueJob = defaults.buildGlueJob(stack, {
4646
glueJobProps: cfnJobProps,
4747
database: _database,
4848
table: defaults.createGlueTable(stack, _database, undefined, [{
@@ -52,6 +52,8 @@ test('Test deployment with role creation', () => {
5252
}], 'kinesis', {STREAM_NAME: 'testStream'})
5353
});
5454

55+
expect(_glueJob[2]?.[0]).toBeDefined();
56+
expect(_glueJob[2]?.[0]).toBeInstanceOf(Bucket);
5557
expect(stack).toHaveResourceLike('AWS::Glue::Job', {
5658
Type: "AWS::Glue::Job",
5759
Properties: {
@@ -99,7 +101,7 @@ test('Create a Glue Job outside the construct', () => {
99101

100102
const _database = defaults.createGlueDatabase(stack, defaults.DefaultGlueDatabaseProps());
101103

102-
defaults.buildGlueJob(stack, {
104+
const _glueJob = defaults.buildGlueJob(stack, {
103105
existingCfnJob: _existingCfnJob,
104106
outputDataStore: {
105107
datastoreType: defaults.SinkStoreType.S3
@@ -111,6 +113,8 @@ test('Create a Glue Job outside the construct', () => {
111113
comment: ""
112114
}], 'kinesis', {STREAM_NAME: 'testStream'})
113115
});
116+
117+
expect(_glueJob[2]).not.toBeDefined();
114118
expect(stack).toHaveResourceLike('AWS::Glue::Job', {
115119
Type: "AWS::Glue::Job",
116120
Properties: {

0 commit comments

Comments
 (0)