statemachine

package module
v0.0.15 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 7, 2022 License: Apache-2.0 Imports: 9 Imported by: 0

README

Workflow Studio compatible State Machine

This is a Workflow Studio compatible AWS Step Function state machine construct.

The goal of this construct is to make it easy to build and maintain your state machines using the Workflow Studio but still leverage the AWS CDK as the source of truth for the state machine.

Read more about it here.

How to Use This Construct

Start by designing your initial state machine using the Workflow Studio. When done with your first draft, copy and paste the ASL definition to a local file.

Create a new instance of this construct, handing it a fully parsed version of the ASL. Then add overridden values. The fields in the overrides field should match the States field of the ASL.

const secret = new Secret(stack, 'Secret', {});
new StateMachine(stack, 'Test', {
  stateMachineName: 'A nice state machine',
  definition: JSON.parse(fs.readFileSync(path.join(__dirname, 'sample.json'), 'utf8').toString()),
  overrides: {
    'Read database credentials secret': {
      Parameters: {
        SecretId: secret.secretArn,
      },
    },
  },
});

In this example, the ASL has a state called 'Read database credentials secret' and the SecretId parameter is overridden with a CDK generated value. Future changes can be done by editing, debugging, and testing the state machine directly in the Workflow Studio. Once everything is working properly, copy and paste the ASL back to your local file.

Issues

Please open any issues you have on Github.

Contributing

Please submit PRs from forked repositories if you'd like to contribute.

Documentation

Overview

A Step Function state machine construct focused on working well with the Workflow Studio

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewStateMachine_Override

func NewStateMachine_Override(s StateMachine, scope constructs.Construct, id *string, props *StateMachineProps)

func StateMachine_FromStateMachineArn

func StateMachine_FromStateMachineArn(scope constructs.Construct, id *string, stateMachineArn *string) awsstepfunctions.IStateMachine

Import a state machine.

func StateMachine_IsConstruct

func StateMachine_IsConstruct(x interface{}) *bool

Checks if `x` is a construct.

Returns: true if `x` is an object created from a class which extends `Construct`. Deprecated: use `x instanceof Construct` instead.

func StateMachine_IsResource

func StateMachine_IsResource(construct constructs.IConstruct) *bool

Check whether the given construct is a Resource.

func StateMachine_Smash

func StateMachine_Smash(definition interface{}, smash interface{}) interface{}

Types

type StateMachine

type StateMachine interface {
	awsstepfunctions.StateMachine
	// The environment this resource belongs to.
	//
	// For resources that are created and managed by the CDK
	// (generally, those created by creating new class instances like Role, Bucket, etc.),
	// this is always the same as the environment of the stack they belong to;
	// however, for imported resources
	// (those obtained from static methods like fromRoleArn, fromBucketName, etc.),
	// that might be different than the stack they were imported into.
	Env() *awscdk.ResourceEnvironment
	// The principal this state machine is running as.
	GrantPrincipal() awsiam.IPrincipal
	// The tree node.
	Node() constructs.Node
	// Returns a string-encoded token that resolves to the physical name that should be passed to the CloudFormation resource.
	//
	// This value will resolve to one of the following:
	// - a concrete value (e.g. `"my-awesome-bucket"`)
	// - `undefined`, when a name should be generated by CloudFormation
	// - a concrete name generated automatically during synthesis, in
	//    cross-environment scenarios.
	PhysicalName() *string
	// Execution role of this state machine.
	Role() awsiam.IRole
	// The stack in which this resource is defined.
	Stack() awscdk.Stack
	// The ARN of the state machine.
	StateMachineArn() *string
	// The name of the state machine.
	StateMachineName() *string
	// Type of the state machine.
	StateMachineType() awsstepfunctions.StateMachineType
	// Add the given statement to the role's policy.
	AddToRolePolicy(statement awsiam.PolicyStatement)
	// Apply the given removal policy to this resource.
	//
	// The Removal Policy controls what happens to this resource when it stops
	// being managed by CloudFormation, either because you've removed it from the
	// CDK application or because you've made a change that requires the resource
	// to be replaced.
	//
	// The resource can be deleted (`RemovalPolicy.DESTROY`), or left in your AWS
	// account for data recovery and cleanup later (`RemovalPolicy.RETAIN`).
	ApplyRemovalPolicy(policy awscdk.RemovalPolicy)
	GeneratePhysicalName() *string
	// Returns an environment-sensitive token that should be used for the resource's "ARN" attribute (e.g. `bucket.bucketArn`).
	//
	// Normally, this token will resolve to `arnAttr`, but if the resource is
	// referenced across environments, `arnComponents` will be used to synthesize
	// a concrete ARN with the resource's physical name. Make sure to reference
	// `this.physicalName` in `arnComponents`.
	GetResourceArnAttribute(arnAttr *string, arnComponents *awscdk.ArnComponents) *string
	// Returns an environment-sensitive token that should be used for the resource's "name" attribute (e.g. `bucket.bucketName`).
	//
	// Normally, this token will resolve to `nameAttr`, but if the resource is
	// referenced across environments, it will be resolved to `this.physicalName`,
	// which will be a concrete name.
	GetResourceNameAttribute(nameAttr *string) *string
	// Grant the given identity custom permissions.
	Grant(identity awsiam.IGrantable, actions ...*string) awsiam.Grant
	// Grant the given identity permissions on all executions of the state machine.
	GrantExecution(identity awsiam.IGrantable, actions ...*string) awsiam.Grant
	// Grant the given identity permissions to read results from state machine.
	GrantRead(identity awsiam.IGrantable) awsiam.Grant
	// Grant the given identity permissions to start an execution of this state machine.
	GrantStartExecution(identity awsiam.IGrantable) awsiam.Grant
	// Grant the given identity permissions to start a synchronous execution of this state machine.
	GrantStartSyncExecution(identity awsiam.IGrantable) awsiam.Grant
	// Grant the given identity task response permissions on a state machine.
	GrantTaskResponse(identity awsiam.IGrantable) awsiam.Grant
	// Return the given named metric for this State Machine's executions.
	Metric(metricName *string, props *awscloudwatch.MetricOptions) awscloudwatch.Metric
	// Metric for the number of executions that were aborted.
	MetricAborted(props *awscloudwatch.MetricOptions) awscloudwatch.Metric
	// Metric for the number of executions that failed.
	MetricFailed(props *awscloudwatch.MetricOptions) awscloudwatch.Metric
	// Metric for the number of executions that were started.
	MetricStarted(props *awscloudwatch.MetricOptions) awscloudwatch.Metric
	// Metric for the number of executions that succeeded.
	MetricSucceeded(props *awscloudwatch.MetricOptions) awscloudwatch.Metric
	// Metric for the number of executions that were throttled.
	MetricThrottled(props *awscloudwatch.MetricOptions) awscloudwatch.Metric
	// Metric for the interval, in milliseconds, between the time the execution starts and the time it closes.
	MetricTime(props *awscloudwatch.MetricOptions) awscloudwatch.Metric
	// Metric for the number of executions that timed out.
	MetricTimedOut(props *awscloudwatch.MetricOptions) awscloudwatch.Metric
	// Returns a string representation of this construct.
	ToString() *string
}

func NewStateMachine

func NewStateMachine(scope constructs.Construct, id *string, props *StateMachineProps) StateMachine

type StateMachineProps

type StateMachineProps struct {
	// An object that can be serialized into an ASL.
	Definition interface{} `json:"definition" yaml:"definition"`
	// Defines what execution history events are logged and where they are logged.
	Logs *awsstepfunctions.LogOptions `json:"logs" yaml:"logs"`
	// An object that matches the schema/shape of the ASL .States map with overridden values.
	//
	// Example:
	//   {'My First State': { Parameters: { FunctionName: 'aLambdaFunctionArn' } } }
	//
	Overrides interface{} `json:"overrides" yaml:"overrides"`
	// The execution role for the state machine service.
	Role awsiam.IRole `json:"role" yaml:"role"`
	// A name for the state machine.
	StateMachineName *string `json:"stateMachineName" yaml:"stateMachineName"`
	// Type of the state machine.
	StateMachineType awsstepfunctions.StateMachineType `json:"stateMachineType" yaml:"stateMachineType"`
	// Maximum run time for this state machine.
	Timeout awscdk.Duration `json:"timeout" yaml:"timeout"`
	// Specifies whether Amazon X-Ray tracing is enabled for this state machine.
	TracingEnabled *bool `json:"tracingEnabled" yaml:"tracingEnabled"`
}

Directories

Path Synopsis
Package jsii contains the functionaility needed for jsii packages to initialize their dependencies and themselves.
Package jsii contains the functionaility needed for jsii packages to initialize their dependencies and themselves.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL