├── .github
└── workflows
│ └── build.yaml
├── .gitignore
├── CODE_OF_CONDUCT.md
├── CONTRIBUTING.md
├── LICENSE
├── README.md
├── THIRD-PARTY-LICENSES.txt
├── apps
├── java-datastream
│ ├── README.md
│ └── kds-to-s3-datastream-java
│ │ ├── README.md
│ │ ├── cdk-infra
│ │ ├── .gitignore
│ │ ├── README.md
│ │ ├── bin
│ │ │ └── main.ts
│ │ ├── cdk.json
│ │ ├── cfn.yaml
│ │ ├── jest.config.js
│ │ ├── lib
│ │ │ └── cdk-infra-kds-to-s3-stack.ts
│ │ ├── package.json
│ │ ├── test
│ │ │ └── cdk-infra-kda-kafka-to-s3.test.ts
│ │ └── tsconfig.json
│ │ ├── dependency-reduced-pom.xml
│ │ ├── img
│ │ ├── .$msk-kda-s3.drawio.bkp
│ │ ├── .$msk-kda-s3.drawio.dtmp
│ │ ├── kds-kda-s3.drawio
│ │ └── kds-kda-s3.png
│ │ ├── package.json
│ │ ├── pom.xml
│ │ ├── src
│ │ └── main
│ │ │ ├── java
│ │ │ └── com
│ │ │ │ └── amazonaws
│ │ │ │ └── services
│ │ │ │ └── kinesisanalytics
│ │ │ │ ├── StreamingJob.java
│ │ │ │ └── stock
│ │ │ │ ├── Stock.java
│ │ │ │ ├── StockDateBucketAssigner.java
│ │ │ │ └── StockDeserializationSchema.java
│ │ │ └── resources
│ │ │ ├── OrderSchema.avsc
│ │ │ └── log4j2.properties
│ │ └── test-create.sh
└── studio
│ ├── README.md
│ └── msk-to-studio
│ ├── README.md
│ ├── cdk-infra
│ ├── .gitignore
│ ├── CFN-README.md
│ ├── README.md
│ ├── bin
│ │ └── main.ts
│ ├── cdk.json
│ ├── jest.config.js
│ ├── lib
│ │ └── cdk-infra-kafka-to-studio-stack.ts
│ ├── package.json
│ ├── test
│ │ └── cdk-infra-kda-kafka-to-s3.test.ts
│ └── tsconfig.json
│ └── img
│ ├── .$msk-studio.drawio.bkp
│ ├── .$msk-studio.drawio.dtmp
│ ├── msk-studio.drawio
│ └── msk-studio.png
├── bootstrap-cdk
├── .gitignore
├── .npmignore
├── README.md
├── bin
│ └── main.ts
├── cdk.json
├── jest.config.js
├── lib
│ └── bootstrap-cdk-stack.ts
├── package.json
├── test
│ └── bootstrap-cdk.test.ts
└── tsconfig.json
├── cdk-infra
└── shared
│ ├── README.md
│ ├── bin
│ ├── main.d.ts
│ ├── main.js
│ └── main.ts
│ ├── cdk.json
│ ├── jest.config.js
│ ├── lambda
│ └── aws-lambda-helpers
│ │ ├── .gitignore
│ │ ├── README.md
│ │ ├── aws-lambda-helpers.iml
│ │ ├── pom.xml
│ │ └── src
│ │ ├── main
│ │ └── java
│ │ │ └── com
│ │ │ └── amazonaws
│ │ │ ├── App.java
│ │ │ ├── DataPayload.java
│ │ │ ├── MSKDataGen.java
│ │ │ ├── MSKDataGenHandler.java
│ │ │ ├── ResourceProperties.java
│ │ │ ├── Stock.java
│ │ │ └── TopicGenHandler.java
│ │ └── test
│ │ └── java
│ │ └── com
│ │ └── amazonaws
│ │ └── AppTest.java
│ ├── lib
│ ├── .gitignore
│ ├── app-start-lambda-construct.ts
│ ├── copy-assets-lambda-construct.ts
│ ├── create-studio-app-lambda-construct.ts
│ ├── flink-msk-zep-construct.ts
│ ├── kda-construct.ts
│ ├── kda-zep-construct.ts
│ ├── kds-datagen-lambda-construct.ts
│ ├── msf-java-app-construct.ts
│ ├── msk-construct.ts
│ ├── msk-get-bootstrap-broker-string.ts
│ ├── msk-serverless-construct.ts
│ ├── msk-topic-creation-lambda-construct.ts
│ └── zeppelin-note-run-lambda-construct.ts
│ ├── package.json
│ ├── test
│ ├── cdk-infra-msf-kafka-to-s3.test.d.ts
│ ├── cdk-infra-msf-kafka-to-s3.test.js
│ └── cdk-infra-msf-kafka-to-s3.test.ts
│ └── tsconfig.json
├── datagen
├── README.md
├── orders-datagen
│ ├── DATAGEN-KDS.md
│ ├── DATAGEN-MSK.md
│ ├── README.md
│ ├── kds-datagen.ipynb
│ ├── local
│ │ ├── pyflink_datagen.py
│ │ └── pyflink_kafkaread.py
│ ├── msk-iam-datagen.ipynb
│ └── msk-iam-datagen.zpln
└── stock-ticker-datagen
│ └── kds-datagen.zpln
├── img
├── blueprint-diagram.png
└── msf-icon.png
├── notes
├── contribute.md
├── installation.md
└── modify.md
└── python
├── README.md
├── lambda_copy_assets_to_s3.py
├── lambda_create_studio_app.py
├── lambda_kds_datagen.py
├── lambda_msf_app_start.py
├── lambda_run_studio_notebook
├── bundle-lambda-for-release.sh
├── cfnresponse.py
├── lambda_function.py
└── requirements.txt
├── local_kds_datagen.py
├── msf_java_app_custom_resource_handler.py
├── requirements.txt
├── test_kda_java_app_custom_resource_handler.py
└── test_lambda_kda_app_start.py
/.github/workflows/build.yaml:
--------------------------------------------------------------------------------
1 | name: Build and Release
2 |
3 | on:
4 | push:
5 | branches: [main]
6 | pull_request:
7 | branches: [main]
8 | release:
9 | types: [created]
10 |
11 | jobs:
12 | build-and-release:
13 | name: Build and Release
14 | runs-on: ubuntu-latest
15 | steps:
16 | - name: Install NodeJS
17 | uses: actions/setup-node@v3
18 | with:
19 | node-version: v18.16.1
20 |
21 | - name: Install Python
22 | uses: actions/setup-python@v4
23 | with:
24 | python-version: 3.8.16
25 |
26 | - name: Install Java
27 | uses: actions/setup-java@v3
28 | with:
29 | distribution: corretto
30 | java-version: 11
31 |
32 | - name: Install AWS CDK
33 | run: |
34 | npm install -g aws-cdk
35 |
36 | - name: Checkout source
37 | uses: actions/checkout@v2
38 |
39 | - name: Test Python modules
40 | working-directory: python
41 | run: |
42 | python -m pip install -r requirements.txt
43 | python -m pytest
44 |
45 | - name: Create artifacts directory
46 | run: |
47 | mkdir artifacts
48 |
49 | - name: Build shared assets
50 | working-directory: cdk-infra/shared
51 | run: |
52 | npm install
53 | cd lambda/aws-lambda-helpers
54 | mvn clean package shade:shade
55 | cp target/aws-lambda-helpers-1.0.jar ../../../../artifacts/
56 |
57 | - name: Build bootstrap template
58 | working-directory: bootstrap-cdk
59 | run: |
60 | npm install
61 | cdk synth -j > ../artifacts/BootstrapCdkStack.template.json
62 |
63 | - name: Build kds-to-s3-datastream-java
64 | working-directory: apps/java-datastream/kds-to-s3-datastream-java
65 | run: |
66 | mvn package
67 | cd cdk-infra
68 | npm install
69 | cdk synth -j > ../target/kds-to-s3-datastream-java.json
70 | cd ..
71 | cp target/kds-to-s3-datastream-java-1.0.1.jar ../../../artifacts/
72 | cp target/kds-to-s3-datastream-java.json ../../../artifacts/
73 |
74 | - name: Build kafka-to-studio
75 | run: |
76 | cd apps/studio/msk-to-studio/cdk-infra
77 | npm install
78 | cdk synth -j | grep -Ev '^\[Warning' > ../../../../artifacts/CdkInfraKafkaToStudioStack.template.json
79 | cd ../../../..
80 | cd python/lambda_run_studio_notebook
81 | ./bundle-lambda-for-release.sh
82 | cp my-deployment.zip ../../artifacts/
83 |
84 |
85 | - name: List artifacts
86 | working-directory: artifacts
87 | run: |
88 | ls -l
89 |
90 | - name: Publish artifacts
91 | if: github.event_name == 'release'
92 | uses: skx/github-action-publish-binaries@master
93 | env:
94 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
95 | with:
96 | args: "artifacts/*"
97 |
98 |
--------------------------------------------------------------------------------
/CODE_OF_CONDUCT.md:
--------------------------------------------------------------------------------
1 | ## Code of Conduct
2 | This project has adopted the [Amazon Open Source Code of Conduct](https://aws.github.io/code-of-conduct).
3 | For more information see the [Code of Conduct FAQ](https://aws.github.io/code-of-conduct-faq) or contact
4 | opensource-codeofconduct@amazon.com with any additional questions or comments.
5 |
--------------------------------------------------------------------------------
/CONTRIBUTING.md:
--------------------------------------------------------------------------------
1 | # Contributing Guidelines
2 |
3 | Thank you for your interest in contributing to our project. Whether it's a bug report, new feature, correction, or additional
4 | documentation, we greatly value feedback and contributions from our community.
5 |
6 | Please read through this document before submitting any issues or pull requests to ensure we have all the necessary
7 | information to effectively respond to your bug report or contribution.
8 |
9 |
10 | ## Reporting Bugs/Feature Requests
11 |
12 | We welcome you to use the GitHub issue tracker to report bugs or suggest features.
13 |
14 | When filing an issue, please check existing open, or recently closed, issues to make sure somebody else hasn't already
15 | reported the issue. Please try to include as much information as you can. Details like these are incredibly useful:
16 |
17 | * A reproducible test case or series of steps
18 | * The version of our code being used
19 | * Any modifications you've made relevant to the bug
20 | * Anything unusual about your environment or deployment
21 |
22 |
23 | ## Contributing via Pull Requests
24 | Contributions via pull requests are much appreciated. Before sending us a pull request, please ensure that:
25 |
26 | 1. You are working against the latest source on the *main* branch.
27 | 2. You check existing open, and recently merged, pull requests to make sure someone else hasn't addressed the problem already.
28 | 3. You open an issue to discuss any significant work - we would hate for your time to be wasted.
29 |
30 | To send us a pull request, please:
31 |
32 | 1. Fork the repository.
33 | 2. Modify the source; please focus on the specific change you are contributing. If you also reformat all the code, it will be hard for us to focus on your change.
34 | 3. Ensure local tests pass.
35 | 4. Commit to your fork using clear commit messages.
36 | 5. Send us a pull request, answering any default questions in the pull request interface.
37 | 6. Pay attention to any automated CI failures reported in the pull request, and stay involved in the conversation.
38 |
39 | GitHub provides additional document on [forking a repository](https://help.github.com/articles/fork-a-repo/) and
40 | [creating a pull request](https://help.github.com/articles/creating-a-pull-request/).
41 |
42 |
43 | ## Finding contributions to work on
44 | Looking at the existing issues is a great way to find something to contribute on. As our projects, by default, use the default GitHub issue labels (enhancement/bug/duplicate/help wanted/invalid/question/wontfix), looking at any 'help wanted' issues is a great place to start.
45 |
46 |
47 | ## Code of Conduct
48 | This project has adopted the [Amazon Open Source Code of Conduct](https://aws.github.io/code-of-conduct).
49 | For more information see the [Code of Conduct FAQ](https://aws.github.io/code-of-conduct-faq) or contact
50 | opensource-codeofconduct@amazon.com with any additional questions or comments.
51 |
52 |
53 | ## Security issue notifications
54 | If you discover a potential security issue in this project we ask that you notify AWS/Amazon Security via our [vulnerability reporting page](http://aws.amazon.com/security/vulnerability-reporting/). Please do **not** create a public github issue.
55 |
56 |
57 | ## Licensing
58 |
59 | See the [LICENSE](LICENSE) file for our project's licensing. We will ask you to confirm the licensing of your contribution.
60 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | Managed Service for Apache flink
2 | Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 |
2 |
Managed Service for Apache Flink Blueprints
3 |
4 |
5 |
6 | Managed Service for Apache Flink Blueprints are a curated collection of Apache Flink applications. Each blueprint will walk you through how to solve a practical problem related to stream processing using Apache Flink. These blueprints can be leveraged to create more complex applications to solve your business challenges in Apache Flink, and they are designed to be extensible. We will feature examples for both the DataStream and Table API where possible.
7 |
8 |
9 |
10 | ## Get started with Blueprints
11 |
12 | Within this repo, you will find examples of Apache Flink applications that can be run locally, on an open source Apache Flink cluster, or on Managed Service for Apache Flink cluster. Clone the repository to get started.
13 |
14 | | Description | Flink API | Language
15 | | --- | --- | --- |
16 | | **[Reading from Kinesis Data Streams and writing to Amazon S3](apps/java-datastream/kds-to-s3-datastream-java)** | DataStream | Java |
17 | | **[Reading from MSK Serverless into Managed Service for Apache Flink Studio](apps/studio/msk-to-studio/)** | Flink SQL | SQL
18 |
19 |
20 |
21 | ## Installation
22 |
23 | Follow the installation instructions [here](notes/installation.md) to install the shared libraries and begin developing.
24 |
25 | ## Contributing
26 | Have a good idea for a new Managed Service for Apache Flink Blueprint? Check out the instructions [here](notes/contribute.md) for how to contribute.
27 |
28 | ## Modifying
29 | Need to modify the blueprint for your needs? Check out the instructions [here](notes/modify.md) for more details.
--------------------------------------------------------------------------------
/apps/java-datastream/README.md:
--------------------------------------------------------------------------------
1 | # Java Datastream apps
2 |
3 | | Description |
4 | | --- |
5 | | [Reading from Kinesis Data Streams and writing to Amazon S3](./kds-to-s3-datastream-java/README.md)
--------------------------------------------------------------------------------
/apps/java-datastream/kds-to-s3-datastream-java/README.md:
--------------------------------------------------------------------------------
1 | # KDS to S3 (Java Datastream API)
2 |
3 | This blueprint deploys a MSF app that reads from Kinesis Data Streams (KDS) using IAM auth and writes to S3 using the Java DataStream API:
4 |
5 | 
6 |
7 | ## Project details
8 |
9 | 1. Flink version: `1.20.0`
10 | 2. Java version: `11`
11 |
12 | ## Key components used
13 |
14 | 1. `FlinkKinesisConsumer`.
15 | 2. `FileSink` (`StreamingFileSink` is slated to be deprecated).
16 |
17 | ## High-level deployment steps
18 |
19 | 1. Build app and copy resulting JAR to S3 location
20 | 2. Deploy associated infra (KDS and MSF) using CDK script
21 | - If using existing resources, you can simply update app properties in MSF.
22 | 3. Perform data generation
23 |
24 | ## Prerequisites
25 |
26 | 1. Maven
27 | 2. AWS SDK v2
28 | 2. AWS CDK v2 - for deploying associated infra (KDS Stream and MSF app)
29 |
30 | ## Step-by-step deployment walkthrough
31 |
32 | 1. First, let's set up some environment variables to make the deployment easier. Replace these values with your own S3 bucket, app name, etc.
33 |
34 | ```bash
35 | export AWS_PROFILE=<>
36 | export APP_NAME=<>
37 | export S3_BUCKET=<>
38 | export S3_FILE_KEY=<>
39 | ```
40 |
41 | 2. Build Java Flink application locally.
42 |
43 | From root directory of this project, run:
44 |
45 | ```
46 | mvn clean package
47 | ```
48 |
49 | 3. Copy jar to S3 so it can be referenced in CDK deployment
50 |
51 | ```bash
52 | aws s3 cp target/<> ${S3_BUCKET}/{S3_FILE_KEY}
53 | ```
54 |
55 | 4. Follow instructions in the [`cdk-infra`](cdk-infra/README.md) folder to deploy the infrastructure associated with this app - such as the source KDS stream and the Managed Service for Apache Flink application.
56 |
57 | 5. Follow instructions in [orders-datagen](../../../datagen/orders-datagen/README.md) to create topic and generate data into the source KDS stream.
58 |
59 | 6. Start your Managed Service for Apache Flink application from the AWS console.
60 |
61 | 7. Do a Flink query or S3 Select Query against S3 to view data written to S3.
62 |
63 |
64 |
65 | ## Launching via CloudFormation with pre-synthesized templates:
66 |
67 | 1. First, navigate to [the bootstrapping folder](/bootstrap-cdk/): `/bootstrap-cdk` and synthesize the template: `cdk synth`
68 | 2. Next, navigate to this blueprint's cdk-infra folder and type `cdk synth` to synthesize the template.
69 | 3. Finally, navigate to the root of the project. `/`
70 |
71 | #### Bootstrap your account (run in root of project and change variables accordingly)
72 |
73 | Copy and paste this command into a terminal in the root of the project to bootstrap the assets into your account.
74 |
75 | ```bash
76 | export timestampToLetters=$(date +%s)
77 | export BucketName=myblueprintdemoassets-${timestampToLetters}
78 | export BootstrapStackName=bootstrap-my-account-${timestampToLetters}-stack
79 | export BlueprintStackName=kds-to-s3-blueprint-${timestampToLetters}-stack
80 | export AppName=kds-to-s3-demo-${timestampToLetters}-app
81 | export StreamName=kds-to-s3-demo-${timestampToLetters}-stream
82 | export CloudWatchLogGroupName=blueprints/managed-flink/${AppName}
83 | export CloudWatchLogStreamName=managed-flink-log-stream
84 | export RoleName=kds-to-s3-demo-${timestampToLetters}-role
85 |
86 | aws cloudformation create-stack --template-body file://./bootstrap-cdk/cdk.out/BootstrapCdkStack.template.json --stack-name ${BootstrapStackName} --parameters ParameterKey=AssetBucket,ParameterValue=$BucketName ParameterKey=AssetList,ParameterValue="https://data-streaming-labs.s3.amazonaws.com/blueprint-test/kds-to-s3-datastream-java-1.0.1.jar\,https://data-streaming-labs.s3.amazonaws.com/blueprint-test/kds-to-s3-datastream-java.json" --capabilities CAPABILITY_IAM
87 | ```
88 |
89 | ### once bootstrapping finishes (in your AWS Console), then run next command from terminal:
90 |
91 | ```bash
92 | aws cloudformation create-stack --template-url https://${BucketName}.s3.amazonaws.com/kds-to-s3-datastream-java.json --stack-name $BlueprintStackName --parameters ParameterKey=AppName,ParameterValue=$AppName ParameterKey=CloudWatchLogGroupName,ParameterValue=$CloudWatchLogGroupName ParameterKey=CloudWatchLogStreamName,ParameterValue=$CloudWatchLogStreamName ParameterKey=StreamName,ParameterValue=$StreamName ParameterKey=BucketName,ParameterValue=$BucketName ParameterKey=BootstrapStackName,ParameterValue=$BootstrapStackName ParameterKey=RoleName,ParameterValue=$RoleName --capabilities CAPABILITY_NAMED_IAM
93 | ```
94 |
95 | Now the blueprint will be launched in your account.
--------------------------------------------------------------------------------
/apps/java-datastream/kds-to-s3-datastream-java/cdk-infra/.gitignore:
--------------------------------------------------------------------------------
1 | *.js
2 | !jest.config.js
3 | *.d.ts
4 | node_modules
5 |
6 | # CDK asset staging directory
7 | .cdk.staging
8 | cdk.out
9 |
--------------------------------------------------------------------------------
/apps/java-datastream/kds-to-s3-datastream-java/cdk-infra/README.md:
--------------------------------------------------------------------------------
1 | # CDK Infrastructure associated with MSK Serverless to S3 MSF blueprint (Java)
2 |
3 | This CDK script deploys the following the components:
4 |
5 | 1. VPC for MSK Serverless and Managed Service for Apache Flink application.
6 | 2. MSK Serverless.
7 | 3. Managed Service for Apache Flink Java DataStream API application.
8 | 4. IAM permissions for the role associated with the Managed Service for Apache Flink application.
9 |
10 | This CDK script expects you to supply the following *existing* resources:
11 |
12 | 1. S3 bucket where the application jar will be uploaded (`appBucket` below).
13 | 2. S3 bucket that will function as the sink (`appSinkBucket` below).
14 | 3. Glue database (`glueDatabaseName` below).
15 |
16 | ## CDK runtime context key/value pairs that need to be supplied
17 |
18 | Open up `cdk.json` and fill in appropriate values for each of these CDK context values:
19 |
20 | | Context value name | Purpose | Notes
21 | | --- | --- | --- |
22 | | `msfAppName` | The name of the Managed Service for Apache Flink application | MSF app *will be created* |
23 | | `appBucket` | The S3 bucket where the application payload will be stored | *Must be pre-existing* |
24 | | `appSinkBucket` | The bucket to which the MSK to S3 Flink app will write output files (in Parquet) | *Must be pre-existing* |
25 | | `runtimeEnvironment` | The Managed Service for Apache Flink runtime environment | For instance, `FLINK-1_15` |
26 | | `deployDataGen` | `true` if you want Zeppelin-based interactive MSF for data generation to be deployed; `false` otherwise | N/A |
27 | | `glueDatabaseName` | The AWS Glue database that will be used by MSF Studio datagen app | *Must be pre-existing* |
28 | | `msfLogGroup` | The name for the CloudWatch Log Group that will be linked to the MSF Flink app | Log group *will be created* |
29 | | `msfLogStream` | The name for the CloudWatch Log Stream that will be linked to the MSF Flink app | Log stream *will be created* |
30 | | `sourceMskClusterName` | The name for the source MSK Serverless cluster | MSK Serverless cluster *will be created* |
31 |
32 | For more information on CDK Runtime Context, please see [Runtime Context](https://docs.aws.amazon.com/cdk/v2/guide/context.html).
33 |
34 |
35 | ## Deploying the blueprint
36 |
37 | ```
38 | cdk deploy
39 | ```
40 |
41 | This will launch a CloudFormation Stack containing all the resources required for the blueprint.
42 |
43 | ## Generating a CloudFormation script using `cdk synth`:
44 |
45 | Instead of deploying directly, you could also generate an intermediate CFN script using the command below.
46 |
47 | ```
48 | cdk synth
49 | ```
50 |
51 | ## Deleting the blueprint
52 |
53 | To avoid ongoing charges, please make sure that you delete the blueprint and associated AWS resources using the following command.
54 |
55 | ```
56 | cdk destroy
57 | ```
--------------------------------------------------------------------------------
/apps/java-datastream/kds-to-s3-datastream-java/cdk-infra/bin/main.ts:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env node
2 | /*
3 | * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
4 | * Apache-2.0
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this
7 | * software and associated documentation files (the "Software"), to deal in the Software
8 | * without restriction, including without limitation the rights to use, copy, modify,
9 | * merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
10 | * permit persons to whom the Software is furnished to do so.
11 | *
12 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
13 | * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
14 | * PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
15 | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
16 | * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
17 | * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
18 | */
19 |
20 | import 'source-map-support/register';
21 | import * as cdk from 'aws-cdk-lib';
22 | import { CdkInfraKdsToS3Stack } from '../lib/cdk-infra-kds-to-s3-stack';
23 | import { BootstraplessStackSynthesizer } from 'cdk-bootstrapless-synthesizer';
24 |
25 | const app = new cdk.App();
26 |
27 | // NOTE: We're not creating a bucket to hold the application jar; we
28 | // expect there to be a pre-existing bucket. You can modify this stack
29 | // to also create a bucket instead.
30 | // Same goes for the bucket that this app will be writing to.
31 | new CdkInfraKdsToS3Stack(app, 'CdkInfraMSFKdsToS3Stack', {
32 | synthesizer: new BootstraplessStackSynthesizer({
33 | templateBucketName: 'cfn-template-bucket',
34 |
35 | fileAssetBucketName: 'file-asset-bucket-${AWS::Region}',
36 | fileAssetRegionSet: ['us-west-1', 'us-west-2'],
37 | fileAssetPrefix: 'file-asset-prefix/latest/'
38 | }),
39 | });
--------------------------------------------------------------------------------
/apps/java-datastream/kds-to-s3-datastream-java/cdk-infra/cdk.json:
--------------------------------------------------------------------------------
1 | {
2 | "app": "npx ts-node --prefer-ts-exts bin/main.ts",
3 | "watch": {
4 | "include": [
5 | "**"
6 | ],
7 | "exclude": [
8 | "README.md",
9 | "cdk*.json",
10 | "**/*.d.ts",
11 | "**/*.js",
12 | "tsconfig.json",
13 | "package*.json",
14 | "yarn.lock",
15 | "node_modules",
16 | "test"
17 | ]
18 | },
19 | "context": {
20 | "@aws-cdk/aws-apigateway:usagePlanKeyOrderInsensitiveId": true,
21 | "@aws-cdk/core:stackRelativeExports": true,
22 | "@aws-cdk/aws-rds:lowercaseDbIdentifier": true,
23 | "@aws-cdk/aws-lambda:recognizeVersionProps": true,
24 | "@aws-cdk/aws-lambda:recognizeLayerVersion": true,
25 | "@aws-cdk/aws-cloudfront:defaultSecurityPolicyTLSv1.2_2021": true,
26 | "@aws-cdk-containers/ecs-service-extensions:enableDefaultLogDriver": true,
27 | "@aws-cdk/aws-ec2:uniqueImdsv2TemplateName": true,
28 | "@aws-cdk/core:checkSecretUsage": true,
29 | "@aws-cdk/aws-iam:minimizePolicies": true,
30 | "@aws-cdk/aws-ecs:arnFormatIncludesClusterName": true,
31 | "@aws-cdk/core:validateSnapshotRemovalPolicy": true,
32 | "@aws-cdk/aws-codepipeline:crossAccountKeyAliasStackSafeResourceName": true,
33 | "@aws-cdk/aws-s3:createDefaultLoggingPolicy": true,
34 | "@aws-cdk/aws-sns-subscriptions:restrictSqsDescryption": true,
35 | "@aws-cdk/aws-apigateway:disableCloudWatchRole": true,
36 | "@aws-cdk/core:enablePartitionLiterals": true,
37 | "@aws-cdk/core:target-partitions": [
38 | "aws",
39 | "aws-cn"
40 | ],
41 | "msfAppName": "",
42 | "appBucket": "",
43 | "appFileKeyOnS3": "",
44 | "appSinkBucket": "",
45 | "runtimeEnvironment": "",
46 | "glueDatabaseName": "",
47 | "flinkVersion": "1.15.2",
48 | "RuntimeEnvironment": "1.13.2",
49 | "deployDataGen": "false",
50 | "msfLogGroup": "",
51 | "msfLogStream": "",
52 | "sourceKinesisStreamName": ""
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/apps/java-datastream/kds-to-s3-datastream-java/cdk-infra/cfn.yaml:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/awslabs/managed-service-for-apache-flink-blueprints/5c8da457d749d32069e99f2e64687613a6e099ad/apps/java-datastream/kds-to-s3-datastream-java/cdk-infra/cfn.yaml
--------------------------------------------------------------------------------
/apps/java-datastream/kds-to-s3-datastream-java/cdk-infra/jest.config.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | testEnvironment: 'node',
3 | roots: ['/test'],
4 | testMatch: ['**/*.test.ts'],
5 | transform: {
6 | '^.+\\.tsx?$': 'ts-jest'
7 | }
8 | };
9 |
--------------------------------------------------------------------------------
/apps/java-datastream/kds-to-s3-datastream-java/cdk-infra/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "cdk-infra-msf-kafka-to-s3",
3 | "version": "0.1.0",
4 | "bin": {
5 | "cdk-infra-msf-kafka-to-s3": "bin/cdk-infra-msf-kafka-to-s3.js"
6 | },
7 | "scripts": {
8 | "build": "tsc",
9 | "watch": "tsc -w",
10 | "test": "jest",
11 | "cdk": "cdk"
12 | },
13 | "devDependencies": {
14 | "@types/jest": "29.5.1",
15 | "@types/node": "18.16.0",
16 | "@types/prettier": "2.7.2",
17 | "aws-cdk": "2.76.0",
18 | "jest": "29.5.0",
19 | "ts-jest": "29.1.0",
20 | "ts-node": "10.9.1",
21 | "typescript": "5.0.4"
22 | },
23 | "dependencies": {
24 | "aws-cdk-lib": "^2.85.0",
25 | "cdk-bootstrapless-synthesizer": "^2.3.2",
26 | "constructs": "10.2.4",
27 | "source-map-support": "0.5.21"
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/apps/java-datastream/kds-to-s3-datastream-java/cdk-infra/test/cdk-infra-kda-kafka-to-s3.test.ts:
--------------------------------------------------------------------------------
1 | // import * as cdk from 'aws-cdk-lib';
2 | // import { Template } from 'aws-cdk-lib/assertions';
3 |
4 | // example test. To run these tests, uncomment this file along with the
5 | // example resource in lib/cdk-infra-msf-kafka-to-s3-stack.ts
6 | test('SQS Queue Created', () => {
7 | // const app = new cdk.App();
8 | // // WHEN
9 | // // THEN
10 | // const template = Template.fromStack(stack);
11 |
12 | // template.hasResourceProperties('AWS::SQS::Queue', {
13 | // VisibilityTimeout: 300
14 | // });
15 | });
16 |
--------------------------------------------------------------------------------
/apps/java-datastream/kds-to-s3-datastream-java/cdk-infra/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "target": "ES2018",
4 | "module": "commonjs",
5 | "lib": [
6 | "es2018"
7 | ],
8 | "declaration": true,
9 | "strict": true,
10 | "noImplicitAny": true,
11 | "strictNullChecks": true,
12 | "noImplicitThis": true,
13 | "alwaysStrict": true,
14 | "noUnusedLocals": false,
15 | "noUnusedParameters": false,
16 | "noImplicitReturns": true,
17 | "noFallthroughCasesInSwitch": false,
18 | "inlineSourceMap": true,
19 | "inlineSources": true,
20 | "experimentalDecorators": true,
21 | "strictPropertyInitialization": false,
22 | "typeRoots": [
23 | "./node_modules/@types"
24 | ]
25 | },
26 | "exclude": [
27 | "node_modules",
28 | "cdk.out"
29 | ]
30 | }
31 |
--------------------------------------------------------------------------------
/apps/java-datastream/kds-to-s3-datastream-java/dependency-reduced-pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 4.0.0
4 | com.amazonaws.services.kinesisanalytics
5 | kds-to-s3-datastream-java
6 | KDS to S3 DataStream App
7 | 1.0.1
8 |
9 |
10 |
11 |
12 | org.eclipse.m2e
13 | lifecycle-mapping
14 | 1.0.0
15 |
16 |
17 |
18 |
19 |
20 | org.apache.maven.plugins
21 | maven-shade-plugin
22 | [3.1.1,)
23 |
24 | shade
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 | org.apache.maven.plugins
34 | maven-compiler-plugin
35 | [3.1,)
36 |
37 | testCompile
38 | compile
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 | maven-compiler-plugin
54 | 3.8.0
55 |
56 | ${jdk.version}
57 | ${jdk.version}
58 |
59 |
60 |
61 | maven-shade-plugin
62 | 3.1.1
63 |
64 |
65 | package
66 |
67 | shade
68 |
69 |
70 |
71 |
72 | org.apache.flink:force-shading
73 | com.google.code.findbugs:jsr305
74 | org.slf4j:*
75 | org.apache.logging.log4j:*
76 |
77 |
78 |
79 |
80 | *:*
81 |
82 | META-INF/*.SF
83 | META-INF/*.DSA
84 | META-INF/*.RSA
85 |
86 |
87 |
88 |
89 |
90 | com.amazonaws.services.kinesisanalytics.StreamingJob
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 | false
103 |
104 |
105 | apache.snapshots
106 | Apache Development Snapshot Repository
107 | https://repository.apache.org/content/repositories/snapshots/
108 |
109 |
110 |
111 |
112 | com.amazonaws
113 | aws-kinesisanalytics-runtime
114 | 1.2.0
115 | provided
116 |
117 |
118 | org.apache.logging.log4j
119 | log4j-slf4j-impl
120 | 2.17.1
121 | runtime
122 |
123 |
124 | org.apache.logging.log4j
125 | log4j-api
126 | 2.17.1
127 | runtime
128 |
129 |
130 | org.apache.logging.log4j
131 | log4j-core
132 | 2.17.1
133 | runtime
134 |
135 |
136 |
137 | 2.12
138 | 1.12.2
139 | 1.11
140 | 2.13.4.2
141 | 2.13.4
142 | 1.15.4
143 | 2.4.1
144 | 1.11
145 | UTF-8
146 | 1.9.2
147 | 2.17.1
148 | 2.0.0
149 | 1.11
150 | 11
151 | 1.2.0
152 |
153 |
154 |
--------------------------------------------------------------------------------
/apps/java-datastream/kds-to-s3-datastream-java/img/.$msk-kda-s3.drawio.bkp:
--------------------------------------------------------------------------------
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 |
--------------------------------------------------------------------------------
/apps/java-datastream/kds-to-s3-datastream-java/img/.$msk-kda-s3.drawio.dtmp:
--------------------------------------------------------------------------------
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 |
--------------------------------------------------------------------------------
/apps/java-datastream/kds-to-s3-datastream-java/img/kds-kda-s3.drawio:
--------------------------------------------------------------------------------
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 |
--------------------------------------------------------------------------------
/apps/java-datastream/kds-to-s3-datastream-java/img/kds-kda-s3.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/awslabs/managed-service-for-apache-flink-blueprints/5c8da457d749d32069e99f2e64687613a6e099ad/apps/java-datastream/kds-to-s3-datastream-java/img/kds-kda-s3.png
--------------------------------------------------------------------------------
/apps/java-datastream/kds-to-s3-datastream-java/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "devDependencies": {
3 | "ts-node": "10.9.1",
4 | "typescript": "4.9.5"
5 | },
6 | "dependencies": {
7 | "aws-cdk": "2.64"
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/apps/java-datastream/kds-to-s3-datastream-java/src/main/java/com/amazonaws/services/kinesisanalytics/stock/Stock.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3 | * Apache-2.0
4 | *
5 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this
6 | * software and associated documentation files (the "Software"), to deal in the Software
7 | * without restriction, including without limitation the rights to use, copy, modify,
8 | * merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
9 | * permit persons to whom the Software is furnished to do so.
10 | *
11 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
12 | * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
13 | * PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
14 | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
15 | * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
16 | * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
17 | */
18 |
19 | package com.amazonaws.services.kinesisanalytics.stock;
20 |
21 | import java.util.Objects;
22 |
23 | public class Stock {
24 |
25 | private String event_time;
26 | private String ticker;
27 | private float price;
28 |
29 | public Stock() {}
30 |
31 | public void setEvent_time(String event_time) {
32 | this.event_time = event_time;
33 | }
34 |
35 | public String getEvent_time() {
36 | return this.event_time;
37 | }
38 |
39 | public void setTicker(String ticker) {
40 | this.ticker = ticker;
41 | }
42 |
43 | public String getTicker() {
44 | return this.ticker;
45 | }
46 |
47 | public void setPrice(float price) {
48 | this.price = price;
49 | }
50 |
51 | public float getPrice() {
52 | return this.price;
53 | }
54 |
55 | @Override
56 | public String toString() {
57 | return "Stock{" + "ticker=" + ticker + ", price='" + price + '\'' + ", time=" + event_time + '}';
58 | }
59 |
60 | @Override
61 | public boolean equals(Object o) {
62 | if (this == o) {
63 | return true;
64 | }
65 | if (o == null || getClass() != o.getClass()) {
66 | return false;
67 | }
68 | Stock stock = (Stock) o;
69 | return ticker.equals(stock.ticker) &&
70 | price == stock.price &&
71 | event_time.equals(stock.event_time);
72 | }
73 |
74 | @Override
75 | public int hashCode() {
76 | return Objects.hash(ticker, price, event_time);
77 | }
78 | }
79 |
--------------------------------------------------------------------------------
/apps/java-datastream/kds-to-s3-datastream-java/src/main/java/com/amazonaws/services/kinesisanalytics/stock/StockDateBucketAssigner.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3 | * Apache-2.0
4 | *
5 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this
6 | * software and associated documentation files (the "Software"), to deal in the Software
7 | * without restriction, including without limitation the rights to use, copy, modify,
8 | * merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
9 | * permit persons to whom the Software is furnished to do so.
10 | *
11 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
12 | * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
13 | * PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
14 | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
15 | * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
16 | * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
17 | */
18 |
19 | package com.amazonaws.services.kinesisanalytics.stock;
20 |
21 | import org.apache.flink.core.io.SimpleVersionedSerializer;
22 | import org.apache.flink.streaming.api.functions.sink.filesystem.BucketAssigner;
23 | import org.apache.flink.streaming.api.functions.sink.filesystem.bucketassigners.SimpleVersionedStringSerializer;
24 |
25 | import java.time.LocalDateTime;
26 | import java.time.format.DateTimeFormatter;
27 |
28 | public class StockDateBucketAssigner implements BucketAssigner {
29 | private final String prefix;
30 | private final String partitionFormat;
31 | private transient DateTimeFormatter dtFormatForWrite;
32 |
33 | public StockDateBucketAssigner(String partitionFormat, String prefix) {
34 | this.prefix = prefix;
35 | this.partitionFormat = partitionFormat;
36 | }
37 |
38 | @Override
39 | public String getBucketId(Stock stock, Context context) {
40 | this.dtFormatForWrite = DateTimeFormatter.ofPattern(partitionFormat);
41 |
42 | String eventTimeStr = stock.getEvent_time();
43 | LocalDateTime eventTime = LocalDateTime.parse(eventTimeStr.replace(" ", "T"));
44 |
45 | String formattedDate = eventTime.format(this.dtFormatForWrite);
46 |
47 | return String.format("%sts=%s",
48 | prefix,
49 | formattedDate
50 | );
51 | }
52 |
53 | @Override
54 | public SimpleVersionedSerializer getSerializer() {
55 | return SimpleVersionedStringSerializer.INSTANCE;
56 | }
57 | }
--------------------------------------------------------------------------------
/apps/java-datastream/kds-to-s3-datastream-java/src/main/java/com/amazonaws/services/kinesisanalytics/stock/StockDeserializationSchema.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3 | * Apache-2.0
4 | *
5 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this
6 | * software and associated documentation files (the "Software"), to deal in the Software
7 | * without restriction, including without limitation the rights to use, copy, modify,
8 | * merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
9 | * permit persons to whom the Software is furnished to do so.
10 | *
11 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
12 | * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
13 | * PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
14 | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
15 | * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
16 | * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
17 | */
18 |
19 | package com.amazonaws.services.kinesisanalytics.stock;
20 |
21 | import com.fasterxml.jackson.databind.ObjectMapper;
22 | import com.fasterxml.jackson.databind.json.JsonMapper;
23 | import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
24 | import org.apache.flink.api.common.serialization.AbstractDeserializationSchema;
25 |
26 | import java.io.IOException;
27 |
28 | public class StockDeserializationSchema extends AbstractDeserializationSchema {
29 | private static final long serialVersionUID = 1L;
30 |
31 | private transient ObjectMapper objectMapper;
32 |
33 | @Override
34 | public void open(InitializationContext context) {
35 | objectMapper = JsonMapper.builder().build().registerModule(new JavaTimeModule());
36 | }
37 |
38 | @Override
39 | public Stock deserialize(byte[] bytes) throws IOException {
40 | return objectMapper.readValue(bytes, Stock.class);
41 | }
42 | } // class
--------------------------------------------------------------------------------
/apps/java-datastream/kds-to-s3-datastream-java/src/main/resources/OrderSchema.avsc:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3 |
4 | Permission is hereby granted, free of charge, to any person obtaining a copy of
5 | this software and associated documentation files (the "Software"), to deal in
6 | the Software without restriction, including without limitation the rights to
7 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
8 | the Software, and to permit persons to whom the Software is furnished to do so.
9 |
10 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
11 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
12 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
13 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
14 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
15 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
16 | */
17 | {
18 | "name": "Order",
19 | "namespace": "com.amazonaws.services.kinesisanalytics.orders",
20 | "type": "record",
21 | "fields": [
22 | {
23 | "name": "product_id",
24 | "type": "long"
25 | },
26 | {
27 | "name": "order_number",
28 | "type": "long"
29 | },
30 | {
31 | "name": "quantity",
32 | "type": "int"
33 | },
34 | {
35 | "name": "price",
36 | "type": "double"
37 | },
38 | {
39 | "name": "buyer",
40 | "type": "string"
41 | },
42 | {
43 | "name": "order_time",
44 | "type": "string"
45 | }
46 | ]
47 | }
48 |
--------------------------------------------------------------------------------
/apps/java-datastream/kds-to-s3-datastream-java/src/main/resources/log4j2.properties:
--------------------------------------------------------------------------------
1 | ################################################################################
2 | # Licensed to the Apache Software Foundation (ASF) under one
3 | # or more contributor license agreements. See the NOTICE file
4 | # distributed with this work for additional information
5 | # regarding copyright ownership. The ASF licenses this file
6 | # to you under the Apache License, Version 2.0 (the
7 | # "License"); you may not use this file except in compliance
8 | # with the License. You may obtain a copy of the License at
9 | #
10 | # http://www.apache.org/licenses/LICENSE-2.0
11 | #
12 | # Unless required by applicable law or agreed to in writing, software
13 | # distributed under the License is distributed on an "AS IS" BASIS,
14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | # See the License for the specific language governing permissions and
16 | # limitations under the License.
17 | ################################################################################
18 |
19 | rootLogger.level = INFO
20 | rootLogger.appenderRef.console.ref = ConsoleAppender
21 |
22 | appender.console.name = ConsoleAppender
23 | appender.console.type = CONSOLE
24 | appender.console.layout.type = PatternLayout
25 | appender.console.layout.pattern = %d{HH:mm:ss,SSS} %-5p %-60c %x - %m%n
26 |
--------------------------------------------------------------------------------
/apps/java-datastream/kds-to-s3-datastream-java/test-create.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | set -x
4 |
5 | AWS_ACCOUNT_ID=$(aws sts get-caller-identity) | jq -r ".Account"
6 | AWS_REGION=$(aws configure get region)
7 | BUCKET_NAME="msf-blueprints-kds-to-s3-${AWS_ACCOUNT_ID}-${AWS_REGION}"
8 | APP_NAME=kds-to-s3-datastream-java
9 | JAR_FILE=$APP_NAME-1.0.1.jar
10 |
11 | # Create required S3 buckets if they don't already exist
12 | # Buckets are created in the default region. Use AWS_REGION
13 | # environment variable to change where they are created.
14 | aws s3api head-bucket --bucket $BUCKET_NAME --region $AWS_REGION >/dev/null 2>&1
15 | if [ $? -ne 0 ]; then
16 | aws s3api create-bucket --bucket $BUCKET_NAME --region $AWS_REGION --create-bucket-configuration LocationConstraint=$AWS_REGION | cat
17 | fi
18 |
19 |
20 | # After this point any failure should stop execution
21 | set -e
22 |
23 | # Build Flink app
24 | mvn clean
25 | mvn package
26 |
27 | # Build CFN
28 | cd cdk-infra
29 | cdk synth -j > ../target/$APP_NAME.json
30 | cd ..
31 |
32 | # Upload artifacts
33 | aws s3 cp target/$JAR_FILE s3://$BUCKET_NAME/$JAR_FILE
34 |
35 | # Create CFN stack
36 | aws cloudformation deploy --stack-name $APP_NAME --parameter-overrides "AppName=${APP_NAME}" "BucketName=${BUCKET_NAME}" "StreamName=${APP_NAME}" "RoleName=${APP_NAME}" "GlueDatabaseName=default" "CloudWatchLogGroupName=blueprints/msf/${APP_NAME}" "CloudWatchLogStreamName=log-stream-${APP_NAME}" "BootstrapStackName=test-script" --capabilities CAPABILITY_NAMED_IAM --template-file target/$APP_NAME.json
37 |
--------------------------------------------------------------------------------
/apps/studio/README.md:
--------------------------------------------------------------------------------
1 | # Studio apps
2 |
3 | | Description |
4 | | --- |
5 | | [Reading from MSK Serverless using Studio](msk-to-studio/README.md) |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/apps/studio/msk-to-studio/README.md:
--------------------------------------------------------------------------------
1 | # MSK to Studio
2 |
3 | This blueprint deploys a Studio app that reads from MSK Serverless using IAM auth using the Table API:
4 |
5 | 
6 |
7 | ## Project details
8 |
9 | 1. Flink version: `1.15.2`
10 | 2. Python version: `3.8`
11 |
12 | ## Key components used
13 |
14 | 1. New (in Flink 1.13) `KafkaSource` connector (`FlinkKafkaSource` is slated to be deprecated).
15 |
16 | ## High-level deployment steps
17 |
18 | 1. Deploy associated infra (MSK and MSF Studio) using CDK script
19 | 2. Run Studio query to read from MSK topic
20 |
21 | ## Prerequisites
22 |
23 | 1. Maven
24 | 2. AWS SDK v2
25 | 2. AWS CDK v2 - for deploying associated infra (MSK and MSF app)
26 |
27 | ## Step-by-step deployment walkthrough
28 |
29 | 1. First, let's set up some environment variables to make the deployment easier. Replace these values with your own S3 bucket, app name, etc.
30 |
31 | ```bash
32 | export AWS_PROFILE=<>
33 | export APP_NAME=<>
34 | ```
35 |
36 | 2. Follow instructions in the [`cdk-infra`](cdk-infra/README.md) folder to *deploy* the infrastructure associated with this app - such as MSK Serverless and the Managed Service for Apache Flink Studio application.
37 |
38 | 3. Start your Managed Service for Apache Flink Studio application from the AWS console.
39 |
40 | 4. Run Flink SQL query in Studio notebook to read from MSK topic.
41 |
42 |
43 | ## Launching via CloudFormation with pre-synthesized templates:
44 |
45 | 1. First, navigate to [the bootstrapping folder](/bootstrap-cdk/): `/bootstrap-cdk` and synthesize the template: `cdk synth`
46 | 2. Next, navigate to this blueprint's cdk-infra folder and type `cdk synth` to synthesize the template.
47 | 3. Finally, navigate to the root of the project. `/`
48 |
49 | #### Bootstrap your account (run in root of project and change variables accordingly)
50 |
51 | Copy and paste this command into a terminal in the root of the project to bootstrap the assets into your account.
52 |
53 |
54 | ```bash
55 | export timestampToLetters=$(date +%s)
56 | export BucketName=myblueprintdemoassets-${timestampToLetters}
57 | export BootstrapStackName=bootstrap-my-account-${timestampToLetters}-stack
58 | export BlueprintStackName=studio-demo-msk-studio-blueprint-${timestampToLetters}-stack
59 | export AppName=studio-demo-${timestampToLetters}-app
60 | export ClusterName=studio-demo-${timestampToLetters}-cluster
61 | export GlueDatabaseName=studio_demo_${timestampToLetters}_db
62 | export CloudWatchLogGroupName=blueprints/managed-flink/${AppName}
63 | export CloudWatchLogStreamName=managed-flink-log-stream
64 | export RoleName=studio-demo-${timestampToLetters}-role
65 | export RuntimeEnvironment=ZEPPELIN-FLINK-3_0
66 |
67 | aws cloudformation create-stack --template-body file://./bootstrap-cdk/cdk.out/BootstrapCdkStack.template.json --stack-name ${BootstrapStackName} --parameters ParameterKey=AssetBucket,ParameterValue=$BucketName ParameterKey=AssetList,ParameterValue="https://data-streaming-labs.s3.amazonaws.com/blueprint-test/aws-lambda-helpers-1.0.jar\,https://data-streaming-labs.s3.amazonaws.com/blueprint-test/CdkInfraKafkaToStudioStack.template.json\,https://data-streaming-labs.s3.amazonaws.com/blueprint-test/my-deployment.zip" --capabilities CAPABILITY_IAM
68 | ```
69 |
70 | ### once bootstrapping finishes (in your AWS Console), then run next command from terminal:
71 |
72 | ```bash
73 | aws cloudformation create-stack --template-url https://${BucketName}.s3.amazonaws.com/CdkInfraKafkaToStudioStack.template.json --stack-name $BlueprintStackName --parameters ParameterKey=AppName,ParameterValue=$AppName ParameterKey=GlueDatabaseName,ParameterValue=$GlueDatabaseName ParameterKey=RuntimeEnvironment,ParameterValue=$RuntimeEnvironment ParameterKey=CloudWatchLogGroupName,ParameterValue=$CloudWatchLogGroupName ParameterKey=CloudWatchLogStreamName,ParameterValue=$CloudWatchLogStreamName ParameterKey=ClusterName,ParameterValue=$ClusterName ParameterKey=BucketName,ParameterValue=$BucketName ParameterKey=RoleName,ParameterValue=$RoleName ParameterKey=BootstrapStackName,ParameterValue=$BootstrapStackName --capabilities CAPABILITY_NAMED_IAM --disable-rollback
74 | ```
75 |
76 | Now the blueprint will be launched in your account.
--------------------------------------------------------------------------------
/apps/studio/msk-to-studio/cdk-infra/.gitignore:
--------------------------------------------------------------------------------
1 | *.js
2 | !jest.config.js
3 | *.d.ts
4 | node_modules
5 |
6 | # CDK asset staging directory
7 | .cdk.staging
8 | cdk.out
9 |
--------------------------------------------------------------------------------
/apps/studio/msk-to-studio/cdk-infra/CFN-README.md:
--------------------------------------------------------------------------------
1 | # Steps for deploying CFN
2 |
3 | 1. Deploy `bootstrap-template.yaml`
4 | 2. Copy `zip` and `jar` files to shared S3 bucket
5 | 3. Deploy `out.yaml` w/ all params supplied. Note `lambdaZipsS3Bucket`: this is the name of the bucket where the zip and jar files are expected to be.
--------------------------------------------------------------------------------
/apps/studio/msk-to-studio/cdk-infra/README.md:
--------------------------------------------------------------------------------
1 | # CDK Infrastructure associated with MSK Serverless to S3 MSF blueprint (Java)
2 |
3 | This CDK script deploys the following the components:
4 |
5 | 1. VPC for MSK Serverless and Managed Service for Apache Flinkapplication.
6 | 2. MSK Serverless.
7 | 3. Managed Service for Apache Flink Java DataStream API application.
8 | 4. IAM permissions for the role associated with the Managed Service for Apache Flink application.
9 |
10 | This CDK script expects you to supply the following *existing* resources:
11 |
12 | 1. S3 bucket where the application jar will be uploaded (`appBucket` below).
13 | 2. S3 bucket that will function as the sink (`appSinkBucket` below).
14 | 3. Glue database (`glueDatabaseName` below).
15 |
16 | ## CDK runtime context key/value pairs that need to be supplied
17 |
18 | Open up `cdk.json` and fill in appropriate values for each of these CDK context values:
19 |
20 | | Context value name | Purpose | Notes
21 | | --- | --- | --- |
22 | | `msfAppName` | The name of the Managed Service for Apache Flink application | MSF app *will be created* |
23 | | `appBucket` | The S3 bucket where the application payload will be stored | *Must be pre-existing* |
24 | | `appSinkBucket` | The bucket to which the MSK to S3 Flink app will write output files (in Parquet) | *Must be pre-existing* |
25 | | `runtimeEnvironment` | The Managed Service for Apache Flink runtime environment | For instance, `FLINK-1_15` |
26 | | `deployDataGen` | `true` if you want Zeppelin-based interactive MSF for data generation to be deployed; `false` otherwise | N/A |
27 | | `glueDatabaseName` | The AWS Glue database that will be used by MSF Studio datagen app | *Must be pre-existing* |
28 | | `msfLogGroup` | The name for the CloudWatch Log Group that will be linked to the MSF Flink app | Log group *will be created* |
29 | | `msfLogStream` | The name for the CloudWatch Log Stream that will be linked to the MSF Flink app | Log stream *will be created* |
30 | | `sourceMskClusterName` | The name for the source MSK Serverless cluster | MSK Serverless cluster *will be created* |
31 |
32 | For more information on CDK Runtime Context, please see [Runtime Context](https://docs.aws.amazon.com/cdk/v2/guide/context.html).
33 |
34 |
35 | ## Deploying the blueprint
36 |
37 | ```
38 | cdk deploy
39 | ```
40 |
41 | This will launch a CloudFormation Stack containing all the resources required for the blueprint.
42 |
43 | ## Generating a CloudFormation script using `cdk synth`:
44 |
45 | Instead of deploying directly, you could also generate an intermediate CFN script using the command below.
46 |
47 | ```
48 | cdk synth
49 | ```
50 |
51 | ## Deleting the blueprint
52 |
53 | To avoid ongoing charges, please make sure that you delete the blueprint and associated AWS resources using the following command.
54 |
55 | ```
56 | cdk destroy
57 | ```
--------------------------------------------------------------------------------
/apps/studio/msk-to-studio/cdk-infra/bin/main.ts:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env node
2 | /*
3 | * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
4 | * Apache-2.0
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this
7 | * software and associated documentation files (the "Software"), to deal in the Software
8 | * without restriction, including without limitation the rights to use, copy, modify,
9 | * merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
10 | * permit persons to whom the Software is furnished to do so.
11 | *
12 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
13 | * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
14 | * PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
15 | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
16 | * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
17 | * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
18 | */
19 |
20 | import 'source-map-support/register';
21 | import * as cdk from 'aws-cdk-lib';
22 | import { CdkInfraKafkaToStudioStack } from '../lib/cdk-infra-kafka-to-studio-stack';
23 | import { BootstraplessStackSynthesizer } from 'cdk-bootstrapless-synthesizer';
24 |
25 |
26 | const app = new cdk.App();
27 |
28 | const studioAppName = app.node.tryGetContext('studioAppName');
29 | const glueDatabaseName = app.node.tryGetContext('glueDatabaseName');
30 | const RuntimeEnvironment = app.node.tryGetContext('RuntimeEnvironment');
31 | const msfLogGroup = app.node.tryGetContext('msfLogGroup');
32 | const studioLogStream = app.node.tryGetContext('studioLogStream');
33 | const mskClusterName = app.node.tryGetContext('mskClusterName');
34 | const SourceTopicName = app.node.tryGetContext('SourceTopicName');
35 | const blueprintName = "MSK_STUDIO";
36 |
37 | // NOTE: We're not creating a bucket to hold the application jar; we
38 | // expect there to be a pre-existing bucket. You can modify this stack
39 | // to also create a bucket instead.
40 | // Same goes for the bucket that this app will be writing to.
41 | new CdkInfraKafkaToStudioStack(app, 'CdkInfraKafkaToStudioStack', {
42 | synthesizer: new BootstraplessStackSynthesizer({
43 | templateBucketName: 'cfn-template-bucket',
44 |
45 | fileAssetBucketName: 'file-asset-bucket-${AWS::Region}',
46 | fileAssetRegionSet: ['us-west-1', 'us-west-2'],
47 | fileAssetPrefix: 'file-asset-prefix/latest/'
48 | }),
49 | studioAppName: studioAppName,
50 | glueDatabaseName: glueDatabaseName,
51 | RuntimeEnvironment: RuntimeEnvironment,
52 | msfLogGroup: msfLogGroup,
53 | studioLogStream: studioLogStream,
54 | mskClusterName: mskClusterName,
55 | SourceTopicName: SourceTopicName,
56 | blueprintName: blueprintName,
57 | });
--------------------------------------------------------------------------------
/apps/studio/msk-to-studio/cdk-infra/cdk.json:
--------------------------------------------------------------------------------
1 | {
2 | "app": "npx ts-node --prefer-ts-exts bin/main.ts",
3 | "watch": {
4 | "include": [
5 | "**"
6 | ],
7 | "exclude": [
8 | "README.md",
9 | "cdk*.json",
10 | "**/*.d.ts",
11 | "**/*.js",
12 | "tsconfig.json",
13 | "package*.json",
14 | "yarn.lock",
15 | "node_modules",
16 | "test"
17 | ]
18 | },
19 | "context": {
20 | "@aws-cdk/aws-apigateway:usagePlanKeyOrderInsensitiveId": true,
21 | "@aws-cdk/core:stackRelativeExports": true,
22 | "@aws-cdk/aws-rds:lowercaseDbIdentifier": true,
23 | "@aws-cdk/aws-lambda:recognizeVersionProps": true,
24 | "@aws-cdk/aws-lambda:recognizeLayerVersion": true,
25 | "@aws-cdk/aws-cloudfront:defaultSecurityPolicyTLSv1.2_2021": true,
26 | "@aws-cdk-containers/ecs-service-extensions:enableDefaultLogDriver": true,
27 | "@aws-cdk/aws-ec2:uniqueImdsv2TemplateName": true,
28 | "@aws-cdk/core:checkSecretUsage": true,
29 | "@aws-cdk/aws-iam:minimizePolicies": true,
30 | "@aws-cdk/aws-ecs:arnFormatIncludesClusterName": true,
31 | "@aws-cdk/core:validateSnapshotRemovalPolicy": true,
32 | "@aws-cdk/aws-codepipeline:crossAccountKeyAliasStackSafeResourceName": true,
33 | "@aws-cdk/aws-s3:createDefaultLoggingPolicy": true,
34 | "@aws-cdk/aws-sns-subscriptions:restrictSqsDescryption": true,
35 | "@aws-cdk/aws-apigateway:disableCloudWatchRole": true,
36 | "@aws-cdk/core:enablePartitionLiterals": true,
37 | "@aws-cdk/core:target-partitions": [
38 | "aws",
39 | "aws-cn"
40 | ],
41 | "studioAppName": "abc123",
42 | "runtimeEnvironment": "abc123",
43 | "glueDatabaseName": "abc123",
44 | "RuntimeEnvironment": "ZEPPELIN-FLINK-3_0",
45 | "msfLogGroup": "abc123",
46 | "studioLogStream": "abc123",
47 | "mskClusterName": "abc123",
48 | "SourceTopicName": "sourceTopic"
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/apps/studio/msk-to-studio/cdk-infra/jest.config.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | testEnvironment: 'node',
3 | roots: ['/test'],
4 | testMatch: ['**/*.test.ts'],
5 | transform: {
6 | '^.+\\.tsx?$': 'ts-jest'
7 | }
8 | };
9 |
--------------------------------------------------------------------------------
/apps/studio/msk-to-studio/cdk-infra/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "cdk-infra-msf-kafka-to-s3",
3 | "version": "0.1.0",
4 | "bin": {
5 | "cdk-infra-msf-kafka-to-s3": "bin/cdk-infra-msf-kafka-to-s3.js"
6 | },
7 | "scripts": {
8 | "build": "tsc",
9 | "watch": "tsc -w",
10 | "test": "jest",
11 | "cdk": "cdk"
12 | },
13 | "devDependencies": {
14 | "@types/jest": "29.5.1",
15 | "@types/node": "18.16.0",
16 | "@types/prettier": "2.7.2",
17 | "aws-cdk": "2.76.0",
18 | "jest": "29.5.0",
19 | "ts-jest": "29.1.0",
20 | "ts-node": "10.9.1",
21 | "typescript": "5.0.4"
22 | },
23 | "dependencies": {
24 | "aws-cdk-lib": "2.85.0",
25 | "constructs": "10.2.4",
26 | "source-map-support": "0.5.21",
27 | "cdk-bootstrapless-synthesizer": "^2.3.2"
28 |
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/apps/studio/msk-to-studio/cdk-infra/test/cdk-infra-kda-kafka-to-s3.test.ts:
--------------------------------------------------------------------------------
1 | // import * as cdk from 'aws-cdk-lib';
2 | // import { Template } from 'aws-cdk-lib/assertions';
3 |
4 | // example test. To run these tests, uncomment this file along with the
5 | // example resource in lib/cdk-infra-msf-kafka-to-s3-stack.ts
6 | test('SQS Queue Created', () => {
7 | // const app = new cdk.App();
8 | // // WHEN
9 | // // THEN
10 | // const template = Template.fromStack(stack);
11 |
12 | // template.hasResourceProperties('AWS::SQS::Queue', {
13 | // VisibilityTimeout: 300
14 | // });
15 | });
16 |
--------------------------------------------------------------------------------
/apps/studio/msk-to-studio/cdk-infra/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "target": "ES2018",
4 | "module": "commonjs",
5 | "lib": [
6 | "es2018"
7 | ],
8 | "declaration": true,
9 | "strict": true,
10 | "noImplicitAny": true,
11 | "strictNullChecks": true,
12 | "noImplicitThis": true,
13 | "alwaysStrict": true,
14 | "noUnusedLocals": false,
15 | "noUnusedParameters": false,
16 | "noImplicitReturns": true,
17 | "noFallthroughCasesInSwitch": false,
18 | "inlineSourceMap": true,
19 | "inlineSources": true,
20 | "experimentalDecorators": true,
21 | "strictPropertyInitialization": false,
22 | "typeRoots": [
23 | "./node_modules/@types"
24 | ]
25 | },
26 | "exclude": [
27 | "node_modules",
28 | "cdk.out"
29 | ]
30 | }
31 |
--------------------------------------------------------------------------------
/apps/studio/msk-to-studio/img/.$msk-studio.drawio.bkp:
--------------------------------------------------------------------------------
1 | 7VjbctowEP0aHpvxFchjbCBNk87Q0mnTJ4+wha0gW44swO7Xd2XLYGOH0A4PaScJjLVHq9VqL0fAwHTj/JajNPrMAkwHhhbkA3MyMAxdM4bwkEhRISPLrICQk6CCtAOwIL9wvVKhGxLgTGEVJBijgqRt0GdJgn3RwhDnbNdWWzEatIAUhbgDLHxEu+gPEoioQse2dsA/YhJG9c66pmZiVCsrIItQwHYNyJwOTJczJqpRnLuYyuC14zJ7YXbvGMeJOGeBvfz2dfb8ZTrTnc2dcEbPiWt9UFa2iG7Ugb/PXeWvKOogZGssfHkabWA6bCMoSbC7D7gEQ44CAo64jDIOWMISWOtEIqYg6TDcRUTgRYp8aXMHxQLYiiVCpVw3alltK61CyFI5jvNQVtcV2mXWVcjZJi23vIOk985629SXywVna1y7NDDM8ehavx7KjQilR65uMRcE8n5DSSitCiY3QUqieCWkRfCfJOFDKU1MTfnct0WAsggH6iDdXNWBh11x3oBU7m4xi7HgBaio2bEqo6It7g5FaY3GFRY1CtKwlCJSjRDuLR9qBQaqXP6gdIadMsEBtI4SGRcRC1mC6PSAOpCcJNhH5aDzwGS0yzp5wkIUqijQRrB2FeGciMfG+Kc0dWUraZIry6VQNIQ55gSOjflrCcnYhvv4xLENRUKIh1ic0LMqPRmTk+nlmCJBtm26uXiyjE6f30MPZyQDcIIEgscN5KGAFgBoSGWxLzmMQjn6hLZSQ7pQqS8ExyiWi+Z3p9kiZSQR5WlsB15gw63eNqi6Erky7B6wDxt1Qb2rBg+9b4djsA8bdUG9qyal2us22IeN7K7Hx6v1ntX60Wp4vUC+RxQE/zNZGh1Shrlry57MjMbchHAwREoiTWRDHrEjrLFvTM2x+/h0Vf4dk13NpA9oiemcZUSZXzIhWPwq1frglezTZtu/dlGgLK3CsSK59KP/5uC46u7q3nBA7LtB1lVjeAHUuYf2TXEREjfHwxaL68MujfexeI1dnBfsf5nEIQ+8eGwKDUtSPJgqpaIpXe5GMM+8EYw3dSOYnRvh8+IegEV13HdSfyf1/4jUYyDyEAdeVn5wgY/w3opxb41Wa3QZZt8z+VthdqvT3wvzL77YnVuG6lvUUZWZs/HQsDpVppTfXIGVvIb5dIsretNfKrrlxofIeTsiIo8tn8DKhT4gDI0zysi+SBmBePjxoZxr/IRjTn8D
--------------------------------------------------------------------------------
/apps/studio/msk-to-studio/img/.$msk-studio.drawio.dtmp:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/apps/studio/msk-to-studio/img/msk-studio.drawio:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/apps/studio/msk-to-studio/img/msk-studio.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/awslabs/managed-service-for-apache-flink-blueprints/5c8da457d749d32069e99f2e64687613a6e099ad/apps/studio/msk-to-studio/img/msk-studio.png
--------------------------------------------------------------------------------
/bootstrap-cdk/.gitignore:
--------------------------------------------------------------------------------
1 | *.js
2 | !jest.config.js
3 | *.d.ts
4 | node_modules
5 |
6 | # CDK asset staging directory
7 | .cdk.staging
8 | cdk.out
9 |
--------------------------------------------------------------------------------
/bootstrap-cdk/.npmignore:
--------------------------------------------------------------------------------
1 | *.ts
2 | !*.d.ts
3 |
4 | # CDK asset staging directory
5 | .cdk.staging
6 | cdk.out
7 |
--------------------------------------------------------------------------------
/bootstrap-cdk/README.md:
--------------------------------------------------------------------------------
1 | Run this command to launch this template:
2 |
3 | ```bash
4 | aws cloudformation create-stack --template-body file://./bootstrap-cdk/cdk.out/BootstrapCdkStack.template.json --stack-name bootstrap-my-account --parameters ParameterKey=AssetBucket,ParameterValue=myblueprintdemoassets12345 ParameterKey=AssetList,ParameterValue="https://data-streaming-labs.s3.amazonaws.com/blueprint-test/aws-lambda-helpers-1.0.jar\,https://data-streaming-labs.s3.amazonaws.com/blueprint-test/CdkInfraMsfKafkaToS3Stack.template.json\,https://data-streaming-labs.s3.amazonaws.com/blueprint-test/my-deployment.zip" --capabilities CAPABILITY_IAM
5 | ```
--------------------------------------------------------------------------------
/bootstrap-cdk/bin/main.ts:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env node
2 | /*
3 | * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
4 | * Apache-2.0
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this
7 | * software and associated documentation files (the "Software"), to deal in the Software
8 | * without restriction, including without limitation the rights to use, copy, modify,
9 | * merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
10 | * permit persons to whom the Software is furnished to do so.
11 | *
12 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
13 | * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
14 | * PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
15 | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
16 | * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
17 | * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
18 | */
19 |
20 | import 'source-map-support/register';
21 | import * as cdk from 'aws-cdk-lib';
22 | import { BootstrapCdkStack } from '../lib/bootstrap-cdk-stack';
23 | import { BootstraplessStackSynthesizer } from 'cdk-bootstrapless-synthesizer';
24 |
25 |
26 |
27 | const app = new cdk.App();
28 |
29 | const AssetBucket = app.node.tryGetContext('AssetBucket');
30 |
31 | // list of links (assets) to download
32 | const AssetList = app.node.tryGetContext('AssetList');
33 |
34 | const stackName = app.node.tryGetContext('stackName') ? app.node.tryGetContext('stackName') : "BootstrapCdkStack"
35 |
36 | new BootstrapCdkStack(app, stackName, {
37 | synthesizer: new BootstraplessStackSynthesizer({
38 | templateBucketName: 'cfn-template-bucket',
39 |
40 | fileAssetBucketName: 'file-asset-bucket-${AWS::Region}',
41 | fileAssetRegionSet: ['us-west-1', 'us-west-2'],
42 | fileAssetPrefix: 'file-asset-prefix/latest/'
43 | }),
44 | AssetBucket: AssetBucket,
45 | AssetList: AssetList,
46 | });
--------------------------------------------------------------------------------
/bootstrap-cdk/cdk.json:
--------------------------------------------------------------------------------
1 | {
2 | "app": "npx ts-node --prefer-ts-exts bin/main.ts",
3 | "watch": {
4 | "include": [
5 | "**"
6 | ],
7 | "exclude": [
8 | "README.md",
9 | "cdk*.json",
10 | "**/*.d.ts",
11 | "**/*.js",
12 | "tsconfig.json",
13 | "package*.json",
14 | "yarn.lock",
15 | "node_modules",
16 | "test"
17 | ]
18 | },
19 | "context": {
20 | "@aws-cdk/aws-lambda:recognizeLayerVersion": true,
21 | "@aws-cdk/core:checkSecretUsage": true,
22 | "@aws-cdk/core:target-partitions": [
23 | "aws",
24 | "aws-cn"
25 | ],
26 | "@aws-cdk-containers/ecs-service-extensions:enableDefaultLogDriver": true,
27 | "@aws-cdk/aws-ec2:uniqueImdsv2TemplateName": true,
28 | "@aws-cdk/aws-ecs:arnFormatIncludesClusterName": true,
29 | "@aws-cdk/aws-iam:minimizePolicies": true,
30 | "@aws-cdk/core:validateSnapshotRemovalPolicy": true,
31 | "@aws-cdk/aws-codepipeline:crossAccountKeyAliasStackSafeResourceName": true,
32 | "@aws-cdk/aws-s3:createDefaultLoggingPolicy": true,
33 | "@aws-cdk/aws-sns-subscriptions:restrictSqsDescryption": true,
34 | "@aws-cdk/aws-apigateway:disableCloudWatchRole": true,
35 | "@aws-cdk/core:enablePartitionLiterals": true,
36 | "@aws-cdk/aws-events:eventsTargetQueueSameAccount": true,
37 | "@aws-cdk/aws-iam:standardizedServicePrincipals": true,
38 | "@aws-cdk/aws-ecs:disableExplicitDeploymentControllerForCircuitBreaker": true,
39 | "@aws-cdk/aws-iam:importedRoleStackSafeDefaultPolicyName": true,
40 | "@aws-cdk/aws-s3:serverAccessLogsUseBucketPolicy": true,
41 | "@aws-cdk/aws-route53-patters:useCertificate": true,
42 | "@aws-cdk/customresources:installLatestAwsSdkDefault": false,
43 | "@aws-cdk/aws-rds:databaseProxyUniqueResourceName": true,
44 | "@aws-cdk/aws-codedeploy:removeAlarmsFromDeploymentGroup": true,
45 | "@aws-cdk/aws-apigateway:authorizerChangeDeploymentLogicalId": true,
46 | "@aws-cdk/aws-ec2:launchTemplateDefaultUserData": true,
47 | "@aws-cdk/aws-secretsmanager:useAttachedSecretResourcePolicyForSecretTargetAttachments": true,
48 | "@aws-cdk/aws-redshift:columnId": true,
49 | "@aws-cdk/aws-stepfunctions-tasks:enableEmrServicePolicyV2": true,
50 | "@aws-cdk/aws-ec2:restrictDefaultSecurityGroup": true,
51 | "@aws-cdk/aws-apigateway:requestValidatorUniqueId": true,
52 | "@aws-cdk/aws-kms:aliasNameRef": true,
53 | "@aws-cdk/core:includePrefixInUniqueNameGeneration": true
54 | }
55 | }
56 |
--------------------------------------------------------------------------------
/bootstrap-cdk/jest.config.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | testEnvironment: 'node',
3 | roots: ['/test'],
4 | testMatch: ['**/*.test.ts'],
5 | transform: {
6 | '^.+\\.tsx?$': 'ts-jest'
7 | }
8 | };
9 |
--------------------------------------------------------------------------------
/bootstrap-cdk/lib/bootstrap-cdk-stack.ts:
--------------------------------------------------------------------------------
1 |
2 | /*
3 | * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
4 | * Apache-2.0
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this
7 | * software and associated documentation files (the "Software"), to deal in the Software
8 | * without restriction, including without limitation the rights to use, copy, modify,
9 | * merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
10 | * permit persons to whom the Software is furnished to do so.
11 | *
12 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
13 | * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
14 | * PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
15 | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
16 | * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
17 | * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
18 | */
19 |
20 | import * as cdk from 'aws-cdk-lib';
21 | import { Construct } from 'constructs';
22 | import { StackProps } from 'aws-cdk-lib';
23 | import { CopyAssetsLambdaConstruct } from "../../cdk-infra/shared/lib/copy-assets-lambda-construct";
24 |
25 |
26 |
27 |
28 | export interface GlobalProps extends StackProps {
29 | AssetBucket: string,
30 | AssetList: string,
31 | }
32 |
33 |
34 |
35 | export class BootstrapCdkStack extends cdk.Stack {
36 | constructor(scope: Construct, id: string, props?: GlobalProps) {
37 | super(scope, id, props);
38 |
39 | // we'll be generating a CFN script so we need CFN params
40 | let cfnParams = this.getParams(props);
41 |
42 |
43 | // this construct creates an S3 bucket then copies all the assets passed
44 | const copyAssetsLambdaFn = new CopyAssetsLambdaConstruct(this, 'CopyAssetsLambda', {
45 | account: this.account,
46 | region: this.region,
47 | AssetBucket: cfnParams.get("AssetBucket")!.valueAsString,
48 | AssetList: cfnParams.get("AssetList")!.valueAsString
49 | });
50 |
51 |
52 |
53 | } // constructor
54 |
55 |
56 |
57 | getParams(props?: GlobalProps): Map {
58 | let params = new Map();
59 | const AssetBucket = new cdk.CfnParameter(this, "AssetBucket", {
60 | type: "String",
61 | description: "The s3 bucket to create that will hold the CFN template script and assets."
62 | });
63 | params.set("AssetBucket", AssetBucket);
64 |
65 | const AssetList = new cdk.CfnParameter(this, "AssetList", {
66 | type: "String",
67 | description: "The list of assets, comma separated, of all assets you wish to include in S3 bucket assets"});
68 |
69 | params.set("AssetList", AssetList)
70 | return params;
71 |
72 | }
73 |
74 | } // class
75 |
--------------------------------------------------------------------------------
/bootstrap-cdk/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "bootstrap-cdk",
3 | "version": "0.1.0",
4 | "bin": {
5 | "bootstrap-cdk": "bin/bootstrap-cdk.js"
6 | },
7 | "scripts": {
8 | "build": "tsc",
9 | "watch": "tsc -w",
10 | "test": "jest",
11 | "cdk": "cdk"
12 | },
13 | "devDependencies": {
14 | "@types/jest": "29.5.1",
15 | "@types/node": "18.16.0",
16 | "@types/prettier": "2.7.2",
17 | "aws-cdk": "2.76.0",
18 | "jest": "29.5.0",
19 | "ts-jest": "29.1.0",
20 | "ts-node": "10.9.1",
21 | "typescript": "5.0.4"
22 | },
23 | "dependencies": {
24 | "aws-cdk-lib": "2.85.0",
25 | "constructs": "10.2.4",
26 | "source-map-support": "0.5.21",
27 | "cdk-bootstrapless-synthesizer": "^2.3.2"
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/bootstrap-cdk/test/bootstrap-cdk.test.ts:
--------------------------------------------------------------------------------
1 | // import * as cdk from 'aws-cdk-lib';
2 | // import { Template } from 'aws-cdk-lib/assertions';
3 | // import * as BootstrapCdk from '../lib/bootstrap-cdk-stack';
4 |
5 | // example test. To run these tests, uncomment this file along with the
6 | // example resource in lib/bootstrap-cdk-stack.ts
7 | test('SQS Queue Created', () => {
8 | // const app = new cdk.App();
9 | // // WHEN
10 | // const stack = new BootstrapCdk.BootstrapCdkStack(app, 'MyTestStack');
11 | // // THEN
12 | // const template = Template.fromStack(stack);
13 |
14 | // template.hasResourceProperties('AWS::SQS::Queue', {
15 | // VisibilityTimeout: 300
16 | // });
17 | });
18 |
--------------------------------------------------------------------------------
/bootstrap-cdk/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "target": "ES2020",
4 | "module": "commonjs",
5 | "lib": [
6 | "es2020",
7 | "dom"
8 | ],
9 | "declaration": true,
10 | "strict": true,
11 | "noImplicitAny": true,
12 | "strictNullChecks": true,
13 | "noImplicitThis": true,
14 | "alwaysStrict": true,
15 | "noUnusedLocals": false,
16 | "noUnusedParameters": false,
17 | "noImplicitReturns": true,
18 | "noFallthroughCasesInSwitch": false,
19 | "inlineSourceMap": true,
20 | "inlineSources": true,
21 | "experimentalDecorators": true,
22 | "strictPropertyInitialization": false,
23 | "typeRoots": [
24 | "./node_modules/@types"
25 | ]
26 | },
27 | "exclude": [
28 | "node_modules",
29 | "cdk.out"
30 | ]
31 | }
32 |
--------------------------------------------------------------------------------
/cdk-infra/shared/README.md:
--------------------------------------------------------------------------------
1 | # Welcome to your CDK TypeScript project
2 |
3 | This is a blank project for CDK development with TypeScript.
4 |
5 | The `cdk.json` file tells the CDK Toolkit how to execute your app.
6 |
7 | ## Useful commands
8 |
9 | * `npm run build` compile typescript to js
10 | * `npm run watch` watch for changes and compile
11 | * `npm run test` perform the jest unit tests
12 | * `cdk deploy` deploy this stack to your default AWS account/region
13 | * `cdk diff` compare deployed stack with current state
14 | * `cdk synth` emits the synthesized CloudFormation template
15 |
--------------------------------------------------------------------------------
/cdk-infra/shared/bin/main.d.ts:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env node
2 | import 'source-map-support/register';
3 |
--------------------------------------------------------------------------------
/cdk-infra/shared/bin/main.js:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env node
2 | "use strict";
3 | Object.defineProperty(exports, "__esModule", { value: true });
4 | require("source-map-support/register");
5 | const cdk = require("aws-cdk-lib");
6 | const app = new cdk.App();
7 | //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibWFpbi5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIm1haW4udHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7O0FBQ0EsdUNBQXFDO0FBQ3JDLG1DQUFtQztBQUVuQyxNQUFNLEdBQUcsR0FBRyxJQUFJLEdBQUcsQ0FBQyxHQUFHLEVBQUUsQ0FBQyIsInNvdXJjZXNDb250ZW50IjpbIiMhL3Vzci9iaW4vZW52IG5vZGVcbmltcG9ydCAnc291cmNlLW1hcC1zdXBwb3J0L3JlZ2lzdGVyJztcbmltcG9ydCAqIGFzIGNkayBmcm9tICdhd3MtY2RrLWxpYic7XG5cbmNvbnN0IGFwcCA9IG5ldyBjZGsuQXBwKCk7Il19
--------------------------------------------------------------------------------
/cdk-infra/shared/bin/main.ts:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env node
2 | /*
3 | * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
4 | * Apache-2.0
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this
7 | * software and associated documentation files (the "Software"), to deal in the Software
8 | * without restriction, including without limitation the rights to use, copy, modify,
9 | * merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
10 | * permit persons to whom the Software is furnished to do so.
11 | *
12 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
13 | * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
14 | * PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
15 | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
16 | * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
17 | * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
18 | */
19 |
20 | import 'source-map-support/register';
21 | import * as cdk from 'aws-cdk-lib';
22 |
23 | const app = new cdk.App();
--------------------------------------------------------------------------------
/cdk-infra/shared/cdk.json:
--------------------------------------------------------------------------------
1 | {
2 | "app": "npx ts-node --prefer-ts-exts bin/main.ts",
3 | "watch": {
4 | "include": ["**"],
5 | "exclude": [
6 | "README.md",
7 | "cdk*.json",
8 | "**/*.d.ts",
9 | "**/*.js",
10 | "tsconfig.json",
11 | "package*.json",
12 | "yarn.lock",
13 | "node_modules",
14 | "test"
15 | ]
16 | },
17 | "context": {
18 | "@aws-cdk/aws-apigateway:usagePlanKeyOrderInsensitiveId": true,
19 | "@aws-cdk/core:stackRelativeExports": true,
20 | "@aws-cdk/aws-rds:lowercaseDbIdentifier": true,
21 | "@aws-cdk/aws-lambda:recognizeVersionProps": true,
22 | "@aws-cdk/aws-lambda:recognizeLayerVersion": true,
23 | "@aws-cdk/aws-cloudfront:defaultSecurityPolicyTLSv1.2_2021": true,
24 | "@aws-cdk-containers/ecs-service-extensions:enableDefaultLogDriver": true,
25 | "@aws-cdk/aws-ec2:uniqueImdsv2TemplateName": true,
26 | "@aws-cdk/core:checkSecretUsage": true,
27 | "@aws-cdk/aws-iam:minimizePolicies": true,
28 | "@aws-cdk/aws-ecs:arnFormatIncludesClusterName": true,
29 | "@aws-cdk/core:validateSnapshotRemovalPolicy": true,
30 | "@aws-cdk/aws-codepipeline:crossAccountKeyAliasStackSafeResourceName": true,
31 | "@aws-cdk/aws-s3:createDefaultLoggingPolicy": true,
32 | "@aws-cdk/aws-sns-subscriptions:restrictSqsDescryption": true,
33 | "@aws-cdk/aws-apigateway:disableCloudWatchRole": true,
34 | "@aws-cdk/core:enablePartitionLiterals": true,
35 | "@aws-cdk/core:target-partitions": ["aws", "aws-cn"]
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/cdk-infra/shared/jest.config.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | testEnvironment: 'node',
3 | roots: ['/test'],
4 | testMatch: ['**/*.test.ts'],
5 | transform: {
6 | '^.+\\.tsx?$': 'ts-jest'
7 | }
8 | };
9 |
--------------------------------------------------------------------------------
/cdk-infra/shared/lambda/aws-lambda-helpers/.gitignore:
--------------------------------------------------------------------------------
1 | # maven
2 |
3 | target/
4 | pom.xml.tag
5 | pom.xml.releaseBackup
6 | pom.xml.versionsBackup
7 | pom.xml.next
8 | release.properties
9 | dependency-reduced-pom.xml
10 | buildNumber.properties
11 | .mvn/timing.properties
12 | # https://github.com/takari/maven-wrapper#usage-without-binary-jar
13 | .mvn/wrapper/maven-wrapper.jar
14 |
15 | # Eclipse m2e generated files
16 | # Eclipse Core
17 | .project
18 | # JDT-specific (Eclipse Java Development Tools)
19 | .classpath
20 |
21 | # intellij
22 |
23 | # Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider
24 | # Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
25 |
26 | # User-specific stuff
27 | .idea/**/workspace.xml
28 | .idea/**/tasks.xml
29 | .idea/**/usage.statistics.xml
30 | .idea/**/dictionaries
31 | .idea/**/shelf
32 |
33 | # AWS User-specific
34 | .idea/**/aws.xml
35 |
36 | # Generated files
37 | .idea/**/contentModel.xml
38 |
39 | # Sensitive or high-churn files
40 | .idea/**/dataSources/
41 | .idea/**/dataSources.ids
42 | .idea/**/dataSources.local.xml
43 | .idea/**/sqlDataSources.xml
44 | .idea/**/dynamic.xml
45 | .idea/**/uiDesigner.xml
46 | .idea/**/dbnavigator.xml
47 |
48 | # Gradle
49 | .idea/**/gradle.xml
50 | .idea/**/libraries
51 |
52 | # Gradle and Maven with auto-import
53 | # When using Gradle or Maven with auto-import, you should exclude module files,
54 | # since they will be recreated, and may cause churn. Uncomment if using
55 | # auto-import.
56 | # .idea/artifacts
57 | # .idea/compiler.xml
58 | # .idea/jarRepositories.xml
59 | # .idea/modules.xml
60 | # .idea/*.iml
61 | # .idea/modules
62 | # *.iml
63 | # *.ipr
64 |
65 | # CMake
66 | cmake-build-*/
67 |
68 | # Mongo Explorer plugin
69 | .idea/**/mongoSettings.xml
70 |
71 | # File-based project format
72 | *.iws
73 |
74 | # IntelliJ
75 | out/
76 |
77 | # mpeltonen/sbt-idea plugin
78 | .idea_modules/
79 |
80 | # JIRA plugin
81 | atlassian-ide-plugin.xml
82 |
83 | # Cursive Clojure plugin
84 | .idea/replstate.xml
85 |
86 | # SonarLint plugin
87 | .idea/sonarlint/
88 |
89 | # Crashlytics plugin (for Android Studio and IntelliJ)
90 | com_crashlytics_export_strings.xml
91 | crashlytics.properties
92 | crashlytics-build.properties
93 | fabric.properties
94 |
95 | # Editor-based Rest Client
96 | .idea/httpRequests
97 |
98 | # Android studio 3.1+ serialized cache file
99 | .idea/caches/build_file_checksums.ser
--------------------------------------------------------------------------------
/cdk-infra/shared/lambda/aws-lambda-helpers/README.md:
--------------------------------------------------------------------------------
1 | # Lambda code (in Java) for creating MSK topics
2 |
3 | This project contains Java code for creating topics against MSK, and is meant to be used in AWS Lambda functions. Note that you don't have to build this project or otherwise interact with it to use the CDK templates that reference the output of this project. With that said, here's the info for building this project and using it in the referencing CDK template.
4 |
5 | ## Building this project
6 |
7 | - Run `mvn clean package shade:shade`
8 | - Copy the uber jar named `aws-lambda-helpers-1.0.jar` from the `target` folder to the level above this project
--------------------------------------------------------------------------------
/cdk-infra/shared/lambda/aws-lambda-helpers/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
5 | 4.0.0
6 |
7 | com.amazonaws
8 | aws-lambda-helpers
9 | 1.0
10 |
11 | aws-lambda-helpers
12 |
13 |
14 | UTF-8
15 | 1.11
16 | 11
17 | 1.11
18 | 1.11
19 | 2.7.2
20 |
21 |
22 |
23 |
24 | com.amazonaws
25 | aws-lambda-java-core
26 | 1.2.1
27 |
28 |
29 | org.apache.kafka
30 | kafka-clients
31 | ${kafka.clients.version}
32 |
33 |
34 | software.amazon.lambda
35 | powertools-cloudformation
36 | 1.15.0
37 |
38 |
39 |
40 | software.amazon.msk
41 | aws-msk-iam-auth
42 | 1.1.5
43 |
44 |
45 | com.google.code.gson
46 | gson
47 | 2.10.1
48 |
49 |
50 | junit
51 | junit
52 | 4.13.1
53 | test
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 | org.apache.maven.plugins
63 | maven-compiler-plugin
64 | 3.8.0
65 |
66 | ${jdk.version}
67 | ${jdk.version}
68 |
69 |
70 |
71 | maven-surefire-plugin
72 | 2.22.1
73 |
74 |
75 |
76 |
77 | org.apache.maven.plugins
78 | maven-shade-plugin
79 | 3.1.1
80 |
81 |
82 |
83 | package
84 |
85 | shade
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
96 | *:*
97 |
98 | META-INF/*.SF
99 | META-INF/*.DSA
100 | META-INF/*.RSA
101 |
102 |
103 |
104 |
105 |
106 | com.amazonaws.App
107 |
108 |
109 |
110 |
111 |
112 |
113 |
114 |
115 |
116 |
117 |
--------------------------------------------------------------------------------
/cdk-infra/shared/lambda/aws-lambda-helpers/src/main/java/com/amazonaws/App.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3 | * Apache-2.0
4 | *
5 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this
6 | * software and associated documentation files (the "Software"), to deal in the Software
7 | * without restriction, including without limitation the rights to use, copy, modify,
8 | * merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
9 | * permit persons to whom the Software is furnished to do so.
10 | *
11 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
12 | * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
13 | * PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
14 | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
15 | * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
16 | * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
17 | */
18 |
19 | package com.amazonaws;
20 |
21 | public class App {
22 | public static void main(String[] args) throws Exception {
23 | System.out.println("Starting program...");
24 |
25 | String bootstrapServers = "boot-8vkw6qcx.c1.kafka-serverless.us-east-1.amazonaws.com:9098";
26 | String topic = "sourceTopic";
27 | MSKDataGen mskDataGen = new MSKDataGen(bootstrapServers, topic, 100);
28 | mskDataGen.run();
29 | }
30 | }
--------------------------------------------------------------------------------
/cdk-infra/shared/lambda/aws-lambda-helpers/src/main/java/com/amazonaws/DataPayload.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3 | * Apache-2.0
4 | *
5 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this
6 | * software and associated documentation files (the "Software"), to deal in the Software
7 | * without restriction, including without limitation the rights to use, copy, modify,
8 | * merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
9 | * permit persons to whom the Software is furnished to do so.
10 | *
11 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
12 | * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
13 | * PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
14 | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
15 | * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
16 | * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
17 | */
18 |
19 | package com.amazonaws;
20 |
21 | import com.google.gson.Gson;
22 |
23 | /*
24 | The purpose of this hierarchy of classes is to ensure that we properly structure our response for
25 | CDK: {'Data': {'attributes': {'Response': }}}
26 | */
27 | public class DataPayload {
28 | public AttributesPayload Data;
29 |
30 | public DataPayload() {
31 | }
32 |
33 | public DataPayload(String response) {
34 | this.Data = new AttributesPayload(response);
35 | }
36 |
37 | public String asJson() {
38 | Gson gson = new Gson();
39 | return gson.toJson(this);
40 | }
41 |
42 | public static class AttributesPayload {
43 | public ResponsePayload attributes;
44 |
45 | public AttributesPayload(String response) {
46 | this.attributes = new ResponsePayload(response);
47 | }
48 | }
49 |
50 | public static class ResponsePayload {
51 | public ResponsePayload(String response) {
52 | this.Response = response;
53 | }
54 |
55 | public String Response;
56 | }
57 | }
--------------------------------------------------------------------------------
/cdk-infra/shared/lambda/aws-lambda-helpers/src/main/java/com/amazonaws/MSKDataGenHandler.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3 | * Apache-2.0
4 | *
5 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this
6 | * software and associated documentation files (the "Software"), to deal in the Software
7 | * without restriction, including without limitation the rights to use, copy, modify,
8 | * merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
9 | * permit persons to whom the Software is furnished to do so.
10 | *
11 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
12 | * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
13 | * PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
14 | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
15 | * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
16 | * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
17 | */
18 |
19 | package com.amazonaws;
20 |
21 | import com.amazonaws.services.lambda.runtime.Context;
22 | import com.amazonaws.services.lambda.runtime.LambdaLogger;
23 | import com.amazonaws.services.lambda.runtime.RequestHandler;
24 | import com.google.gson.Gson;
25 | import com.google.gson.GsonBuilder;
26 | import com.google.gson.reflect.TypeToken;
27 |
28 | import java.lang.reflect.Type;
29 | import java.util.Map;
30 |
31 | public class MSKDataGenHandler implements RequestHandler