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

Align CDK Template #1577

Merged
merged 29 commits into from
Oct 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
68b6750
Align
samchungy Jun 8, 2024
888b127
add dep
samchungy Jun 8, 2024
28d2e78
Merge branch 'main' into upgrade-cdk-template
samchungy Jun 8, 2024
60659f4
update hooks
samchungy Jun 8, 2024
2ec8e20
Merge branch 'upgrade-cdk-template' of github.com:seek-oss/skuba into…
samchungy Jun 8, 2024
c3e222d
update
samchungy Jun 8, 2024
46311fc
Merge branch 'main' into upgrade-cdk-template
samchungy Jun 8, 2024
b61f9d2
fix
samchungy Jun 8, 2024
3537f89
Update hot-worms-decide.md
samchungy Jun 8, 2024
fd204b0
update bundler settings
samchungy Jun 8, 2024
92c9a4b
Merge branch 'upgrade-cdk-template' of github.com:seek-oss/skuba into…
samchungy Jun 8, 2024
cbf83d8
Update hot-worms-decide.md
samchungy Jun 8, 2024
a4172e2
add extension layer
samchungy Jun 8, 2024
1f2a1ae
Merge branch 'upgrade-cdk-template' of github.com:seek-oss/skuba into…
samchungy Jun 8, 2024
2a2adfe
update bundling
samchungy Jun 8, 2024
fe58114
Merge branch 'main' of github.com:seek-oss/skuba into upgrade-cdk-tem…
samchungy Jun 19, 2024
4721553
Merge branch 'main' of github.com:seek-oss/skuba into upgrade-cdk-tem…
samchungy Sep 28, 2024
402afab
fix lock
samchungy Sep 28, 2024
ca287df
export schema to fix lint error
samchungy Sep 28, 2024
6446df4
Merge branch 'main' of github.com:seek-oss/skuba into upgrade-cdk-tem…
samchungy Oct 2, 2024
b721a9a
further alignment
samchungy Oct 2, 2024
1a4f706
Bump datadog extension
samchungy Oct 18, 2024
ff41462
update version name
samchungy Oct 18, 2024
d6a6135
Merge branch 'main' of github.com:seek-oss/skuba into upgrade-cdk-tem…
samchungy Oct 18, 2024
9d4d67a
remove redundant default sections
samchungy Oct 18, 2024
00664b4
tweak
samchungy Oct 18, 2024
ed68214
replace lambda version
samchungy Oct 19, 2024
77d75a8
bump datadog-lambda-js
samchungy Oct 19, 2024
f479b47
lock
samchungy Oct 19, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .changeset/hot-worms-decide.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
'skuba': patch
---

template/lambda-sqs-worker-cdk: Align template with Serverless template

This adds the same boilerplate code available in `lambda-sqs-worker` along with Datadog integration.
35 changes: 35 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions template/lambda-sqs-worker-cdk/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ENVIRONMENT=local
145 changes: 145 additions & 0 deletions template/lambda-sqs-worker-cdk/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
# <%- repoName %>

[![Powered by skuba](https://img.shields.io/badge/🤿%20skuba-powered-009DC4)](https://github.com/seek-oss/skuba)

Next steps:

1. [ ] Finish templating if this was skipped earlier:

```shell
pnpm exec skuba configure
```

2. [ ] Create a new repository in the appropriate GitHub organisation.
3. [ ] Add the repository to BuildAgency;
see our internal [Buildkite Docs] for more information.
4. [ ] Add Datadog extension, deployment bucket configuration and data classification tags to [infra/config.ts](infra/config.ts).
5. [ ] Push local commits to the upstream GitHub branch.
6. [ ] Configure [GitHub repository settings].
7. [ ] Delete this checklist 😌.

[Buildkite Docs]: https://backstage.myseek.xyz/docs/default/component/buildkite-docs
[GitHub repository settings]: https://github.com/<%-orgName%>/<%-repoName%>/settings

## Design

<%-repoName %> is a Node.js [Lambda] application built in line with our [Technical Guidelines].
It is backed by a typical SQS message + dead letter queue configuration and uses common SEEK packages.
Workers enable fault-tolerant asynchronous processing of events.

The `lambda-sqs-worker-cdk` template is modelled after a hypothetical enricher that scores job advertisements.
It's stubbed out with in-memory [scoring service](src/services/jobScorer.ts).
This would be replaced with internal logic or an external service in production.

This project is deployed with [AWS CDK].
The Lambda runtime provisions a single Node.js process per container.
The supplied [infra/appStack.ts](infra/appStack.ts) starts out with a minimal `memorySize` which may require tuning based on workload.
Under load, we autoscale horizontally in terms of container count up to `reservedConcurrency`.

[@seek/aws-codedeploy-hooks] configures [CodeDeploy] for a blue-green deployment approach.
A smoke test is run against the new version before traffic is switched over,
providing an opportunity to test access and connectivity to online dependencies.
This defaults to an invocation with an empty object `{}`.

## Development

### Test

```shell
# Run Jest tests locally
pnpm test

# Authenticate to dev account
awsauth

# Run smoke test against deployed application
ENVIRONMENT=dev pnpm smoke
```

### Lint

```shell
# Fix issues
pnpm format

# Check for issues
pnpm lint
```

### Start

```shell
# Start a local HTTP server
pnpm start

# Start with Node.js Inspector enabled
pnpm start:debug
```

This serves the Lambda application over HTTP.
For example, to invoke the handler with an empty object `{}` for smoke testing:

```shell
curl --data '[{}, {"awsRequestId": "local"}]' --include localhost:<%- port %>
```

### Deploy

This project is deployed through a [Buildkite pipeline](.buildkite/pipeline.yml).

- Commits to a feature branch can be deployed to the dev environment by unblocking a step in the Buildkite UI
- Commits to the default branch are automatically deployed to the dev and prod environments in sequence

To deploy locally:

```shell
# Authenticate to dev account
awsauth

ENVIRONMENT=dev pnpm run deploy
```

A hotswap deploy enables faster deployment but come with caveats such as requiring a Lambda to be rebuilt with every build.

To deploy a [hotswap]:

```shell
# Authenticate to dev account
awsauth

ENVIRONMENT=dev pnpm run deploy:hotswap
```

To rapidly roll back a change,
retry an individual deployment step from the previous build in Buildkite.
Note that this will introduce drift between the head of the default Git branch and the live environment;
use with caution and always follow up with a proper revert or fix in Git history.

## Support

### Dev

TODO: add support links for the dev environment.

<!--
- CloudWatch dashboard
- Datadog dashboard
- Splunk logs
-->

### Prod

TODO: add support links for the prod environment.

<!--
- CloudWatch dashboard
- Datadog dashboard
- Splunk logs
-->

[@seek/aws-codedeploy-hooks]: https://github.com/seek-oss/aws-codedeploy-hooks
[AWS CDK]: https://docs.aws.amazon.com/cdk/v2/guide/home.html
[CodeDeploy]: https://docs.aws.amazon.com/codedeploy
[Hotswap]: https://docs.aws.amazon.com/cdk/v2/guide/ref-cli-cmd-deploy.html#ref-cli-cmd-deploy-options
[Lambda]: https://docs.aws.amazon.com/lambda
[Technical Guidelines]: https://myseek.atlassian.net/wiki/spaces/AA/pages/2358346017/
Loading