Package: scotthsieh-projen-statemachine
projen-simplenpm (JS/TS)PyPI (Python)Maven (Java)GoNuGetLinkLinkLinkLinkLinkBuild a custom construct based on an example in an AWS Blog post and useprojento publish to 5 language repositories, i.e., npm, PyPI, Central Maven, NuGet, and Go.ArchitectureThis library constrcution is referred to the first example in this AWS blog,Introducing Amazon API Gateway service integration for AWS Step Functionswritten 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:How to utilize polyglot packages and deployTypeScript$cdk--initlanguagetypescript
$yarnaddprojen-statemachine-exampleimport{StateMachineApiGatewayExample}from'projen-statemachine-example';exportclassTypescriptStackextendscdk.Stack{constructor(scope:cdk.Construct,id:string,props?:cdk.StackProps){super(scope,id,props);conststageName='default';constpartPath='pets';constexampleConstruct=newStateMachineApiGatewayExample(this,'KerKer',{stageName:stageName,partPath:partPath});newcdk.CfnOutput(this,'OStateMachine',{value:exampleConstruct.stateMachine.stateMachineArn});newcdk.CfnOutput(this,'OExecutionOutput',{value:exampleConstruct.executionInput,description:'Sample input to StartExecution.'});}Python$cdkinit--languagepython
$cat<<EOL > requirements.txtaws-cdk.corescotthsieh_projen_statemachineEOL$python-mpipinstall-rrequirements.txtfromaws_cdkimportcoreascdkfromscotthsieh_projen_statemachineimportStateMachineApiGatewayExampleclassPythonStack(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$cdkinit--languagejava
$mvnpackage.
.<properties><project.build.sourceEncoding>UTF-8</project.build.sourceEncoding><custom.construct.version>0.1.20</custom.construct.version><cdk.version>1.104.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>packagecom.myorg;importsoftware.amazon.awscdk.core.Construct;importsoftware.amazon.awscdk.core.CfnOutput;importsoftware.amazon.awscdk.core.CfnOutputProps;importsoftware.amazon.awscdk.core.Stack;importsoftware.amazon.awscdk.core.StackProps;importio.github.hsiehshujeng.projen.statemachine.*;publicclassJavaStackextendsStack{publicJavaStack(finalConstructscope,finalStringid){this(scope,id,null);}publicJavaStack(finalConstructscope,finalStringid,finalStackPropsprops){super(scope,id,props);StringstageName="default";StringpartPath="pets";StateMachineApiGatewayExampleexampleConstruct=newStateMachineApiGatewayExample(this,"KerKer",StateMachineApiGatewayExampleProps.builder().stageName(stageName).partPath(partPath).build());newCfnOutput(this,"OStateMachine",CfnOutputProps.builder().value(exampleConstruct.getStateMachine().getStateMachineArn()).build());newCfnOutput(this,"OExecutionOutput",CfnOutputProps.builder().value(exampleConstruct.getExecutionInput()).description("Sample input to StartExecution.").build());}}C#$cdkinit--languagecsharp
$dotnetaddsrc/CsharppackageProjen.Statemachine--version0.1.21usingAmazon.CDK;usingScottHsieh.Examples;namespaceCsharp{publicclassCsharpStack:Stack{internalCsharpStack(Constructscope,stringid,IStackPropsprops=null):base(scope,id,props){stringstageName="default";stringpartPath="pets";varexampleConstruct=newStateMachineApiGatewayExample(this,"KerKer",newStateMachineApiGatewayExampleProps{StageName=stageName,PartPath=partPath});newCfnOutput(this,"OStateMachine",newCfnOutputProps{Value=exampleConstruct.StateMachine.StateMachineArn});newCfnOutput(this,"OExecutionOutput",newCfnOutputProps{Value=exampleConstruct.ExecutionInput,Description="Sample input to StartExecution."});}}}Referencesjsii referenceaws-cdk-gojsii