Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(custom-resources): state machine provider #7979

Closed
wants to merge 5 commits into from

Conversation

jogold
Copy link
Contributor

@jogold jogold commented May 14, 2020

Add a state machine custom resource provider.

It uses the nested workflow pattern where the "user" state machine is started
as a task in the provider state machine. This allows to set a timeout for the
custom resource.

This could be used as a base for a Fargate task custom resource provider.

Closes #6505

TODO:

  • README
  • Unit tests

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license

Add a state machine custom resource provider.

It uses the nested workflow pattern where the "user" state machine is started
as a task in the provider state machine. This allows to set a timeout for the
custom resource.

This could be used as a base for a Fargate task custom resource provider.

Closes aws#6505
@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildProject6AEA49D1-qxepHUsryhcu
  • Commit ID: 6450f5c
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildProject6AEA49D1-qxepHUsryhcu
  • Commit ID: 82cc9d8
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@jogold
Copy link
Contributor Author

jogold commented Jun 6, 2020

Combined with tasks.EvaluateExpression it can be really powerful, here is how you can do the CfnJson from core:

const stateMachine = new sfn.StateMachine(stack, 'SM', {
  definition: new sfn.Task(stack, 'JSON', {
    task: new tasks.EvaluateExpression({
      expression: 'JSON.parse($.ResourceProperties.Value)',
    }),
    resultPath: '$.Data',
  }),
});

new cdk.CustomResource(stack, 'CR', {
  serviceToken: new cr.StateMachineProvider(stack, 'SMP', { stateMachine }).serviceToken,
  properties: {
    Value: JSON.stringify({ key1: 'value1', key2: 'value2' }),
  },
});

A good "LOC to deployed infra" ratio 😄

@eladb
Copy link
Contributor

eladb commented Jun 7, 2020

Combined with tasks.EvaluateExpression it can be really powerful, here is how you can do the CfnJson from core:

const stateMachine = new sfn.StateMachine(stack, 'SM', {

  definition: new sfn.Task(stack, 'JSON', {

    task: new tasks.EvaluateExpression({

      expression: 'JSON.parse($.ResourceProperties.Value)',

    }),

    resultPath: '$.Data',

  }),

});



new cdk.CustomResource(stack, 'CR', {

  serviceToken: new cr.StateMachineProvider(stack, 'SMP', { stateMachine }).serviceToken,

  properties: {

    Value: JSON.stringify({ key1: 'value1', key2: 'value2' }),

  },

});

A good "LOC to deployed infra" ratio 😄

Wow very powerful.

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildProject6AEA49D1-qxepHUsryhcu
  • Commit ID: e28b483
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@eladb
Copy link
Contributor

eladb commented Aug 4, 2020

I am closing this for now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

State machine custom resource
3 participants