-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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(stepfunctions-tasks): support for APIGW API: Invoke #11565
Conversation
@pahud feel free to give the open PR a review as well! |
packages/@aws-cdk/aws-stepfunctions-tasks/lib/apigateway/invoke.ts
Outdated
Show resolved
Hide resolved
packages/@aws-cdk/aws-stepfunctions-tasks/lib/apigateway/invoke.ts
Outdated
Show resolved
Hide resolved
packages/@aws-cdk/aws-stepfunctions-tasks/lib/apigateway/invoke.ts
Outdated
Show resolved
Hide resolved
packages/@aws-cdk/aws-stepfunctions-tasks/lib/apigateway/invoke.ts
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for this change! Some comments.
packages/@aws-cdk/aws-stepfunctions-tasks/lib/apigateway/invoke.ts
Outdated
Show resolved
Hide resolved
packages/@aws-cdk/aws-stepfunctions-tasks/lib/apigateway/invoke.ts
Outdated
Show resolved
Hide resolved
packages/@aws-cdk/aws-stepfunctions-tasks/lib/apigateway/invoke.ts
Outdated
Show resolved
Hide resolved
packages/@aws-cdk/aws-stepfunctions-tasks/lib/apigateway/invoke.ts
Outdated
Show resolved
Hide resolved
packages/@aws-cdk/aws-stepfunctions-tasks/test/apigateway/invoke.test.ts
Show resolved
Hide resolved
packages/@aws-cdk/aws-stepfunctions-tasks/lib/apigateway/invoke.ts
Outdated
Show resolved
Hide resolved
/** | ||
* Retreive data from a server at the specified resource | ||
*/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/** | |
* Retreive data from a server at the specified resource | |
*/ | |
/** Retrieve data from a server at the specified resource */ |
packages/@aws-cdk/aws-stepfunctions-tasks/lib/apigateway/invoke.ts
Outdated
Show resolved
Hide resolved
packages/@aws-cdk/aws-stepfunctions-tasks/lib/apigateway/invoke.ts
Outdated
Show resolved
Hide resolved
packages/@aws-cdk/aws-stepfunctions-tasks/lib/apigateway/invoke.ts
Outdated
Show resolved
Hide resolved
packages/@aws-cdk/aws-stepfunctions-tasks/lib/apigateway/invoke.ts
Outdated
Show resolved
Hide resolved
packages/@aws-cdk/aws-stepfunctions-tasks/lib/apigateway/invoke.ts
Outdated
Show resolved
Hide resolved
} else { | ||
return { | ||
Resource: integrationResourceArn('apigateway', 'invoke', this.integrationPattern), | ||
Parameters: sfn.FieldUtils.renderObject({ | ||
ApiEndpoint: this.props.apiEndpoint, | ||
Method: this.props.method, | ||
Stage: this.props.stage, | ||
Path: this.props.path, | ||
AuthType: (this.props.authType ? this.props.authType.value : sfn.TaskInput.fromDataAt('$.AuthType').value) === '$' ? (this.props.authType ? this.props.authType.value : sfn.TaskInput.fromDataAt('$.AuthType').value) : 'NO_AUTH', | ||
}), | ||
}; | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
there's a lot of duplicated code in this control flow chain from the if
on down. I think we can simplify this to be a lot more succinct. let's refactor this please!
Pull request has been modified.
* hostname of an API Gateway URL | ||
* @example {ApiId}.execute-api.{region}.amazonaws.com | ||
*/ | ||
readonly apiEndpoint: string; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this should not be needed anymore.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
would also love if @nija-at could take a look since he's the primary maintainer of the api-gateway
module
|
||
const invokeJob = new tasks.ApiGatewayInvoke(stack, 'Invoke APIGW', { | ||
api: restApi, | ||
apiEndpoint: restApi.restApiId, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why does this need to be an input parameter as well? you're already accepting the restApi
as input
* hostname of an API Gateway URL | ||
* @example {ApiId}.execute-api.{region}.amazonaws.com | ||
*/ | ||
readonly apiEndpoint: string; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the endpoint can be inferred from the api
so you shouldn't need to make this an input anymore
* } | ||
* }, | ||
*/ | ||
readonly headers?: { [key: string]: any }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
confirming to ensure we have the right type here: "Headers.$" : "$.input"
is not valid correct?
i.e. the entire headers field cannot be allocated to a field in the state input
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Anyone digging into this? Happy to try and help; looking forward to putting this functionality to use ;)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@eikeon - happy to have your help here!! :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this pretty much the sole remaining thing holding up this pull request? Can save some time to attempt to dig into this headers issue later today
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
headers here probably should be similar to input here: packages/@aws-cdk/aws-stepfunctions-tasks/test/start-execution.test.ts and packages/@aws-cdk/aws-stepfunctions-tasks/lib/start-execution.ts -- and they both have the same type. Gotta run for a few hours, but will trace how headers is being used in this pull request compared to other working examples.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
readonly headers?: { [key: string]: string[] }
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I also see a string value in one of the examples on that doc page: readonly headers?: { [key: string]: string[] | string }
|
||
/** | ||
* Name of the stage where the API is deployed to in API Gateway | ||
* @default - Required for REST and $default for HTTP |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: be sure to describe what $default
means as the user might find that information useful in determining whether they need to set it or not.
|
||
/** | ||
* Authentication methods | ||
* @default - NO_AUTH |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* @default - NO_AUTH | |
* @default AuthType.NO_AUTH |
} | ||
|
||
/** | ||
* Gets the "execute-api" ARN |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: I think the doc string should be a little more informative than the method name. Perhaps describe what that ARN is / what it's used for, show an example of what it looks like, etc.
|
||
/** | ||
* The authentication method used to call the endpoint | ||
* @default NO_AUTH |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
enums don't have defaults, it's only where they're used that would
* @default NO_AUTH |
* Stack verification steps: | ||
* * aws stepfunctions start-execution --state-machine-arn <deployed state machine arn> : should return execution arn | ||
* * aws stepfunctions describe-execution --execution-arn <exection-arn generated before> : should return status as SUCCEEDED and a query-execution-id | ||
* * aws apigateway test-invoke-method --rest-api-id <value> --resource-id <value> --http-method <value>: should return the same response as the state machine |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should return the same response as the state machine
nit: better to be explicit and clear about what that response is
function helloCode(_event: any, _context: any, callback: any) { | ||
return callback(undefined, { | ||
statusCode: 200, | ||
body: 'hello, world!', | ||
}); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
does this need to be a function? - why not just define it ahead of it's usage or inline it?
* Stack verification steps: | ||
* * aws stepfunctions start-execution --state-machine-arn <deployed state machine arn> : should return execution arn | ||
* * aws stepfunctions describe-execution --execution-arn <exection-arn generated before> : should return status as SUCCEEDED and a query-execution-id | ||
* * aws apigateway test-invoke-method --rest-api-id <value> --resource-id <value> --http-method <value>: should return the same response as the state machine |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should the rest-api-id also be an output? same question for all the inputs here. steps should include where they retrieved from. you might need to add outputs to the stack if they're not easily available.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you clarify what you mean by this? I am not sure how to get the rest-api-id.
Pull request has been modified.
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
Hi Guys, what's up with the feature ? |
…PIs (#13033) feat(stepfunctions-tasks): Support calling APIGW REST and HTTP APIs Taking ownership of the original PR #11565 by @Sumeet-Badyal API as per documentation here: https://docs.aws.amazon.com/step-functions/latest/dg/connect-api-gateway.html https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-control-access-using-iam-policies-to-invoke-api.html closes #11566 closes #11565 ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
feat(stepfunctions-tasks): support for APIGW API: Invoke
Implementation
Update package @aws-cdk/aws-stepfunctions-tasks to include support for ApiGateway Invoke
API as per documentation here:
https://docs.aws.amazon.com/step-functions/latest/dg/connect-api-gateway.html
https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-control-access-using-iam-policies-to-invoke-api.html
Includes support for the following Amazon Athena API calls:
Invoke
Closes #11565
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license