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

Add a Lambda+Codepipeline Typescript example #269

Merged
merged 4 commits into from
May 8, 2020

Conversation

gustakasn0v
Copy link
Contributor

I'm adding an example here that deploys a Lambda+ApiGateway setup using CodePipeline.

Although there's plenty of examples of Lambda already, deploying them via CodePipeline had some non-trivial challenges to sort out. This could mean teams start using CDK and like it, but drop it because they can't adopt Full CI/CD easily when using it

Fixes #267


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

@gustakasn0v
Copy link
Contributor Author

To the reviewer: regarding Conventional Commits, would you prefer if I squashed all the commits to something like:

feat: Add Lambda+CodePipeline Typescript example

@mergify
Copy link
Contributor

mergify bot commented Mar 29, 2020

Title does not follow the guidelines of Conventional Commits. Please adjust title before merge.

NGL321
NGL321 previously requested changes Apr 6, 2020
Copy link
Contributor

@NGL321 NGL321 left a comment

Choose a reason for hiding this comment

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

Looks excellent! My main concern is that some of the syntax choices were not consistent. Once thats fixed I'm happy to merge!

😸

)
const editOrCreateLambdaDependencies = new PolicyStatement();
editOrCreateLambdaDependencies.addActions(
"iam:GetRole",
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
"iam:GetRole",
"iam:GetRole",

}
})

const lambdaPolicy = new PolicyStatement();
Copy link
Contributor

Choose a reason for hiding this comment

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

Please be consistent with semicolons. We recommend all lines terminate with semicolon, but if you want to follow the no-semicolon TS guidance, stick to that throughout the example.

@gustakasn0v
Copy link
Contributor Author

@NGL321 Thanks for taking a look! I'll address that and update the pull request

@mergify mergify bot dismissed NGL321’s stale review April 11, 2020 13:52

Pull request has been modified.

@gustakasn0v gustakasn0v force-pushed the master branch 2 times, most recently from 6149291 to e158f16 Compare April 11, 2020 22:09
@gustakasn0v gustakasn0v requested a review from NGL321 April 11, 2020 22:10
@gustakasn0v
Copy link
Contributor Author

@NGL321 The build seems to be failing with the following error:

> [email protected] build /Users/seoaneg/Workspaces/aws-cdk-examples/typescript/lambda-api-ci/cdk.out/asset.5d8ebe4e1b7da78e3a974de62e8d9aac8a42747f5c303e249b6d1e2855c6e92f
> tsc

npx: installed 202 in 17.326s
--app is required either in command-line, in cdk.json or in ~/.cdk.json

widgets-lambda is the name of the NPM package I created under typescript/lambda-api-ci/src for the Lambda function. It seems the build is mistaking it for a CDK package. Do you know if I can exclude it somehow?

This commit adds an example that deploys a Lambda+ApiGateway setup using CodePipeline.
Although there's plenty of examples of Lambda already, deploying them via CodePipeline had some non-trivial challenges to sort out. This could mean teams start using CDK and like it, but drop it because they can't adopt Full CI/CD easily when using it
@gustakasn0v
Copy link
Contributor Author

Screen Shot 2020-04-18 at 5 50 34 pm

@@ -20,7 +20,7 @@ verify_star_dependencies() {
}

# Find and build all NPM projects
for pkgJson in $(find typescript -name package.json | grep -v node_modules); do
for pkgJson in $(find typescript -name cdk.json | grep -v node_modules); do
Copy link
Contributor Author

@gustakasn0v gustakasn0v Apr 18, 2020

Choose a reason for hiding this comment

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

I've run the following commands to compare the directories that are evaluated:

find typescript -name package.json  | grep -v node_modules | xargs -n 1 dirname | sort
find typescript -name cdj.json  | grep -v node_modules | xargs -n 1 dirname | sort

Here is the diff. Directories removed are shown in grey on the left-hand side:
Screen Shot 2020-04-18 at 5 50 34 pm
Link
These directories are now excluded as they're Lambda NPM packages, not CDK packages:

typescript/lambda-api-ci/cdk.out/asset.5d8ebe4e1b7da78e3a974de62e8d9aac8a42747f5c303e249b6d1e2855c6e92f
typescript/lambda-api-ci/src

Copy link
Contributor

Choose a reason for hiding this comment

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

Thank you for the catch! I had not noticed this. The fix is logical and LGTM.

😸

NGL321
NGL321 previously approved these changes Apr 20, 2020
@mergify mergify bot dismissed NGL321’s stale review April 20, 2020 23:11

Pull request has been modified.

@gustakasn0v
Copy link
Contributor Author

@NGL321 Looks like mergify discarded your approval after the rebase. Can you take another look?

@NGL321
Copy link
Contributor

NGL321 commented May 8, 2020

@NGL321 Looks like mergify discarded your approval after the rebase. Can you take another look?

Well thats frustrating! Taking care of now!

😸 😷

NGL321
NGL321 previously approved these changes May 8, 2020
@mergify mergify bot dismissed NGL321’s stale review May 8, 2020 03:02

Pull request has been modified.

@gustakasn0v
Copy link
Contributor Author

gustakasn0v commented May 8, 2020

@NGL321 I think mergify blew up again 🤦

@NGL321 NGL321 merged commit 6f24ca6 into aws-samples:master May 8, 2020
its-mirus-lu pushed a commit to its-mirus-lu/aws-cdk-examples that referenced this pull request Mar 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Lambda+CodePipeline example
3 participants