cdk-databrew-cicd


Namecdk-databrew-cicd JSON
Version 2.0.456 PyPI version JSON
download
home_pagehttps://github.com/HsiehShuJeng/cdk-databrew-cicd.git
SummaryA construct for AWS Glue DataBrew wtih CICD
upload_time2024-12-22 01:03:07
maintainerNone
docs_urlNone
authorShu-Jeng Hsieh
requires_python~=3.8
licenseApache-2.0
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # cdk-databrew-cicd

This construct creates a **CodePipeline** pipeline where users can push a **DataBrew** recipe into the **CodeCommit** repository and the recipe will be pushed to a pre-production AWS account and a production AWS account by order automatically.

| npm (JS/TS) | PyPI (Python) | Maven (Java) | Go | NuGet |
| --- | --- | --- | --- | --- |
| [Link](https://www.npmjs.com/package/cdk-databrew-cicd) | [Link](https://pypi.org/project/cdk_databrew_cicd/) | [Link](https://search.maven.org/artifact/io.github.hsiehshujeng/cdk-databrew-cicd) | [Link](https://github.com/HsiehShuJeng/cdk-databrew-cicd-go) | [Link](https://www.nuget.org/packages/Databrew.Cicd/) |

[![License](https://img.shields.io/badge/License-Apache%202.0-green)](https://opensource.org/licenses/Apache-2.0) [![Release](https://github.com/HsiehShuJeng/cdk-databrew-cicd/workflows/Release/badge.svg)](https://github.com/HsiehShuJeng/cdk-databrew-cicd/actions/workflows/release.yml) [![npm downloads](https://img.shields.io/npm/dt/cdk-databrew-cicd?label=npm%20downloads&style=plastic)](https://img.shields.io/npm/dt/cdk-databrew-cicd?label=npm%20downloads&style=plastic) [![pypi downloads](https://img.shields.io/pypi/dm/cdk-databrew-cicd?label=pypi%20downloads&style=plastic)](https://img.shields.io/pypi/dm/cdk-databrew-cicd?label=pypi%20downloads&style=plastic) [![NuGet downloads](https://img.shields.io/nuget/dt/Databrew.Cicd?label=NuGet%20downloads&style=plastic)](https://img.shields.io/nuget/dt/Databrew.Cicd?label=NuGet%20downloads&style=plastic) [![repo languages](https://img.shields.io/github/languages/count/HsiehShuJeng/cdk-databrew-cicd?label=repo%20languages&style=plastic)](https://img.shields.io/github/languages/count/HsiehShuJeng/cdk-databrew-cicd?label=repo%20languages&style=plastic)

# Table of Contents

* [Serverless Architecture](#serverless-architecture)
* [Introduction](#introduction)
* [Example](#example)

  * [Typescript](#typescript)
  * [Python](#python)
  * [Java](#java)
  * [C#](#c)
  * [Go](#go)
* [Some Efforts after Stack Creation](#some-efforts-after-stack-creation)
* [How Successful Commits Look Like](#how-successful-commits-look-like)

# Serverless Architecture

![image](https://d2908q01vomqb2.cloudfront.net/b6692ea5df920cad691c20319a6fffd7a4a766b8/2021/05/19/image001.jpg) *Romi B. and Gaurav W., 2021*

# Introduction

The architecture was introduced by **Romi Boimer** and **Gaurav Wadhawan** and was posted on the AWS Blog as [*Set up CI/CD pipelines for AWS Glue DataBrew using AWS Developer Tools*](https://aws.amazon.com/tw/blogs/big-data/set-up-ci-cd-pipelines-for-aws-glue-databrew-using-aws-developer-tools/).
I converted the architecture into a CDK construct for 5 programming languages. Before applying the AWS construct, make sure you've set up a proper IAM role for the pre-production and production AWS accounts. You could achieve it either by creating manually or creating through a custom construct in this library.

```python
import { IamRole } from 'cdk-databrew-cicd';

new IamRole(this, 'AccountIamRole', {
    environment: 'preproduction', // or 'production'
    accountID: 'ACCOUNT_ID',
    // roleName: 'OPTIONAL'
});
```

# Example

## Typescript

You could also refer to [here](https://github.com/HsiehShuJeng/cdk-databrew-cicd/tree/main/src/demo/typescript).

```bash
$ cdk --init language typescript
$ yarn add cdk-databrew-cicd
```

```python
import * as cdk from '@aws-cdk/core';
import { DataBrewCodePipeline } from 'cdk-databrew-cicd';

class TypescriptStack extends cdk.Stack {
  constructor(scope: cdk.Construct, id: string, props?: cdk.StackProps) {
    super(scope, id, props);

    const preproductionAccountId = 'PREPRODUCTION_ACCOUNT_ID';
    const productionAccountId = 'PRODUCTION_ACCOUNT_ID';

    const dataBrewPipeline = new DataBrewCodePipeline(this, 'DataBrewCicdPipeline', {
      preproductionIamRoleArn: `arn:${cdk.Aws.PARTITION}:iam::${preproductionAccountId}:role/preproduction-Databrew-Cicd-Role`,
      productionIamRoleArn: `arn:${cdk.Aws.PARTITION}:iam::${productionAccountId}:role/production-Databrew-Cicd-Role`,
      // bucketName: 'OPTIONAL',
      // repoName: 'OPTIONAL',
      // branchName: 'OPTIONAL',
      // pipelineName: 'OPTIONAL'
    });

    new cdk.CfnOutput(this, 'OPreproductionLambdaArn', { value: dataBrewPipeline.preproductionFunctionArn });
    new cdk.CfnOutput(this, 'OProductionLambdaArn', { value: dataBrewPipeline.productionFunctionArn });
    new cdk.CfnOutput(this, 'OCodeCommitRepoArn', { value: dataBrewPipeline.codeCommitRepoArn });
    new cdk.CfnOutput(this, 'OCodePipelineArn', { value: dataBrewPipeline.codePipelineArn });
  }
}

const app = new cdk.App();
new TypescriptStack(app, 'TypescriptStack', {
  stackName: 'DataBrew-CICD'
});
```

## Python

You could also refer to [here](https://github.com/HsiehShuJeng/cdk-databrew-cicd/tree/main/src/demo/python).

```bash
# upgrading related Python packages
$ python -m ensurepip --upgrade
$ python -m pip install --upgrade pip
$ python -m pip install --upgrade virtualenv
# initialize a CDK Python project
$ cdk init --language python
# make packages installed locally instead of globally
$ source .venv/bin/activate
$ cat <<EOL > requirements.txt
aws-cdk.core
cdk-databrew-cicd
EOL
$ python -m pip install -r requirements.txt
```

```python
from aws_cdk import core as cdk
from cdk_databrew_cicd import DataBrewCodePipeline

class PythonStack(cdk.Stack):

    def __init__(self, scope: cdk.Construct, construct_id: str, **kwargs) -> None:
        super().__init__(scope, construct_id, **kwargs)

        preproduction_account_id = "PREPRODUCTION_ACCOUNT_ID"
        production_account_id = "PRODUCTION_ACCOUNT_ID"

        databrew_pipeline = DataBrewCodePipeline(self,
        "DataBrewCicdPipeline",
        preproduction_iam_role_arn=f"arn:{cdk.Aws.PARTITION}:iam::{preproduction_account_id}:role/preproduction-Databrew-Cicd-Role",
        production_iam_role_arn=f"arn:{cdk.Aws.PARTITION}:iam::{production_account_id}:role/preproduction-Databrew-Cicd-Role",
            # bucket_name="OPTIONAL",
            # repo_name="OPTIONAL",
            # repo_name="OPTIONAL",
            # branch_namne="OPTIONAL",
            # pipeline_name="OPTIONAL"
            )

        cdk.CfnOutput(self, 'OPreproductionLambdaArn', value=databrew_pipeline.preproduction_function_arn)
        cdk.CfnOutput(self, 'OProductionLambdaArn', value=databrew_pipeline.production_function_arn)
        cdk.CfnOutput(self, 'OCodeCommitRepoArn', value=databrew_pipeline.code_commit_repo_arn)
        cdk.CfnOutput(self, 'OCodePipelineArn', value=databrew_pipeline.code_pipeline_arn)
```

```bash
$ deactivate
```

## Java

You could also refer to [here](https://github.com/HsiehShuJeng/cdk-databrew-cicd/tree/main/src/demo/java).

```bash
$ cdk init --language java
$ mvn package
```

```xml
.
.
<properties>
      <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
      <cdk.version>2.87.0</cdk.version>
      <constrcut.verion>2.0.196</constrcut.verion>
      <junit.version>5.7.1</junit.version>
</properties>
 .
 .
 <dependencies>
     <!-- AWS Cloud Development Kit -->
      <dependency>
            <groupId>software.amazon.awscdk</groupId>
            <artifactId>aws-cdk-lib</artifactId>
            <version>${cdk.version}</version>
      </dependency>
      <dependency>
        <groupId>io.github.hsiehshujeng</groupId>
        <artifactId>cdk-databrew-cicd</artifactId>
        <version>${constrcut.verion}</version>
        </dependency>
     .
     .
     .
 </dependencies>
```

```java
package com.myorg;

import software.amazon.awscdk.core.CfnOutput;
import software.amazon.awscdk.core.CfnOutputProps;
import software.amazon.awscdk.core.Construct;
import software.amazon.awscdk.core.Stack;
import software.amazon.awscdk.core.StackProps;
import io.github.hsiehshujeng.cdk.databrew.cicd.DataBrewCodePipeline;
import io.github.hsiehshujeng.cdk.databrew.cicd.DataBrewCodePipelineProps;

public class JavaStack extends Stack {
    public JavaStack(final Construct scope, final String id) {
        this(scope, id, null);
    }

    public JavaStack(final Construct scope, final String id, final StackProps props) {
        super(scope, id, props);
        String preproductionAccountId = "PREPRODUCTION_ACCOUNT_ID";
        String productionAccountId = "PRODUCTION_ACCOUNT_ID";
        DataBrewCodePipeline databrewPipeline = new DataBrewCodePipeline(this, "DataBrewCicdPipeline",
                DataBrewCodePipelineProps.builder().preproductionIamRoleArn(preproductionAccountId)
                        .productionIamRoleArn(productionAccountId)
                        // .bucketName("OPTIONAL")
                        // .branchName("OPTIONAL")
                        // .pipelineName("OPTIONAL")
                        .build());

        new CfnOutput(this, "OPreproductionLambdaArn",
                CfnOutputProps.builder()
                    .value(databrewPipeline.getPreproductionFunctionArn())
                    .build());
        new CfnOutput(this, "OProductionLambdaArn",
                CfnOutputProps.builder()
                    .value(databrewPipeline.getProductionFunctionArn())
                    .build());
        new CfnOutput(this, "OCodeCommitRepoArn",
                CfnOutputProps.builder()
                    .value(databrewPipeline.getCodeCommitRepoArn())
                    .build());
        new CfnOutput(this, "OCodePipelineArn",
                CfnOutputProps.builder()
                    .value(databrewPipeline.getCodePipelineArn())
                    .build());
    }
}
```

## C#

You could also refer to [here](https://github.com/HsiehShuJeng/cdk-databrew-cicd/tree/main/src/demo/csharp).

```bash
$ cdk init --language csharp
$ dotnet add src/Csharp package Databrew.Cicd --version 2.0.196
```

```cs
using Amazon.CDK;
using ScottHsieh.Cdk;

namespace Csharp
{
    public class CsharpStack : Stack
    {
        internal CsharpStack(Construct scope, string id, IStackProps props = null) : base(scope, id, props)
        {
            var preproductionAccountId = "PREPRODUCTION_ACCOUNT_ID";
            var productionAccountId = "PRODUCTION_ACCOUNT_ID";

            var dataBrewPipeline = new DataBrewCodePipeline(this, "DataBrewCicdPipeline", new DataBrewCodePipelineProps
            {
                PreproductionIamRoleArn = $"arn:{Aws.PARTITION}:iam::{preproductionAccountId}:role/preproduction-Databrew-Cicd-Role",
                ProductionIamRoleArn = $"arn:{Aws.PARTITION}:iam::{productionAccountId}:role/preproduction-Databrew-Cicd-Role",
                // BucketName = "OPTIONAL",
                // RepoName = "OPTIONAL",
                // BranchName = "OPTIONAL",
                // PipelineName = "OPTIONAL"
            });
            new CfnOutput(this, "OPreproductionLambdaArn", new CfnOutputProps
            {
                Value = dataBrewPipeline.PreproductionFunctionArn
            });
            new CfnOutput(this, "OProductionLambdaArn", new CfnOutputProps
            {
                Value = dataBrewPipeline.ProductionFunctionArn
            });
            new CfnOutput(this, "OCodeCommitRepoArn", new CfnOutputProps
            {
                Value = dataBrewPipeline.CodeCommitRepoArn
            });
            new CfnOutput(this, "OCodePipelineArn", new CfnOutputProps
            {
                Value = dataBrewPipeline.CodeCommitRepoArn
            });
        }
    }
}
```

## Go

You could also refer to [here](src/demo/go_lang/).

```bash
# Initialize a new AWS CDK application in the current directory with the Go programming language
cdk init app -l go
# Add this custom CDK construct to your project
go get github.com/HsiehShuJeng/cdk-databrew-cicd-go/cdkdatabrewcicd/v2@v2.0.196
# Ensure all dependencies are properly listed in the go.mod file and remove any unused ones
go mod tidy
# Upgrade all Go modules in your project to their latest minor or patch versions
go get -u ./...
```

```go
package main

import (
	"fmt"

	"github.com/aws/aws-cdk-go/awscdk/v2"

	// "github.com/aws/aws-cdk-go/awscdk/v2/awssqs"
	"github.com/HsiehShuJeng/cdk-databrew-cicd-go/cdkdatabrewcicd/v2"
	"github.com/aws/constructs-go/constructs/v10"
	"github.com/aws/jsii-runtime-go"
)

type GoLangStackProps struct {
	awscdk.StackProps
}

func NewGoLangStack(scope constructs.Construct, id string, props *GoLangStackProps) awscdk.Stack {
	var sprops awscdk.StackProps
	if props != nil {
		sprops = props.StackProps
	}
	stack := awscdk.NewStack(scope, &id, &sprops)

	preproductionAccountId := "PREPRODUCTION_ACCOUNT_ID"
	productionAccountId := "PRODUCTION_ACCOUNT_ID"

	dataBrewPipeline := cdkdatabrewcicd.NewDataBrewCodePipeline(stack, jsii.String("DataBrewCicdPipeline"), &cdkdatabrewcicd.DataBrewCodePipelineProps{
		PreproductionIamRoleArn: jsii.String(fmt.Sprintf("arn:%s:iam::%s:role/preproduction-Databrew-Cicd-Role", *awscdk.Aws_PARTITION(), preproductionAccountId)),
		ProductionIamRoleArn:    jsii.String(fmt.Sprintf("arn:%s:iam::%s:role/production-Databrew-Cicd-Role", *awscdk.Aws_PARTITION(), productionAccountId)),
		// BucketName:   jsii.String("OPTIONAL"),
		// RepoName:     jsii.String("OPTIONAL"),
		// BranchName:   jsii.String("OPTIONAL"),
		// PipelineName: jsii.String("OPTIONAL"),
	})

	awscdk.NewCfnOutput(stack, jsii.String("OPreproductionLambdaArn"), &awscdk.CfnOutputProps{Value: dataBrewPipeline.PreproductionFunctionArn()})
	awscdk.NewCfnOutput(stack, jsii.String("OProductionLambdaArn"), &awscdk.CfnOutputProps{Value: dataBrewPipeline.ProductionFunctionArn()})
	awscdk.NewCfnOutput(stack, jsii.String("OCodeCommitRepoArn"), &awscdk.CfnOutputProps{Value: dataBrewPipeline.CodeCommitRepoArn()})
	awscdk.NewCfnOutput(stack, jsii.String("OCodePipelineArn"), &awscdk.CfnOutputProps{Value: dataBrewPipeline.CodePipelineArn()})

	return stack
}

func main() {
	defer jsii.Close()

	app := awscdk.NewApp(nil)

	NewGoLangStack(app, "GoLangStack", &GoLangStackProps{
		awscdk.StackProps{
			Env: env(),
		},
	})

	app.Synth(nil)
}

func env() *awscdk.Environment {
	return nil
}

```

# Some Efforts after Stack Creation

## CodeCommit

1. Create HTTPS Git credentials for AWS CodeCommit with an IAM user that you're going to use.
   ![image](https://raw.githubusercontent.com/HsiehShuJeng/cdk-databrew-cicd/main/images/codecommit_credentials.png)
2. Run through the steps noted on the README.md of the CodeCommit repository after finishing establishing the stack via CDK. The returned message with success should be looked like the following (assume you have installed [`git-remote-codecommit`](https://pypi.org/project/git-remote-codecommit/)):

   ```bash
   $ git clone codecommit://scott.codecommit@DataBrew-Recipes-Repo
   Cloning into 'DataBrew-Recipes-Repo'...
   remote: Counting objects: 6, done.
   Unpacking objects: 100% (6/6), 2.03 KiB | 138.00 KiB/s, done.
   ```
3. Add a DataBrew recipe into the local repositroy (directory) and commit the change. (either directly on the main branch or merging another branch into the main branch)

## Glue DataBrew

1. Download any recipe either generated out by following [*Getting started with AWS Glue DataBrew*](https://docs.aws.amazon.com/zh_tw/databrew/latest/dg/getting-started.html) or made by yourself as **JSON file**.
   ![image](https://raw.githubusercontent.com/HsiehShuJeng/cdk-databrew-cicd/main/images/databrew_recipes.png)
2. Move the recipe from the download directory to the local directory for the CodeCommit repository.

   ```bash
   $ mv ${DOWNLOAD_DIRECTORY}/chess-project-recipe.json ${CODECOMMIT_LOCAL_DIRECTORY}/
   ```
3. Commit the change to a branch with a name you prefer.

   ```bash
   $ cd ${{CODECOMMIT_LOCAL_DIRECTORY}}
   $ git checkout -b add-recipe main
   $ git add .
   $ git commit -m "first recipe"
   $ git push --set-upstream origin add-recipe
   ```
4. Merge the branch into the main branch. Just go to the **AWS CodeCommit** web console to do the merge as its process is purely the same as you've already done thousands of times on **Github** but only with different UIs.

# How Successful Commits Look Like

1. In the infrastructure account, the status of the CodePipeline DataBrew pipeline should be similar as the following:
   ![image](https://raw.githubusercontent.com/HsiehShuJeng/cdk-databrew-cicd/main/images/infra_codepipeline.png)
2. In the **pre-production** account with the same region as where the CICD pipeline is deployed at the infrastructue account, you'll see this.
   ![image](https://raw.githubusercontent.com/HsiehShuJeng/cdk-databrew-cicd/main/images/preproduction-recipe.png)
3. In the **production** account with the same region as where the CICD pipeline is deployed at the infrastructue account, you'll see this.
   ![image](https://raw.githubusercontent.com/HsiehShuJeng/cdk-databrew-cicd/main/images/production-recipe.png)

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/HsiehShuJeng/cdk-databrew-cicd.git",
    "name": "cdk-databrew-cicd",
    "maintainer": null,
    "docs_url": null,
    "requires_python": "~=3.8",
    "maintainer_email": null,
    "keywords": null,
    "author": "Shu-Jeng Hsieh",
    "author_email": null,
    "download_url": "https://files.pythonhosted.org/packages/cc/ac/49cc09920e547bb5d1f35e079a026991d57a3d08c58101777fcfd59b8df0/cdk_databrew_cicd-2.0.456.tar.gz",
    "platform": null,
    "description": "# cdk-databrew-cicd\n\nThis construct creates a **CodePipeline** pipeline where users can push a **DataBrew** recipe into the **CodeCommit** repository and the recipe will be pushed to a pre-production AWS account and a production AWS account by order automatically.\n\n| npm (JS/TS) | PyPI (Python) | Maven (Java) | Go | NuGet |\n| --- | --- | --- | --- | --- |\n| [Link](https://www.npmjs.com/package/cdk-databrew-cicd) | [Link](https://pypi.org/project/cdk_databrew_cicd/) | [Link](https://search.maven.org/artifact/io.github.hsiehshujeng/cdk-databrew-cicd) | [Link](https://github.com/HsiehShuJeng/cdk-databrew-cicd-go) | [Link](https://www.nuget.org/packages/Databrew.Cicd/) |\n\n[![License](https://img.shields.io/badge/License-Apache%202.0-green)](https://opensource.org/licenses/Apache-2.0) [![Release](https://github.com/HsiehShuJeng/cdk-databrew-cicd/workflows/Release/badge.svg)](https://github.com/HsiehShuJeng/cdk-databrew-cicd/actions/workflows/release.yml) [![npm downloads](https://img.shields.io/npm/dt/cdk-databrew-cicd?label=npm%20downloads&style=plastic)](https://img.shields.io/npm/dt/cdk-databrew-cicd?label=npm%20downloads&style=plastic) [![pypi downloads](https://img.shields.io/pypi/dm/cdk-databrew-cicd?label=pypi%20downloads&style=plastic)](https://img.shields.io/pypi/dm/cdk-databrew-cicd?label=pypi%20downloads&style=plastic) [![NuGet downloads](https://img.shields.io/nuget/dt/Databrew.Cicd?label=NuGet%20downloads&style=plastic)](https://img.shields.io/nuget/dt/Databrew.Cicd?label=NuGet%20downloads&style=plastic) [![repo languages](https://img.shields.io/github/languages/count/HsiehShuJeng/cdk-databrew-cicd?label=repo%20languages&style=plastic)](https://img.shields.io/github/languages/count/HsiehShuJeng/cdk-databrew-cicd?label=repo%20languages&style=plastic)\n\n# Table of Contents\n\n* [Serverless Architecture](#serverless-architecture)\n* [Introduction](#introduction)\n* [Example](#example)\n\n  * [Typescript](#typescript)\n  * [Python](#python)\n  * [Java](#java)\n  * [C#](#c)\n  * [Go](#go)\n* [Some Efforts after Stack Creation](#some-efforts-after-stack-creation)\n* [How Successful Commits Look Like](#how-successful-commits-look-like)\n\n# Serverless Architecture\n\n![image](https://d2908q01vomqb2.cloudfront.net/b6692ea5df920cad691c20319a6fffd7a4a766b8/2021/05/19/image001.jpg) *Romi B. and Gaurav W., 2021*\n\n# Introduction\n\nThe architecture was introduced by **Romi Boimer** and **Gaurav Wadhawan** and was posted on the AWS Blog as [*Set up CI/CD pipelines for AWS Glue DataBrew using AWS Developer Tools*](https://aws.amazon.com/tw/blogs/big-data/set-up-ci-cd-pipelines-for-aws-glue-databrew-using-aws-developer-tools/).\nI converted the architecture into a CDK construct for 5 programming languages. Before applying the AWS construct, make sure you've set up a proper IAM role for the pre-production and production AWS accounts. You could achieve it either by creating manually or creating through a custom construct in this library.\n\n```python\nimport { IamRole } from 'cdk-databrew-cicd';\n\nnew IamRole(this, 'AccountIamRole', {\n    environment: 'preproduction', // or 'production'\n    accountID: 'ACCOUNT_ID',\n    // roleName: 'OPTIONAL'\n});\n```\n\n# Example\n\n## Typescript\n\nYou could also refer to [here](https://github.com/HsiehShuJeng/cdk-databrew-cicd/tree/main/src/demo/typescript).\n\n```bash\n$ cdk --init language typescript\n$ yarn add cdk-databrew-cicd\n```\n\n```python\nimport * as cdk from '@aws-cdk/core';\nimport { DataBrewCodePipeline } from 'cdk-databrew-cicd';\n\nclass TypescriptStack extends cdk.Stack {\n  constructor(scope: cdk.Construct, id: string, props?: cdk.StackProps) {\n    super(scope, id, props);\n\n    const preproductionAccountId = 'PREPRODUCTION_ACCOUNT_ID';\n    const productionAccountId = 'PRODUCTION_ACCOUNT_ID';\n\n    const dataBrewPipeline = new DataBrewCodePipeline(this, 'DataBrewCicdPipeline', {\n      preproductionIamRoleArn: `arn:${cdk.Aws.PARTITION}:iam::${preproductionAccountId}:role/preproduction-Databrew-Cicd-Role`,\n      productionIamRoleArn: `arn:${cdk.Aws.PARTITION}:iam::${productionAccountId}:role/production-Databrew-Cicd-Role`,\n      // bucketName: 'OPTIONAL',\n      // repoName: 'OPTIONAL',\n      // branchName: 'OPTIONAL',\n      // pipelineName: 'OPTIONAL'\n    });\n\n    new cdk.CfnOutput(this, 'OPreproductionLambdaArn', { value: dataBrewPipeline.preproductionFunctionArn });\n    new cdk.CfnOutput(this, 'OProductionLambdaArn', { value: dataBrewPipeline.productionFunctionArn });\n    new cdk.CfnOutput(this, 'OCodeCommitRepoArn', { value: dataBrewPipeline.codeCommitRepoArn });\n    new cdk.CfnOutput(this, 'OCodePipelineArn', { value: dataBrewPipeline.codePipelineArn });\n  }\n}\n\nconst app = new cdk.App();\nnew TypescriptStack(app, 'TypescriptStack', {\n  stackName: 'DataBrew-CICD'\n});\n```\n\n## Python\n\nYou could also refer to [here](https://github.com/HsiehShuJeng/cdk-databrew-cicd/tree/main/src/demo/python).\n\n```bash\n# upgrading related Python packages\n$ python -m ensurepip --upgrade\n$ python -m pip install --upgrade pip\n$ python -m pip install --upgrade virtualenv\n# initialize a CDK Python project\n$ cdk init --language python\n# make packages installed locally instead of globally\n$ source .venv/bin/activate\n$ cat <<EOL > requirements.txt\naws-cdk.core\ncdk-databrew-cicd\nEOL\n$ python -m pip install -r requirements.txt\n```\n\n```python\nfrom aws_cdk import core as cdk\nfrom cdk_databrew_cicd import DataBrewCodePipeline\n\nclass PythonStack(cdk.Stack):\n\n    def __init__(self, scope: cdk.Construct, construct_id: str, **kwargs) -> None:\n        super().__init__(scope, construct_id, **kwargs)\n\n        preproduction_account_id = \"PREPRODUCTION_ACCOUNT_ID\"\n        production_account_id = \"PRODUCTION_ACCOUNT_ID\"\n\n        databrew_pipeline = DataBrewCodePipeline(self,\n        \"DataBrewCicdPipeline\",\n        preproduction_iam_role_arn=f\"arn:{cdk.Aws.PARTITION}:iam::{preproduction_account_id}:role/preproduction-Databrew-Cicd-Role\",\n        production_iam_role_arn=f\"arn:{cdk.Aws.PARTITION}:iam::{production_account_id}:role/preproduction-Databrew-Cicd-Role\",\n            # bucket_name=\"OPTIONAL\",\n            # repo_name=\"OPTIONAL\",\n            # repo_name=\"OPTIONAL\",\n            # branch_namne=\"OPTIONAL\",\n            # pipeline_name=\"OPTIONAL\"\n            )\n\n        cdk.CfnOutput(self, 'OPreproductionLambdaArn', value=databrew_pipeline.preproduction_function_arn)\n        cdk.CfnOutput(self, 'OProductionLambdaArn', value=databrew_pipeline.production_function_arn)\n        cdk.CfnOutput(self, 'OCodeCommitRepoArn', value=databrew_pipeline.code_commit_repo_arn)\n        cdk.CfnOutput(self, 'OCodePipelineArn', value=databrew_pipeline.code_pipeline_arn)\n```\n\n```bash\n$ deactivate\n```\n\n## Java\n\nYou could also refer to [here](https://github.com/HsiehShuJeng/cdk-databrew-cicd/tree/main/src/demo/java).\n\n```bash\n$ cdk init --language java\n$ mvn package\n```\n\n```xml\n.\n.\n<properties>\n      <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>\n      <cdk.version>2.87.0</cdk.version>\n      <constrcut.verion>2.0.196</constrcut.verion>\n      <junit.version>5.7.1</junit.version>\n</properties>\n .\n .\n <dependencies>\n     <!-- AWS Cloud Development Kit -->\n      <dependency>\n            <groupId>software.amazon.awscdk</groupId>\n            <artifactId>aws-cdk-lib</artifactId>\n            <version>${cdk.version}</version>\n      </dependency>\n      <dependency>\n        <groupId>io.github.hsiehshujeng</groupId>\n        <artifactId>cdk-databrew-cicd</artifactId>\n        <version>${constrcut.verion}</version>\n        </dependency>\n     .\n     .\n     .\n </dependencies>\n```\n\n```java\npackage com.myorg;\n\nimport software.amazon.awscdk.core.CfnOutput;\nimport software.amazon.awscdk.core.CfnOutputProps;\nimport software.amazon.awscdk.core.Construct;\nimport software.amazon.awscdk.core.Stack;\nimport software.amazon.awscdk.core.StackProps;\nimport io.github.hsiehshujeng.cdk.databrew.cicd.DataBrewCodePipeline;\nimport io.github.hsiehshujeng.cdk.databrew.cicd.DataBrewCodePipelineProps;\n\npublic class JavaStack extends Stack {\n    public JavaStack(final Construct scope, final String id) {\n        this(scope, id, null);\n    }\n\n    public JavaStack(final Construct scope, final String id, final StackProps props) {\n        super(scope, id, props);\n        String preproductionAccountId = \"PREPRODUCTION_ACCOUNT_ID\";\n        String productionAccountId = \"PRODUCTION_ACCOUNT_ID\";\n        DataBrewCodePipeline databrewPipeline = new DataBrewCodePipeline(this, \"DataBrewCicdPipeline\",\n                DataBrewCodePipelineProps.builder().preproductionIamRoleArn(preproductionAccountId)\n                        .productionIamRoleArn(productionAccountId)\n                        // .bucketName(\"OPTIONAL\")\n                        // .branchName(\"OPTIONAL\")\n                        // .pipelineName(\"OPTIONAL\")\n                        .build());\n\n        new CfnOutput(this, \"OPreproductionLambdaArn\",\n                CfnOutputProps.builder()\n                    .value(databrewPipeline.getPreproductionFunctionArn())\n                    .build());\n        new CfnOutput(this, \"OProductionLambdaArn\",\n                CfnOutputProps.builder()\n                    .value(databrewPipeline.getProductionFunctionArn())\n                    .build());\n        new CfnOutput(this, \"OCodeCommitRepoArn\",\n                CfnOutputProps.builder()\n                    .value(databrewPipeline.getCodeCommitRepoArn())\n                    .build());\n        new CfnOutput(this, \"OCodePipelineArn\",\n                CfnOutputProps.builder()\n                    .value(databrewPipeline.getCodePipelineArn())\n                    .build());\n    }\n}\n```\n\n## C#\n\nYou could also refer to [here](https://github.com/HsiehShuJeng/cdk-databrew-cicd/tree/main/src/demo/csharp).\n\n```bash\n$ cdk init --language csharp\n$ dotnet add src/Csharp package Databrew.Cicd --version 2.0.196\n```\n\n```cs\nusing Amazon.CDK;\nusing ScottHsieh.Cdk;\n\nnamespace Csharp\n{\n    public class CsharpStack : Stack\n    {\n        internal CsharpStack(Construct scope, string id, IStackProps props = null) : base(scope, id, props)\n        {\n            var preproductionAccountId = \"PREPRODUCTION_ACCOUNT_ID\";\n            var productionAccountId = \"PRODUCTION_ACCOUNT_ID\";\n\n            var dataBrewPipeline = new DataBrewCodePipeline(this, \"DataBrewCicdPipeline\", new DataBrewCodePipelineProps\n            {\n                PreproductionIamRoleArn = $\"arn:{Aws.PARTITION}:iam::{preproductionAccountId}:role/preproduction-Databrew-Cicd-Role\",\n                ProductionIamRoleArn = $\"arn:{Aws.PARTITION}:iam::{productionAccountId}:role/preproduction-Databrew-Cicd-Role\",\n                // BucketName = \"OPTIONAL\",\n                // RepoName = \"OPTIONAL\",\n                // BranchName = \"OPTIONAL\",\n                // PipelineName = \"OPTIONAL\"\n            });\n            new CfnOutput(this, \"OPreproductionLambdaArn\", new CfnOutputProps\n            {\n                Value = dataBrewPipeline.PreproductionFunctionArn\n            });\n            new CfnOutput(this, \"OProductionLambdaArn\", new CfnOutputProps\n            {\n                Value = dataBrewPipeline.ProductionFunctionArn\n            });\n            new CfnOutput(this, \"OCodeCommitRepoArn\", new CfnOutputProps\n            {\n                Value = dataBrewPipeline.CodeCommitRepoArn\n            });\n            new CfnOutput(this, \"OCodePipelineArn\", new CfnOutputProps\n            {\n                Value = dataBrewPipeline.CodeCommitRepoArn\n            });\n        }\n    }\n}\n```\n\n## Go\n\nYou could also refer to [here](src/demo/go_lang/).\n\n```bash\n# Initialize a new AWS CDK application in the current directory with the Go programming language\ncdk init app -l go\n# Add this custom CDK construct to your project\ngo get github.com/HsiehShuJeng/cdk-databrew-cicd-go/cdkdatabrewcicd/v2@v2.0.196\n# Ensure all dependencies are properly listed in the go.mod file and remove any unused ones\ngo mod tidy\n# Upgrade all Go modules in your project to their latest minor or patch versions\ngo get -u ./...\n```\n\n```go\npackage main\n\nimport (\n\t\"fmt\"\n\n\t\"github.com/aws/aws-cdk-go/awscdk/v2\"\n\n\t// \"github.com/aws/aws-cdk-go/awscdk/v2/awssqs\"\n\t\"github.com/HsiehShuJeng/cdk-databrew-cicd-go/cdkdatabrewcicd/v2\"\n\t\"github.com/aws/constructs-go/constructs/v10\"\n\t\"github.com/aws/jsii-runtime-go\"\n)\n\ntype GoLangStackProps struct {\n\tawscdk.StackProps\n}\n\nfunc NewGoLangStack(scope constructs.Construct, id string, props *GoLangStackProps) awscdk.Stack {\n\tvar sprops awscdk.StackProps\n\tif props != nil {\n\t\tsprops = props.StackProps\n\t}\n\tstack := awscdk.NewStack(scope, &id, &sprops)\n\n\tpreproductionAccountId := \"PREPRODUCTION_ACCOUNT_ID\"\n\tproductionAccountId := \"PRODUCTION_ACCOUNT_ID\"\n\n\tdataBrewPipeline := cdkdatabrewcicd.NewDataBrewCodePipeline(stack, jsii.String(\"DataBrewCicdPipeline\"), &cdkdatabrewcicd.DataBrewCodePipelineProps{\n\t\tPreproductionIamRoleArn: jsii.String(fmt.Sprintf(\"arn:%s:iam::%s:role/preproduction-Databrew-Cicd-Role\", *awscdk.Aws_PARTITION(), preproductionAccountId)),\n\t\tProductionIamRoleArn:    jsii.String(fmt.Sprintf(\"arn:%s:iam::%s:role/production-Databrew-Cicd-Role\", *awscdk.Aws_PARTITION(), productionAccountId)),\n\t\t// BucketName:   jsii.String(\"OPTIONAL\"),\n\t\t// RepoName:     jsii.String(\"OPTIONAL\"),\n\t\t// BranchName:   jsii.String(\"OPTIONAL\"),\n\t\t// PipelineName: jsii.String(\"OPTIONAL\"),\n\t})\n\n\tawscdk.NewCfnOutput(stack, jsii.String(\"OPreproductionLambdaArn\"), &awscdk.CfnOutputProps{Value: dataBrewPipeline.PreproductionFunctionArn()})\n\tawscdk.NewCfnOutput(stack, jsii.String(\"OProductionLambdaArn\"), &awscdk.CfnOutputProps{Value: dataBrewPipeline.ProductionFunctionArn()})\n\tawscdk.NewCfnOutput(stack, jsii.String(\"OCodeCommitRepoArn\"), &awscdk.CfnOutputProps{Value: dataBrewPipeline.CodeCommitRepoArn()})\n\tawscdk.NewCfnOutput(stack, jsii.String(\"OCodePipelineArn\"), &awscdk.CfnOutputProps{Value: dataBrewPipeline.CodePipelineArn()})\n\n\treturn stack\n}\n\nfunc main() {\n\tdefer jsii.Close()\n\n\tapp := awscdk.NewApp(nil)\n\n\tNewGoLangStack(app, \"GoLangStack\", &GoLangStackProps{\n\t\tawscdk.StackProps{\n\t\t\tEnv: env(),\n\t\t},\n\t})\n\n\tapp.Synth(nil)\n}\n\nfunc env() *awscdk.Environment {\n\treturn nil\n}\n\n```\n\n# Some Efforts after Stack Creation\n\n## CodeCommit\n\n1. Create HTTPS Git credentials for AWS CodeCommit with an IAM user that you're going to use.\n   ![image](https://raw.githubusercontent.com/HsiehShuJeng/cdk-databrew-cicd/main/images/codecommit_credentials.png)\n2. Run through the steps noted on the README.md of the CodeCommit repository after finishing establishing the stack via CDK. The returned message with success should be looked like the following (assume you have installed [`git-remote-codecommit`](https://pypi.org/project/git-remote-codecommit/)):\n\n   ```bash\n   $ git clone codecommit://scott.codecommit@DataBrew-Recipes-Repo\n   Cloning into 'DataBrew-Recipes-Repo'...\n   remote: Counting objects: 6, done.\n   Unpacking objects: 100% (6/6), 2.03 KiB | 138.00 KiB/s, done.\n   ```\n3. Add a DataBrew recipe into the local repositroy (directory) and commit the change. (either directly on the main branch or merging another branch into the main branch)\n\n## Glue DataBrew\n\n1. Download any recipe either generated out by following [*Getting started with AWS Glue DataBrew*](https://docs.aws.amazon.com/zh_tw/databrew/latest/dg/getting-started.html) or made by yourself as **JSON file**.\n   ![image](https://raw.githubusercontent.com/HsiehShuJeng/cdk-databrew-cicd/main/images/databrew_recipes.png)\n2. Move the recipe from the download directory to the local directory for the CodeCommit repository.\n\n   ```bash\n   $ mv ${DOWNLOAD_DIRECTORY}/chess-project-recipe.json ${CODECOMMIT_LOCAL_DIRECTORY}/\n   ```\n3. Commit the change to a branch with a name you prefer.\n\n   ```bash\n   $ cd ${{CODECOMMIT_LOCAL_DIRECTORY}}\n   $ git checkout -b add-recipe main\n   $ git add .\n   $ git commit -m \"first recipe\"\n   $ git push --set-upstream origin add-recipe\n   ```\n4. Merge the branch into the main branch. Just go to the **AWS CodeCommit** web console to do the merge as its process is purely the same as you've already done thousands of times on **Github** but only with different UIs.\n\n# How Successful Commits Look Like\n\n1. In the infrastructure account, the status of the CodePipeline DataBrew pipeline should be similar as the following:\n   ![image](https://raw.githubusercontent.com/HsiehShuJeng/cdk-databrew-cicd/main/images/infra_codepipeline.png)\n2. In the **pre-production** account with the same region as where the CICD pipeline is deployed at the infrastructue account, you'll see this.\n   ![image](https://raw.githubusercontent.com/HsiehShuJeng/cdk-databrew-cicd/main/images/preproduction-recipe.png)\n3. In the **production** account with the same region as where the CICD pipeline is deployed at the infrastructue account, you'll see this.\n   ![image](https://raw.githubusercontent.com/HsiehShuJeng/cdk-databrew-cicd/main/images/production-recipe.png)\n",
    "bugtrack_url": null,
    "license": "Apache-2.0",
    "summary": "A construct for AWS Glue DataBrew wtih CICD",
    "version": "2.0.456",
    "project_urls": {
        "Homepage": "https://github.com/HsiehShuJeng/cdk-databrew-cicd.git",
        "Source": "https://github.com/HsiehShuJeng/cdk-databrew-cicd.git"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "7cf9bc2e71fc4d17aa38f0448fb1fd73a0ec59ca08563ac7be2dfc809548ca13",
                "md5": "b2bf90749777203fee4c1b25ede59a15",
                "sha256": "ab87fa8addfc7a4791beca0775f30d87af5a960aecb3eea5a93438dcc452b0fd"
            },
            "downloads": -1,
            "filename": "cdk_databrew_cicd-2.0.456-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "b2bf90749777203fee4c1b25ede59a15",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "~=3.8",
            "size": 1456292,
            "upload_time": "2024-12-22T01:03:04",
            "upload_time_iso_8601": "2024-12-22T01:03:04.344342Z",
            "url": "https://files.pythonhosted.org/packages/7c/f9/bc2e71fc4d17aa38f0448fb1fd73a0ec59ca08563ac7be2dfc809548ca13/cdk_databrew_cicd-2.0.456-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "ccac49cc09920e547bb5d1f35e079a026991d57a3d08c58101777fcfd59b8df0",
                "md5": "10512cf1721192e8187ca46721703be6",
                "sha256": "808e53bc6c99739494ef14e10143a408cff65ad1fcc183b74fea6a9466ab5d8e"
            },
            "downloads": -1,
            "filename": "cdk_databrew_cicd-2.0.456.tar.gz",
            "has_sig": false,
            "md5_digest": "10512cf1721192e8187ca46721703be6",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "~=3.8",
            "size": 1458635,
            "upload_time": "2024-12-22T01:03:07",
            "upload_time_iso_8601": "2024-12-22T01:03:07.484536Z",
            "url": "https://files.pythonhosted.org/packages/cc/ac/49cc09920e547bb5d1f35e079a026991d57a3d08c58101777fcfd59b8df0/cdk_databrew_cicd-2.0.456.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-12-22 01:03:07",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "HsiehShuJeng",
    "github_project": "cdk-databrew-cicd",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "cdk-databrew-cicd"
}
        
Elapsed time: 0.42205s