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(pipes-targets): add lambda function #30271

Merged
merged 2 commits into from
Jun 27, 2024
Merged

Conversation

WtfJoke
Copy link
Contributor

@WtfJoke WtfJoke commented May 20, 2024

Issue # (if applicable)

Closes #30270.

Reason for this change

Lambda Function target is not supported yet by pipes-targets.

Description of changes

  • Added LambdaFunction as a pipes target.
  • Default LambdaFunctionInvocationType to LambdaFunctionInvocationType.REQUEST_RESPONSE
  • Allowed grant Invoke on Lambda by Pipes

Description of how you validated changes

Checklist


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 repeat-contributor [Pilot] contributed between 3-5 PRs to the CDK feature-request A feature should be added or improved. p2 labels May 20, 2024
@aws-cdk-automation aws-cdk-automation requested a review from a team May 20, 2024 00:25
@WtfJoke WtfJoke force-pushed the addLambdaPipeTarget branch 3 times, most recently from 23db285 to 3aa03cc Compare May 20, 2024 01:01
@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 May 20, 2024
This was referenced May 27, 2024
Copy link
Contributor

@RaphaelManke RaphaelManke left a comment

Choose a reason for hiding this comment

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

Overall it looks good to me. I added some minor improvement ideas.

const app = new App();
const stack = new Stack(app, 'TestLambdaFunctionStack');

const lambdaFunction = new lambda.Function(stack, 'MyLambda', {
Copy link
Contributor

Choose a reason for hiding this comment

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

You don't have to define a lambda. A string of an arn should be sufficient.

Copy link
Contributor Author

@WtfJoke WtfJoke Jun 9, 2024

Choose a reason for hiding this comment

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

Are you sure? Shouldnt be the lambda be available for import? Because for the LambdaFunction#grantPush you need a reference to a lambda.IFunction.

Copy link
Contributor

@GavinZZ GavinZZ Jun 24, 2024

Choose a reason for hiding this comment

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

Because it's a unit test, Raphael is right here, you can just hardcode a fake arn and run `lambda.Function.fromFunctionArn(stack, 'MyImportedLambda', ''.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

When using lambda.Function.fromFunctionArn(stack, 'MyImportedLambda', arn), I got following error:

Cannot modify permission to lambda function. Function is either imported or $LATEST version.
If the function is imported from the same account use `fromFunctionAttributes()` API with the `sameEnvironment` flag.
If the function is imported from a different account and already has the correct permissions use `fromFunctionAttributes()` API with the `skipPermissions` flag.

I've used the fromFunctionAttributes with the sameEnvironment flag. However I left the test should work with imported function unchanged as it would not make sense to use the same import twice. An alternative would be the deletion of this test.

@WtfJoke WtfJoke force-pushed the addLambdaPipeTarget branch 2 times, most recently from 125f4b6 to d9e571b Compare June 9, 2024 21:16
@RaphaelManke
Copy link
Contributor

@GavinZZ whats your opinion on this PR?

@GavinZZ
Copy link
Contributor

GavinZZ commented Jun 24, 2024

Thanks for drafting the changes and making contributions. The changes look good to me in general. A minor doc change and a question before approving.

@GavinZZ GavinZZ self-requested a review June 24, 2024 22:35
@WtfJoke
Copy link
Contributor Author

WtfJoke commented Jun 27, 2024

@gastonsilva thanks for the review.
I applied the changes + rebased and force pushed them.
Please have a look again, I hope everything is ready to get this merged :)

Copy link
Contributor

@GavinZZ GavinZZ left a comment

Choose a reason for hiding this comment

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

LGTM, thanks for updating it!

Copy link
Contributor

mergify bot commented Jun 27, 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).

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

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

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

@mergify mergify bot merged commit f594fae into aws:main Jun 27, 2024
9 checks passed
Copy link
Contributor

mergify bot commented Jun 27, 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).

@aws-cdk-automation
Copy link
Collaborator

Comments on closed issues and PRs are hard for our team to see. If you need help, please open a new issue that references this one.

@aws aws locked as resolved and limited conversation to collaborators Jul 25, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
feature-request A feature should be added or improved. p2 pr/needs-community-review This PR needs a review from a Trusted Community Member or Core Team Member. repeat-contributor [Pilot] contributed between 3-5 PRs to the CDK
Projects
None yet
Development

Successfully merging this pull request may close these issues.

(pipes-targets): Add Lambda Function target for EventBridge pipes
4 participants