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(stepfunctions-tasks): add httpinvoke step functions task #28673

Merged
merged 26 commits into from Apr 16, 2024

Conversation

MathieuGilbert
Copy link
Contributor

@MathieuGilbert MathieuGilbert commented Jan 11, 2024

This adds an HttpInvoke Step Functions task construct, which allows calling public APIs as described here.

  • Accepts an Event Bridge API Destination IConnection, setting required permissions to use its credentials.
  • Grants permission to invoke the root path for the endpoint (apiRoot prop). This allows passing the relative endpoint path at execution time (apiEndpoint prop).
  • Defines an enum for the allowed options for the URL encoding style of arrays, used when encoding the request body.

Closes #28278


By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license

@github-actions github-actions bot added beginning-contributor [Pilot] contributed between 0-2 PRs to the CDK effort/small Small work item – less than a day of effort feature-request A feature should be added or improved. p2 labels Jan 11, 2024
@aws-cdk-automation aws-cdk-automation requested a review from a team January 11, 2024 20:15
@MathieuGilbert MathieuGilbert changed the title Add http:invoke step functions task feat(aws-stepfunctions-tasks): Add http:invoke step functions task Jan 11, 2024
Copy link
Collaborator

@aws-cdk-automation aws-cdk-automation left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The pull request linter has failed. See the aws-cdk-automation comment below for failure reasons. If you believe this pull request should receive an exemption, please comment and provide a justification.

A comment requesting an exemption should contain the text Exemption Request. Additionally, if clarification is needed add Clarification Request to a comment.

@MathieuGilbert MathieuGilbert changed the title feat(aws-stepfunctions-tasks): Add http:invoke step functions task feat(aws-stepfunctions-tasks): add http:invoke step functions task Jan 11, 2024
Add task policies: events:RetrieveConnectionCredentials, secretsmanager:GetSecretValue, secretsmanager:DescribeSecret, states:InvokeHTTPEndpoint.
@MathieuGilbert MathieuGilbert changed the title feat(aws-stepfunctions-tasks): add http:invoke step functions task feat(stepfunctions-tasks): add http:invoke step functions task Jan 12, 2024
@aws-cdk-automation
Copy link
Collaborator

This PR has been in the CHANGES REQUESTED state for 3 weeks, and looks abandoned. To keep this PR from being closed, please continue work on it. If not, it will automatically be closed in a week.

…t. Test creates an API Gateway endpoint with basic auth Connection, then uses the connection in its task to invoke the endpoint.
@aws-cdk-automation aws-cdk-automation dismissed their stale review February 2, 2024 23:46

✅ Updated pull request passes all PRLinter validations. Dismissing previous PRLinter review.

@MathieuGilbert MathieuGilbert marked this pull request as ready for review February 22, 2024 22:32
@aws-cdk-automation aws-cdk-automation added the pr/needs-community-review This PR needs a review from a Trusted Community Member or Core Team Member. label Feb 22, 2024

/**
* The style used when applying URL encoding to array values.
*
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: extra newline


/**
* The HTTP method to use.
* @example sfn.TaskInput.fromText("GET")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: can you add a newline before @example and remove the one below.


/**
* The API endpoint to call, relative to `apiRoot`.
* @example sfn.TaskInput.fromText("path/to/resource")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

likewise here.


/**
* The EventBridge Connection to use for authentication.
*
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: extra newline

* The headers to send to the HTTP endpoint.
*
* @default - No additional headers are added to the request.
* @example sfn.TaskInput.fromObject({ 'Content-Type': 'application/json' })
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: can you put @default below @example and add a newline in between.


/**
* A Step Functions Task to call a public third-party API.
*
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: extra newline.

constructor(
scope: Construct,
id: string,
private readonly props: HttpInvokeProps,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Can these be on the same line?

*/
/**
* @internal
*/
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: this formatting looks off

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for pointing these out, I obviously didn't pay enough attention to the comments (and don't normally use them). I did a sweep and they should all be consistent now.

Copy link
Contributor

@msambol msambol left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great stuff. Mostly nits on formatting.

@aws-cdk-automation aws-cdk-automation removed the pr/needs-community-review This PR needs a review from a Trusted Community Member or Core Team Member. label Mar 22, 2024
Copy link
Contributor

@TheRealAmazonKendra TheRealAmazonKendra left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for your contribution! This looks great overall but I just have one suggested change (in addition to the feedback already given).

*
* @default - ArrayEncodingFormat.INDICES
*/
readonly arrayEncodingFormat?: ArrayEncodingFormat;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given that this field is reliant on urlEncodeBody being set, these two fields should probably be one field. Maybe the only field here should still be called urlEncodeBody but have it take an Encoding (not sure about this name) class with a static function that has an optional input of ArrayEncodingFormat. Something along the lines of

urlEncodeBody: Encoding.set(ArrayEncodingFormat.INDICES);

to include encoding format, or

urlEncodeBody: Encoding.set();

to just include encoding with the default format.

This way, if they leave off this prop altogether, it's defaulted to false.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll also add the note here that set probably isn't a great function name here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for pointing this out, I agree it's a bit awkward with the 2 params. I played around a bit, and I think a single prop can work with a couple extra enum options and renaming it to urlEncodingFormat. You can not pass it or specify URLEncodingFormat.NONE to get no encoding, pass it as URLEncodingFormat.DEFAULT to get encoding with the default array encoding (the underlying service defaults to INDICES), or specify the existing values to use those.

…. Rename enum to URLEncodingFormat and add DEFAULT and NONE options. Restructure the buildTaskParameters method for clarity with the new logic, and define an interface for it. Add specific test case for NONE.
@mergify mergify bot dismissed TheRealAmazonKendra’s stale review April 2, 2024 23:27

Pull request has been modified.

@MathieuGilbert
Copy link
Contributor Author

@msambol @TheRealAmazonKendra Thanks for reviewing, I think I've addressed all of your comments. Please let me know if there's anything else!

Copy link
Contributor

@TheRealAmazonKendra TheRealAmazonKendra left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for all your work on this!

Copy link
Contributor

mergify bot commented Apr 16, 2024

Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork).

@TheRealAmazonKendra
Copy link
Contributor

@Mergifyio update

Copy link
Contributor

mergify bot commented Apr 16, 2024

update

❌ Mergify doesn't have permission to update

For security reasons, Mergify can't update this pull request. Try updating locally.
GitHub response: refusing to allow a GitHub App to create or update workflow .github/workflows/request-cli-integ-test.yml without workflows permission

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildv2Project1C6BFA3F-wQm2hXv2jqQv
  • Commit ID: f784b79
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

Copy link
Contributor

mergify bot commented Apr 16, 2024

Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork).

@mergify mergify bot merged commit 178e481 into aws:main Apr 16, 2024
10 checks passed
@MathieuGilbert MathieuGilbert deleted the add-awsstepfunctions-httpinvoke branch April 16, 2024 23:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
beginning-contributor [Pilot] contributed between 0-2 PRs to the CDK effort/small Small work item – less than a day of effort feature-request A feature should be added or improved. p2
Projects
None yet
Development

Successfully merging this pull request may close these issues.

aws-stepfunctions-tasks: Support for new HTTPS Endpoint integration
4 participants