Skip to main content

An example construct for deploying to npm, PyPi, Maven, and Nuget with Amazon API Gateway and AWS Step Functions.

Project description


License Release npm downloads pypi downloads NuGet downloads repo languages

npm (JS/TS) PyPI (Python) Maven (Java) Go NuGet
Link Link Link Link Link

Build a custom construct based on an example in an AWS Blog post and use projen to publish to 5 language repositories, i.e., npm, PyPI, Central Maven, NuGet, and Go.


This library constrcution is referred to the first example in this AWS blog, 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

How to utilize polyglot packages and deploy


$ cdk --init language typescript
$ yarn add projen-statemachine-example
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.'});


$ cdk init --language python
$ cat <<EOL > requirements.txt
$ python -m pip install -r requirements.txt
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",
         cdk.CfnOutput(self, "OExecutionOutput", value=example_construct.execution_input, description="Sample input to StartExecution.")


$ cdk init --language java
$ mvn package
     <!-- AWS Cloud Development Kit -->
package com.myorg;

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",

         new CfnOutput(this, "OStateMachine",
         new CfnOutput(this, "OExecutionOutput", CfnOutputProps.builder()
             .description("Sample input to StartExecution.")


$ cdk init --language csharp
$ dotnet add src/Csharp package Projen.Statemachine --version 0.1.21
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."


Project details

Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

Built Distribution

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page