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: add AWS state machine component #184

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from

Conversation

ryankee
Copy link

@ryankee ryankee commented Apr 5, 2024

Hey all – I needed AWS step functions so I added in a state machine component. This more or less copies the Function component, but with Pulumi's aws.sfn.StateMachine. I don't love wrapping a definition with an all, so any feedback there would be great.

Here's a quick example of usage:

/// <reference path="./.sst/platform/config.d.ts" />
import { all } from "@pulumi/pulumi";

const myFunction = new sst.aws.Function("MyFunction", {...}); 

const myQueue = new sst.aws.Queue("MyQueue", {...})    

const stateMachine = new sst.aws.StateMachine("MyStateMachine", {
  link: [
    myFunction,
    myQueue,
  ],
  definition: all([
    myFunction.arn,
    myQueue.url,
  ]).apply(
    ([
      myFunctionArn,
      myQueueUrl,
    ]) =>
      JSON.stringify({
        "Comment": "A basic example of a state machine",
        "StartAt": "FirstTask",
        "States": {
          "FirstTask": {
            "Type": "Task",
            "Resource": myFunctionArn,
            "InputPath": "$",
            "Next": "SecondTask",
          },
          "SecondTask": {
            "Type": "Task",
            "Resource": "arn:aws:states:::sqs:sendMessage",
            "InputPath": "$",
            "Parameters": {
              "QueueUrl": myQueueUrl,
              "MessageBody": {
                "Input.$": "$",
              },
              "MessageGroupId.$": "$$.Execution.Id",
            },
            "End": true,
          },
        },
      })
  ),
});

@ryankee ryankee changed the title Added AWS state machine component feat: add AWS state machine component Apr 5, 2024
@subvertallchris
Copy link

Hey @ryankee, I'm just getting started with Ion and have a need for this, I was happy to see it. How is it working out for you?

@subvertallchris
Copy link

I'm happy to report that we are using a copy/paste of this PR's code and it is working wonderfully. We had to add aws.iam.ManagedPolicy.LambdaFullAccess to managedPolicyArns but otherwise no meaningful changes.

I'd love to see this merged. My locally implementation does some nasty things during deploy to work around the lack of .sst prior to first run of sst install.

@laeijebor laeijebor mentioned this pull request May 14, 2024
@jayair jayair requested a review from fwang May 14, 2024 17:44
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.

None yet

2 participants