-
Notifications
You must be signed in to change notification settings - Fork 4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add initial FlinkApplication construct
- Loading branch information
Mitch Lloyd
committed
Jan 25, 2021
1 parent
12ef0f2
commit c99efb3
Showing
13 changed files
with
463 additions
and
266 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
AWS Cloud Development Kit (AWS CDK) | ||
Copyright 2018-2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
Copyright 2018-2021 Amazon.com, Inc. or its affiliates. All Rights Reserved. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
99 changes: 99 additions & 0 deletions
99
packages/@aws-cdk/aws-kinesisanalyticsv2/lib/application-code.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
import * as s3 from '@aws-cdk/aws-s3'; | ||
import * as s3_assets from '@aws-cdk/aws-s3-assets'; | ||
import { Construct } from '@aws-cdk/core'; | ||
|
||
export abstract class ApplicationCode { | ||
public static fromBucket(bucket: s3.IBucket, fileKey: string, objectVersion?: string): BucketApplicationCode { | ||
return new BucketApplicationCode({ | ||
bucket, | ||
fileKey, | ||
objectVersion, | ||
}); | ||
} | ||
|
||
public static fromAsset(path: string, options?: s3_assets.AssetOptions): AssetApplicationCode { | ||
return new AssetApplicationCode(path, options); | ||
} | ||
|
||
public abstract bind(scope: Construct): CodeConfiguration; | ||
} | ||
|
||
interface BucketApplicationCodeProps { | ||
bucket: s3.IBucket; | ||
fileKey: string; | ||
objectVersion?: string; | ||
} | ||
|
||
class BucketApplicationCode extends ApplicationCode { | ||
public readonly bucket: s3.IBucket; | ||
public readonly fileKey: string; | ||
public readonly objectVersion?: string; | ||
|
||
constructor(props: BucketApplicationCodeProps) { | ||
super(); | ||
this.bucket = props.bucket; | ||
this.fileKey = props.fileKey; | ||
this.objectVersion = props.objectVersion; | ||
} | ||
|
||
public bind(_scope: Construct): CodeConfiguration { | ||
return { | ||
codeContent: { | ||
s3ContentLocation: { | ||
bucketArn: this.bucket.bucketArn, | ||
fileKey: this.fileKey, | ||
objectVersion: this.objectVersion, | ||
}, | ||
}, | ||
codeContentType: 'ZIPFILE', | ||
}; | ||
} | ||
} | ||
|
||
class AssetApplicationCode extends ApplicationCode { | ||
private readonly path: string; | ||
private readonly options?: s3_assets.AssetOptions; | ||
private _asset?: s3_assets.Asset; | ||
|
||
constructor(path: string, options?: s3_assets.AssetOptions) { | ||
super(); | ||
this.path = path; | ||
this.options = options; | ||
} | ||
|
||
public bind(scope: Construct): CodeConfiguration { | ||
this._asset = new s3_assets.Asset(scope, 'Code', { | ||
path: this.path, | ||
...this.options, | ||
}); | ||
|
||
if (!this._asset.isZipArchive) { | ||
throw new Error(`Asset must be a .zip file or a directory (${this.path})`); | ||
} | ||
|
||
return { | ||
codeContent: { | ||
s3ContentLocation: { | ||
bucketArn: this._asset.bucket.bucketArn, | ||
fileKey: this._asset.s3ObjectKey, | ||
}, | ||
}, | ||
codeContentType: 'ZIPFILE', | ||
}; | ||
} | ||
|
||
get asset(): s3_assets.Asset | undefined { | ||
return this._asset; | ||
} | ||
} | ||
|
||
interface CodeConfiguration { | ||
codeContent: { | ||
s3ContentLocation: { | ||
bucketArn: string; | ||
fileKey: string; | ||
objectVersion?: string; | ||
}, | ||
}, | ||
codeContentType: 'ZIPFILE', | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,3 @@ | ||
export * from './application-code'; | ||
export * from './flink-application'; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
Oops, something went wrong.