# projen-simple
[![License](https://img.shields.io/badge/License-Apache%202.0-green)](https://opensource.org/licenses/Apache-2.0) ![Release](https://github.com/HsiehShuJeng/projen-simple/workflows/Release/badge.svg) [![npm downloads](https://img.shields.io/npm/dt/projen-statemachine-example?label=npm%20downloads&style=plastic)](https://img.shields.io/npm/dt/projen-statemachine-example?label=npm%20downloads&style=plastic) [![pypi downloads](https://img.shields.io/pypi/dm/scotthsieh-projen-statemachine?label=pypi%20downloads&style=plastic)](https://img.shields.io/pypi/dm/scotthsieh-projen-statemachine?label=pypi%20downloads&style=plastic) [![NuGet downloads](https://img.shields.io/nuget/dt/Projen.Statemachine?label=NuGet%20downloads&style=plastic)](https://img.shields.io/nuget/dt/Projen.Statemachine?label=NuGet%20downloads&style=plastic) [![repo languages](https://img.shields.io/github/languages/count/HsiehShuJeng/projen-simple?label=repo%20languages&style=plastic)](https://img.shields.io/github/languages/count/HsiehShuJeng/projen-simple?label=repo%20languages&style=plastic)
| npm (JS/TS) | PyPI (Python) | Maven (Java) | Go | NuGet |
| --- | --- | --- | --- | --- |
| [Link](https://www.npmjs.com/package/projen-simple) | [Link](https://pypi.org/project/scotthsieh_projen_statemachine/) | [Link](https://search.maven.org/artifact/io.github.hsiehshujeng/projen-statemachine) | [Link](https://github.com/HsiehShuJeng/projen-statemachine-go) | [Link](https://www.nuget.org/packages/Projen.Statemachine/) |
Build a custom construct based on an example in an AWS Blog post and use [projen](https://github.com/projen/projen) to publish to 5 language repositories, i.e., npm, PyPI, Central Maven, NuGet, and Go.
# Architecture
This library constrcution is referred to the first example in this AWS blog, [*Introducing Amazon API Gateway service integration for AWS Step Functions*](https://aws.amazon.com/tw/blogs/compute/introducing-amazon-api-gateway-service-integration-for-aws-step-functions/) written by Benjanmin Smith. After you deploy the stack with whatever programming language you like, i.e., Typescript, Python, Java, or C sharp, you'll get a view similar to the following diagram:
![image](https://raw.githubusercontent.com/HsiehShuJeng/projen-simple/main/images/designer_view.png)
# How to utilize polyglot packages and deploy
## TypeScript
```bash
$ cdk --init language typescript
$ yarn add projen-statemachine-example
```
```python
import { StateMachineApiGatewayExample } from 'projen-statemachine-example';
export class TypescriptStack extends cdk.Stack {
constructor(scope: cdk.Construct, id: string, props?: cdk.StackProps) {
super(scope, id, props);
const stageName = 'default';
const partPath = 'pets';
const exampleConstruct = new StateMachineApiGatewayExample(this, 'KerKer', {
stageName: stageName, partPath: partPath});
new cdk.CfnOutput(this, 'OStateMachine', {
value: exampleConstruct.stateMachine.stateMachineArn});
new cdk.CfnOutput(this, 'OExecutionOutput', {
value: exampleConstruct.executionInput, description: 'Sample input to StartExecution.'});
}
```
## Python
```bash
$ cdk init --language python
$ cat <<EOL > requirements.txt
aws-cdk.core
scotthsieh_projen_statemachine
EOL
$ python -m pip install -r requirements.txt
```
```python
from aws_cdk import core as cdk
from scotthsieh_projen_statemachine import StateMachineApiGatewayExample
class PythonStack(cdk.Stack):
def __init__(self, scope: cdk.Construct, construct_id: str, **kwargs) -> None:
super().__init__(scope, construct_id, **kwargs)
stage_name = 'default'
part_path = 'pets'
example_construct = StateMachineApiGatewayExample(
self, 'PythonStatemachne', stage_name=stage_name, part_path=part_path,
)
cdk.CfnOutput(self, "OStateMachine",
value=example_construct.state_machine.state_machine_arn
)
cdk.CfnOutput(self, "OExecutionOutput", value=example_construct.execution_input, description="Sample input to StartExecution.")
```
## Java
```bash
$ cdk init --language java
$ mvn package
```
```xml
.
.
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<custom.construct.version>2.0.474</custom.construct.version>
<cdk.version>2.149.0</cdk.version>
<junit.version>5.7.1</junit.version>
</properties>
.
.
<dependencies>
<!-- AWS Cloud Development Kit -->
.
.
.
<dependency>
<groupId>io.github.hsiehshujeng</groupId>
<artifactId>projen-statemachine</artifactId>
<version>${custom.construct.version}</version>
</dependency>
.
.
.
</dependencies>
```
```java
package com.myorg;
import software.amazon.awscdk.core.Construct;
import software.amazon.awscdk.core.CfnOutput;
import software.amazon.awscdk.core.CfnOutputProps;
import software.amazon.awscdk.core.Stack;
import software.amazon.awscdk.core.StackProps;
import io.github.hsiehshujeng.projen.statemachine.*;
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 stageName = "default";
String partPath = "pets";
StateMachineApiGatewayExample exampleConstruct = new StateMachineApiGatewayExample(this, "KerKer",
StateMachineApiGatewayExampleProps.builder()
.stageName(stageName)
.partPath(partPath)
.build());
new CfnOutput(this, "OStateMachine",
CfnOutputProps.builder()
.value(exampleConstruct.getStateMachine().getStateMachineArn())
.build());
new CfnOutput(this, "OExecutionOutput", CfnOutputProps.builder()
.value(exampleConstruct.getExecutionInput())
.description("Sample input to StartExecution.")
.build());
}
}
```
## C#
```bash
$ cdk init --language csharp
$ dotnet add src/Csharp package Projen.Statemachine --version 2.0.474
```
```cs
using Amazon.CDK;
using ScottHsieh.Examples;
namespace Csharp
{
public class CsharpStack : Stack
{
internal CsharpStack(Construct scope, string id, IStackProps props = null) : base(scope, id, props)
{
string stageName = "default";
string partPath = "pets";
var exampleConstruct = new StateMachineApiGatewayExample(this, "KerKer", new StateMachineApiGatewayExampleProps
{
StageName = stageName,
PartPath = partPath
});
new CfnOutput(this, "OStateMachine", new CfnOutputProps
{
Value = exampleConstruct.StateMachine.StateMachineArn
});
new CfnOutput(this, "OExecutionOutput", new CfnOutputProps
{
Value = exampleConstruct.ExecutionInput,
Description = "Sample input to StartExecution."
});
}
}
}
```
# References
* [jsii reference](https://github.com/cdklabs/jsii-release)
* [aws-cdk-go](https://github.com/aws/aws-cdk-go)
* [jsii](https://github.com/aws/jsii)
Raw data
{
"_id": null,
"home_page": "https://github.com/HsiehShuJeng/projen-simple.git",
"name": "scotthsieh-projen-statemachine",
"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/a7/11/4c64f3e48e6326cde077b05c136c417861d9b0f4c0d9d226e45eb9d8be8a/scotthsieh_projen_statemachine-2.0.598.tar.gz",
"platform": null,
"description": "# projen-simple\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/projen-simple/workflows/Release/badge.svg) [![npm downloads](https://img.shields.io/npm/dt/projen-statemachine-example?label=npm%20downloads&style=plastic)](https://img.shields.io/npm/dt/projen-statemachine-example?label=npm%20downloads&style=plastic) [![pypi downloads](https://img.shields.io/pypi/dm/scotthsieh-projen-statemachine?label=pypi%20downloads&style=plastic)](https://img.shields.io/pypi/dm/scotthsieh-projen-statemachine?label=pypi%20downloads&style=plastic) [![NuGet downloads](https://img.shields.io/nuget/dt/Projen.Statemachine?label=NuGet%20downloads&style=plastic)](https://img.shields.io/nuget/dt/Projen.Statemachine?label=NuGet%20downloads&style=plastic) [![repo languages](https://img.shields.io/github/languages/count/HsiehShuJeng/projen-simple?label=repo%20languages&style=plastic)](https://img.shields.io/github/languages/count/HsiehShuJeng/projen-simple?label=repo%20languages&style=plastic)\n\n| npm (JS/TS) | PyPI (Python) | Maven (Java) | Go | NuGet |\n| --- | --- | --- | --- | --- |\n| [Link](https://www.npmjs.com/package/projen-simple) | [Link](https://pypi.org/project/scotthsieh_projen_statemachine/) | [Link](https://search.maven.org/artifact/io.github.hsiehshujeng/projen-statemachine) | [Link](https://github.com/HsiehShuJeng/projen-statemachine-go) | [Link](https://www.nuget.org/packages/Projen.Statemachine/) |\n\nBuild a custom construct based on an example in an AWS Blog post and use [projen](https://github.com/projen/projen) to publish to 5 language repositories, i.e., npm, PyPI, Central Maven, NuGet, and Go.\n\n# Architecture\n\nThis library constrcution is referred to the first example in this AWS blog, [*Introducing Amazon API Gateway service integration for AWS Step Functions*](https://aws.amazon.com/tw/blogs/compute/introducing-amazon-api-gateway-service-integration-for-aws-step-functions/) written by Benjanmin Smith. After you deploy the stack with whatever programming language you like, i.e., Typescript, Python, Java, or C sharp, you'll get a view similar to the following diagram:\n![image](https://raw.githubusercontent.com/HsiehShuJeng/projen-simple/main/images/designer_view.png)\n\n# How to utilize polyglot packages and deploy\n\n## TypeScript\n\n```bash\n$ cdk --init language typescript\n$ yarn add projen-statemachine-example\n```\n\n```python\nimport { StateMachineApiGatewayExample } from 'projen-statemachine-example';\n\n export class TypescriptStack extends cdk.Stack {\n constructor(scope: cdk.Construct, id: string, props?: cdk.StackProps) {\n super(scope, id, props);\n\n const stageName = 'default';\n const partPath = 'pets';\n const exampleConstruct = new StateMachineApiGatewayExample(this, 'KerKer', {\n stageName: stageName, partPath: partPath});\n\n new cdk.CfnOutput(this, 'OStateMachine', {\n value: exampleConstruct.stateMachine.stateMachineArn});\n new cdk.CfnOutput(this, 'OExecutionOutput', {\n value: exampleConstruct.executionInput, description: 'Sample input to StartExecution.'});\n }\n```\n\n## Python\n\n```bash\n$ cdk init --language python\n$ cat <<EOL > requirements.txt\naws-cdk.core\nscotthsieh_projen_statemachine\nEOL\n$ python -m pip install -r requirements.txt\n```\n\n```python\nfrom aws_cdk import core as cdk\nfrom scotthsieh_projen_statemachine import StateMachineApiGatewayExample\n\nclass PythonStack(cdk.Stack):\n def __init__(self, scope: cdk.Construct, construct_id: str, **kwargs) -> None:\n super().__init__(scope, construct_id, **kwargs)\n\n stage_name = 'default'\n part_path = 'pets'\n example_construct = StateMachineApiGatewayExample(\n self, 'PythonStatemachne', stage_name=stage_name, part_path=part_path,\n )\n\n cdk.CfnOutput(self, \"OStateMachine\",\n value=example_construct.state_machine.state_machine_arn\n )\n cdk.CfnOutput(self, \"OExecutionOutput\", value=example_construct.execution_input, description=\"Sample input to StartExecution.\")\n```\n\n## 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 <custom.construct.version>2.0.474</custom.construct.version>\n <cdk.version>2.149.0</cdk.version>\n <junit.version>5.7.1</junit.version>\n </properties>\n .\n .\n <dependencies>\n <!-- AWS Cloud Development Kit -->\n .\n .\n .\n <dependency>\n <groupId>io.github.hsiehshujeng</groupId>\n <artifactId>projen-statemachine</artifactId>\n <version>${custom.construct.version}</version>\n </dependency>\n .\n .\n .\n </dependencies>\n```\n\n```java\npackage com.myorg;\n\nimport software.amazon.awscdk.core.Construct;\nimport software.amazon.awscdk.core.CfnOutput;\nimport software.amazon.awscdk.core.CfnOutputProps;\nimport software.amazon.awscdk.core.Stack;\nimport software.amazon.awscdk.core.StackProps;\nimport io.github.hsiehshujeng.projen.statemachine.*;\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\n String stageName = \"default\";\n String partPath = \"pets\";\n StateMachineApiGatewayExample exampleConstruct = new StateMachineApiGatewayExample(this, \"KerKer\",\n StateMachineApiGatewayExampleProps.builder()\n .stageName(stageName)\n .partPath(partPath)\n .build());\n\n new CfnOutput(this, \"OStateMachine\",\n CfnOutputProps.builder()\n .value(exampleConstruct.getStateMachine().getStateMachineArn())\n .build());\n new CfnOutput(this, \"OExecutionOutput\", CfnOutputProps.builder()\n .value(exampleConstruct.getExecutionInput())\n .description(\"Sample input to StartExecution.\")\n .build());\n }\n }\n```\n\n## C#\n\n```bash\n$ cdk init --language csharp\n$ dotnet add src/Csharp package Projen.Statemachine --version 2.0.474\n```\n\n```cs\nusing Amazon.CDK;\nusing ScottHsieh.Examples;\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 string stageName = \"default\";\n string partPath = \"pets\";\n\n var exampleConstruct = new StateMachineApiGatewayExample(this, \"KerKer\", new StateMachineApiGatewayExampleProps\n {\n StageName = stageName,\n PartPath = partPath\n });\n\n new CfnOutput(this, \"OStateMachine\", new CfnOutputProps\n {\n Value = exampleConstruct.StateMachine.StateMachineArn\n });\n new CfnOutput(this, \"OExecutionOutput\", new CfnOutputProps\n {\n Value = exampleConstruct.ExecutionInput,\n Description = \"Sample input to StartExecution.\"\n });\n }\n }\n }\n```\n\n# References\n\n* [jsii reference](https://github.com/cdklabs/jsii-release)\n* [aws-cdk-go](https://github.com/aws/aws-cdk-go)\n* [jsii](https://github.com/aws/jsii)\n",
"bugtrack_url": null,
"license": "Apache-2.0",
"summary": "An example construct for deploying to npm, PyPi, Maven, and Nuget with Amazon API Gateway and AWS Step Functions.",
"version": "2.0.598",
"project_urls": {
"Homepage": "https://github.com/HsiehShuJeng/projen-simple.git",
"Source": "https://github.com/HsiehShuJeng/projen-simple.git"
},
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "2eff927d72a06cd3c04343a3c47ac44686b1307e39497ccc38cfc3b93bb44fee",
"md5": "c1c6704ff77a0753af8aed0e623d1dad",
"sha256": "15a1f3fee9d18ab12157692ffd61e78a2cc0e3df71cc59ef1ee9b0bcb7692188"
},
"downloads": -1,
"filename": "scotthsieh_projen_statemachine-2.0.598-py3-none-any.whl",
"has_sig": false,
"md5_digest": "c1c6704ff77a0753af8aed0e623d1dad",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": "~=3.8",
"size": 1508109,
"upload_time": "2024-12-22T01:43:25",
"upload_time_iso_8601": "2024-12-22T01:43:25.698244Z",
"url": "https://files.pythonhosted.org/packages/2e/ff/927d72a06cd3c04343a3c47ac44686b1307e39497ccc38cfc3b93bb44fee/scotthsieh_projen_statemachine-2.0.598-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "a7114c64f3e48e6326cde077b05c136c417861d9b0f4c0d9d226e45eb9d8be8a",
"md5": "7f5621ea0b4dfbc6cac1393ece8b7430",
"sha256": "5ae2e3270578a473f8e4ba51360a55982b2f31108078fab3c823f512d4fb254a"
},
"downloads": -1,
"filename": "scotthsieh_projen_statemachine-2.0.598.tar.gz",
"has_sig": false,
"md5_digest": "7f5621ea0b4dfbc6cac1393ece8b7430",
"packagetype": "sdist",
"python_version": "source",
"requires_python": "~=3.8",
"size": 1509534,
"upload_time": "2024-12-22T01:43:28",
"upload_time_iso_8601": "2024-12-22T01:43:28.905677Z",
"url": "https://files.pythonhosted.org/packages/a7/11/4c64f3e48e6326cde077b05c136c417861d9b0f4c0d9d226e45eb9d8be8a/scotthsieh_projen_statemachine-2.0.598.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-12-22 01:43:28",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "HsiehShuJeng",
"github_project": "projen-simple",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "scotthsieh-projen-statemachine"
}