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

Step functions tasks do not correctly resolve imports/exports #3412

Closed
1 of 5 tasks
jogold opened this issue Jul 24, 2019 · 1 comment
Closed
1 of 5 tasks

Step functions tasks do not correctly resolve imports/exports #3412

jogold opened this issue Jul 24, 2019 · 1 comment
Assignees
Labels
@aws-cdk/aws-stepfunctions Related to AWS StepFunctions needs-triage This issue or PR still needs to be triaged.

Comments

@jogold
Copy link
Contributor

jogold commented Jul 24, 2019

  • I'm submitting a ...

    • πŸͺ² bug report
    • πŸš€ feature request
    • πŸ“š construct library gap
    • ☎️ security issue or vulnerability => Please see policy
    • ❓ support request => Please see note at the top of this template.
  • What is the current behavior?
    The following code:

  const app = new App();

  // STACK1
  const stack1 = new Stack(app, 'stack1');
  const user = new iam.User(stack1, 'User');

  // STACK2
  const stack2 = new Stack(app, 'stack2');
  const taskFn = new lambda.Function(stack2, 'Function', {
    code: lambda.Code.inline('hello'),
    handler: 'index.handler',
    runtime: lambda.Runtime.NODEJS_8_10,
  });

  const task = new sfn.Task(stack2, 'Task', {
    task: new tasks.RunLambdaTask(taskFn, {
      payload: {
        userName: user.userName// import user from stack1
      },
    }),
  });

  new sfn.StateMachine(stack2, 'SM', {
    definition: task,
  });

results in the following DefinitionString in the AWS::StepFunctions::StateMachine resource (note the incorrect Ref on the user, User00B015A1 does not exist in this stack):

{
  "Fn::Join": [
    "",
    [
      "{\"StartAt\":\"Task\",\"States\":{\"Task\":{\"End\":true,\"Parameters\":{\"FunctionName\":\"",
      {
        "Ref": "Function76856677"
      },
      "\",\"Payload\":{\"userName\":\"",
      {
        "Ref": "User00B015A1"
      },
      "\"}},\"Type\":\"Task\",\"Resource\":\"arn:aws:states:::lambda:invoke\"}}}"
    ]
  ]
}

Now if we change the new sfn.StateMachine statement to add a name using the user name (to import it on a prop where it's correctly resolved):

new sfn.StateMachine(stack2, 'SM', {
  definition: task,
  stateMachineName: user.userName // use imported user name as machine name
});

Both DefinitionString and StateMachineName in the AWS::StepFunctions::StateMachine resource use a correct Fn::ImportValue:

{
  "DefinitionString": {
    "Fn::Join": [
      "",
      [
        "{\"StartAt\":\"Task\",\"States\":{\"Task\":{\"End\":true,\"Parameters\":{\"FunctionName\":\"",
        {
          "Ref": "Function76856677"
        },
        "\",\"Payload\":{\"userName\":\"",
        {
          "Fn::ImportValue": "stack1:ExportsOutputRefUser00B015A11BEAACCF"
        },
        "\"}},\"Type\":\"Task\",\"Resource\":\"arn:aws:states:::lambda:invoke\"}}}"
      ]
    ]
  },
  "RoleArn": {
    "Fn::GetAtt": [
      "SMRole49C19C48",
      "Arn"
    ]
  },
  "StateMachineName": {
    "Fn::ImportValue": "stack1:ExportsOutputRefUser00B015A11BEAACCF"
  }
}
  • What is the expected behavior (or behavior of feature suggested)?
    Import/export should work in step functions tasks

  • Please tell us about your environment:

    • CDK CLI Version: 1.0.0
    • Module Version: 1.0.0
    • OS: all
    • Language: all
@jogold jogold added the needs-triage This issue or PR still needs to be triaged. label Jul 24, 2019
@jogold jogold changed the title Step functions tasks do not correctly resolve import/exports Step functions tasks do not correctly resolve imports/exports Jul 24, 2019
@eladb eladb added the @aws-cdk/aws-stepfunctions Related to AWS StepFunctions label Aug 13, 2019
@jogold
Copy link
Contributor Author

jogold commented Aug 19, 2019

Fixed by #3568

@jogold jogold closed this as completed Aug 19, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@aws-cdk/aws-stepfunctions Related to AWS StepFunctions needs-triage This issue or PR still needs to be triaged.
Projects
None yet
Development

No branches or pull requests

3 participants