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

(aws-apigateway): StepFunctionsRestApi does not pass on path #27309

Open
maiksensi opened this issue Sep 27, 2023 · 2 comments
Open

(aws-apigateway): StepFunctionsRestApi does not pass on path #27309

maiksensi opened this issue Sep 27, 2023 · 2 comments
Labels
@aws-cdk/aws-apigateway Related to Amazon API Gateway bug This issue is a bug. effort/medium Medium work item – several days of effort p2

Comments

@maiksensi
Copy link

maiksensi commented Sep 27, 2023

Describe the bug

The construct StepFunctionsRestApi seems to be buggy regarding path handling.

Expected Behavior

When using StepFunctionsRestApi with path: true I expect my underlying Step Function to receive the path.

Current Behavior

Passing a path (also tried different depths combinations like: ...prod/users/4 or .../prod/12) leads to a {"message":"Missing Authentication Token"}

see: curl -X GET "https://XXXXXXXX.execute-api.eu-central-1.amazonaws.com/prod/123" {"message":"Missing Authentication Token"}

Reproduction Steps

deploy this (almost) minimal example:

    const successState = new Pass(this, "SuccessState");

    const stateMachine = new StateMachine(this, "CrudStateMachine", {
      definitionBody: DefinitionBody.fromChainable(successState),
      timeout: Duration.minutes(5),
      stateMachineType: StateMachineType.EXPRESS,
      comment: "This state machine returns an employee entry from DynamoDB",
      logs: {
        destination: new LogGroup(this, "StateMachineLogs", {
          retention: RetentionDays.ONE_DAY,
        }),
        level: LogLevel.ALL,
        includeExecutionData: true,
      },
    });

    new StepFunctionsRestApi(this, "StepFunctionsRestApi", {
      stateMachine,
      path: true,
      requestContext: {
        httpMethod: true,
      },
    });

and send a similar request to the created API:
curl -X GET "https://${apigatewayid}.execute-api.eu-central-1.amazonaws.com/prod/123"

Possible Solution

No response

Additional Information/Context

I can workaround the problem by creating a proxy integration manually on the API but I guess that is not the idea here.

see

const sfnApi = new StepFunctionsRestApi(this, 'StepFunctionsRestApi', {
      deploy: true,
      stateMachine: sfn,
    });

    sfnApi.root.addProxy({
      defaultIntegration: StepFunctionsIntegration.startExecution(sfn, {
        path: true,
        querystring: true,
      }),
      anyMethod: true,
    });

    sfnApi.root.addResource('testpath').addProxy({
      defaultIntegration: StepFunctionsIntegration.startExecution(sfn, {
        path: true,
        querystring: true,
      }),
      anyMethod: true,
    });

Does the current implementation on the vtl packages/@aws-cdk/aws-apigateway/lib/integrations/stepfunctions.vtl only work for key value pairs (regarding paths)?

CDK CLI Version

2.97.0

Framework Version

2.97.0

Node.js Version

v18.14.0

OS

macos 14 (also happened on 13)

Language

Typescript

Language Version

^4.8.3

Other information

No response

@maiksensi maiksensi added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Sep 27, 2023
@github-actions github-actions bot added the @aws-cdk/aws-apigateway Related to Amazon API Gateway label Sep 27, 2023
@indrora
Copy link
Contributor

indrora commented Oct 2, 2023

Two questions:

  • Does this work when you pass -X POST to cURL?
  • Can you make calls to this API from the API Gateway Console?

@indrora indrora added response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days. and removed needs-triage This issue or PR still needs to be triaged. labels Oct 2, 2023
@maiksensi
Copy link
Author

A post request goes through if the root is used:
curl -X POST https://XXXXX.execute-api.eu-central-1.amazonaws.com/prod/ -H 'Content-Type: application/json' -d '{"name":"Leo","age":26}' {"body": {"name":"Leo","age":26}, "querystring":{ }, "path":{ }, "requestContext": {"httpMethod":"POST"}}

If a specific path is used it doesn't work:
curl -X POST https://XXXX.execute-api.eu-central-1.amazonaws.com/prod/123 -H 'Content-Type: application/json' -d '{"name":"Leo","age":26}' {"message":"Missing Authentication Token"}

Making calls via API Gateway Console works just the same as with curl:

  • I can make a GET request, but cannot pass a path param (as non is defined...)
  • I can make a POST request and it is returned successfully on the root.

image

@github-actions github-actions bot removed the response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days. label Oct 4, 2023
@pahud pahud added p2 effort/medium Medium work item – several days of effort labels Nov 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@aws-cdk/aws-apigateway Related to Amazon API Gateway bug This issue is a bug. effort/medium Medium work item – several days of effort p2
Projects
None yet
Development

No branches or pull requests

3 participants