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

(CLI): Hotswap raises Invalid Arn when updating state machine definition #17716

Closed
fab-mindflow opened this issue Nov 25, 2021 · 5 comments · Fixed by #17892
Closed

(CLI): Hotswap raises Invalid Arn when updating state machine definition #17716

fab-mindflow opened this issue Nov 25, 2021 · 5 comments · Fixed by #17892
Assignees
Labels
bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. p1 package/tools Related to AWS CDK Tools or CLI

Comments

@fab-mindflow
Copy link

What is the problem?

CDK deploy with hotswap fails with Invalid ARN prefix error as follows when updating a state definition :

> cdk deploy --hotswap

.......

MyWorkflow123456 failed: InvalidArn: Invalid Arn: 'Invalid ARN prefix: MyWorkflow123456'
    at Request.extractError (####/node_modules/aws-cdk/node_modules/aws-sdk/lib/protocol/json.js:52:27)
    at Request.callListeners (####/node_modules/aws-cdk/node_modules/aws-sdk/lib/sequential_executor.js:106:20)
    at Request.emit (####/node_modules/aws-cdk/node_modules/aws-sdk/lib/sequential_executor.js:78:10)
    at Request.emit (####/node_modules/aws-cdk/node_modules/aws-sdk/lib/request.js:688:14)
    at Request.transition (####/node_modules/aws-cdk/node_modules/aws-sdk/lib/request.js:22:10)
    at AcceptorStateMachine.runTo (####/node_modules/aws-cdk/node_modules/aws-sdk/lib/state_machine.js:14:12)
    at ####/node_modules/aws-cdk/node_modules/aws-sdk/lib/state_machine.js:26:10
    at Request.<anonymous> (####/node_modules/aws-cdk/node_modules/aws-sdk/lib/request.js:38:9)
    at Request.<anonymous> (####/node_modules/aws-cdk/node_modules/aws-sdk/lib/request.js:690:12)
    at Request.callListeners (####/node_modules/aws-cdk/node_modules/aws-sdk/lib/sequential_executor.js:116:18) {
  code: 'InvalidArn',
  time: 2021-11-25T16:08:44.977Z,
  requestId: '###################',
  statusCode: 400,
  retryable: false,
  retryDelay: 40.19606554280166
}
Invalid Arn: 'Invalid ARN prefix: MyWorkflow123456'

This may be due to this:

// even though the name of the property is stateMachineArn, passing the name of the state machine is allowed here

Reproduction Steps

Deploying with --hotswap a state machine in my AWS / CDK environment. A normal deploy (without hotswap) works fine.

What did you expect to happen?

AWS Step Functions State machine updated successfully with hotswap.

What actually happened?

Command line failure to update AWS Step Functions state machine.

CDK CLI Version

1.134.0 (build dd5e12d)

Framework Version

No response

Node.js Version

16.13.0

OS

macOS 12.0.1 (Monterey)

Language

Typescript

Language Version

4.4.3

Other information

No response

@fab-mindflow fab-mindflow added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Nov 25, 2021
@github-actions github-actions bot added the @aws-cdk/aws-lambda Related to AWS Lambda label Nov 25, 2021
@nija-at nija-at added package/tools Related to AWS CDK Tools or CLI and removed @aws-cdk/aws-lambda Related to AWS Lambda labels Dec 2, 2021
@nija-at nija-at assigned rix0rrr and skinny85 and unassigned nija-at and rix0rrr Dec 2, 2021
@skinny85 skinny85 changed the title (@aws-cdk/aws-stepfunctions): Hotswap raises Invalid Arn when updating state machine definition (CLI): Hotswap raises Invalid Arn when updating state machine definition Dec 3, 2021
@skinny85
Copy link
Contributor

skinny85 commented Dec 3, 2021

Hi @fab-mindflow,

thanks for opening the issue. Can you show your CDK code that raises this error?

Thanks,
Adam

@skinny85 skinny85 added the response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days. label Dec 3, 2021
@fab-mindflow
Copy link
Author

fab-mindflow commented Dec 4, 2021

Hi @skinny85,

I can reproduce it from scratch like this:
(edit: can name really be used instead of arn as highlighted in the CDK code - see my initial report link?)

  1. Create a new CDK project (I suppose you don't really need that 😁)
> cdk init --language=typescript
> yarn install
> yarn add @aws-cdk/aws-stepfunctions  
  1. Create a dumb workflow with Step Functions in lib/cdk-stack.ts
import * as sfn from "@aws-cdk/aws-stepfunctions"
import { WaitTime } from "@aws-cdk/aws-stepfunctions"
import * as cdk from "@aws-cdk/core"

export class CdkStack extends cdk.Stack {
  public constructor(scope: cdk.Construct, id: string, props?: cdk.StackProps) {
    super(scope, id, props)

    const waitStep = new sfn.Wait(this, "Wait", {
      time: WaitTime.duration(cdk.Duration.seconds(10)),
    })

    const succeedStep = new sfn.Succeed(this, "Start", {})
    waitStep.next(succeedStep)

    //    const startStep = waitStep
    const startStep = succeedStep

    const _stateMachine = new sfn.StateMachine(this, "MyStateMachine", {
      stateMachineName: "MyStateMachine",
      definition: startStep,
    })
  }
}
  1. Run cdk deploy for first time. No issue of course.

  2. Toggle the line to include 2 steps

    const startStep = waitStep
    //    const startStep = succeedStep
  1. Run cdk deploy --hotswap. This now fails with:
❯ cdk deploy --hotswap
⚠️ The --hotswap flag deliberately introduces CloudFormation drift to speed up deployments
⚠️ It should only be used for development - never use it for your production Stacks!
CdkStack: deploying...

 ❌  CdkStack failed: InvalidArn: Invalid Arn: 'Invalid ARN prefix: MyStateMachine'
    at Request.extractError (/opt/homebrew/Cellar/aws-cdk/1.134.0/libexec/lib/node_modules/aws-cdk/node_modules/aws-sdk/lib/protocol/json.js:52:27)
    at Request.callListeners (/opt/homebrew/Cellar/aws-cdk/1.134.0/libexec/lib/node_modules/aws-cdk/node_modules/aws-sdk/lib/sequential_executor.js:106:20)
    at Request.emit (/opt/homebrew/Cellar/aws-cdk/1.134.0/libexec/lib/node_modules/aws-cdk/node_modules/aws-sdk/lib/sequential_executor.js:78:10)
    at Request.emit (/opt/homebrew/Cellar/aws-cdk/1.134.0/libexec/lib/node_modules/aws-cdk/node_modules/aws-sdk/lib/request.js:686:14)
    at Request.transition (/opt/homebrew/Cellar/aws-cdk/1.134.0/libexec/lib/node_modules/aws-cdk/node_modules/aws-sdk/lib/request.js:22:10)
    at AcceptorStateMachine.runTo (/opt/homebrew/Cellar/aws-cdk/1.134.0/libexec/lib/node_modules/aws-cdk/node_modules/aws-sdk/lib/state_machine.js:14:12)
    at /opt/homebrew/Cellar/aws-cdk/1.134.0/libexec/lib/node_modules/aws-cdk/node_modules/aws-sdk/lib/state_machine.js:26:10
    at Request.<anonymous> (/opt/homebrew/Cellar/aws-cdk/1.134.0/libexec/lib/node_modules/aws-cdk/node_modules/aws-sdk/lib/request.js:38:9)
    at Request.<anonymous> (/opt/homebrew/Cellar/aws-cdk/1.134.0/libexec/lib/node_modules/aws-cdk/node_modules/aws-sdk/lib/request.js:688:12)
    at Request.callListeners (/opt/homebrew/Cellar/aws-cdk/1.134.0/libexec/lib/node_modules/aws-cdk/node_modules/aws-sdk/lib/sequential_executor.js:116:18) {
  code: 'InvalidArn',
  time: 2021-12-04T13:32:20.700Z,
  requestId: 'b1eafc53-483f-45bd-96c1-e409945adb1c',
  statusCode: 400,
  retryable: false,
  retryDelay: 144.62321105479253
}

@github-actions github-actions bot removed the response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days. label Dec 4, 2021
@skinny85
Copy link
Contributor

skinny85 commented Dec 6, 2021

Thanks for the detailed reproduction steps @fab-mindflow!

I'll let @comcalvi handle this one, as he was the original author of this functionality 🙂.

@skinny85 skinny85 assigned comcalvi and unassigned skinny85 Dec 6, 2021
@fab-mindflow
Copy link
Author

Great, thanks ! The hotswap feature for AWS Step Functions is really key to us so we can boost our deployment pipeline. I've seen the CDK 2.0 announcement and hope that the fix can still reach the 1.x branch.

@mergify mergify bot closed this as completed in #17892 Dec 10, 2021
mergify bot pushed a commit that referenced this issue Dec 10, 2021
Before, when the `stateMachineName` property was used, the value of `stateMachineName` was passed directly to the SDK where an ARN was required. Now, when the `stateMachineName` property is used, we construct the ARN from its value, and pass that ARN to the SDK.

Closes #17716

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
@github-actions
Copy link

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see.
If you need more assistance, please either tag a team member or open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.

TikiTDO pushed a commit to TikiTDO/aws-cdk that referenced this issue Feb 21, 2022
Before, when the `stateMachineName` property was used, the value of `stateMachineName` was passed directly to the SDK where an ARN was required. Now, when the `stateMachineName` property is used, we construct the ARN from its value, and pass that ARN to the SDK.

Closes aws#17716

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. p1 package/tools Related to AWS CDK Tools or CLI
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants