Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
642 changes: 608 additions & 34 deletions Cargo.lock

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@ members = [
"functions/fetch-issue-number",
"functions/fetch-quote",
"functions/fetch-sponsor",
"functions/create-issue",
"shared",
]
1 change: 1 addition & 0 deletions functions/create-issue/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
target
27 changes: 27 additions & 0 deletions functions/create-issue/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
[package]
name = "create-issue"
version = "0.1.0"
edition = "2021"

[dependencies]
serde = { version = "1", features = ["derive"] }
serde_json = "1"

lambda_runtime = "0.13.0"
tokio = { version = "1", features = ["macros"] }

# Date/time handling
chrono = { version = "0.4", features = ["serde"] }
chrono-tz = "0.10"

# HTTP requests (with rustls for Lambda compatibility)
reqwest = { version = "0.12", features = [
"json",
"rustls-tls",
], default-features = false }

# Template engine
tera = "1"

# Environment variables and error handling
anyhow = "1"
57 changes: 50 additions & 7 deletions functions/create-issue/README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,52 @@
## How to update the base template
# Introduction

If you want to update the base template this is the process (unfortunately Mailchimp makes it a bit tricky):
create-issuev2 is a Rust project that implements an AWS Lambda function in Rust.

- Update the file `functions/create-issue/templates/newsletter.njk` and apply the desired changes
- Run the tests with `node_modules/.bin/vitest run functions/create-issue/ -u` (from the root of the project)
- Now the file `functions/create-issue/__tests__/__snapshots__/template.html` is up to date. Copy its code.
- In Mailchimp edit the saved template and paste the code
- Check that the preview renders as expected and save
## Prerequisites

- [Rust](https://www.rust-lang.org/tools/install)
- [Cargo Lambda](https://www.cargo-lambda.info/guide/installation.html)

## Building

To build the project for production, run `cargo lambda build --release`. Remove the `--release` flag to build for development.

Read more about building your lambda function in [the Cargo Lambda documentation](https://www.cargo-lambda.info/commands/build.html).

## Testing

You can run regular Rust unit tests with `cargo test`.

If you want to run integration tests locally, you can use the `cargo lambda watch` and `cargo lambda invoke` commands to do it.

First, run `cargo lambda watch` to start a local server. When you make changes to the code, the server will automatically restart.

Second, you'll need a way to pass the event data to the lambda function.

You can use the existent [event payloads](https://github.com/awslabs/aws-lambda-rust-runtime/tree/main/lambda-events/src/fixtures) in the Rust Runtime repository if your lambda function is using one of the supported event types.

You can use those examples directly with the `--data-example` flag, where the value is the name of the file in the [lambda-events](https://github.com/awslabs/aws-lambda-rust-runtime/tree/main/lambda-events/src/fixtures) repository without the `example_` prefix and the `.json` extension.

```bash
cargo lambda invoke --data-example apigw-request
```

For generic events, where you define the event data structure, you can create a JSON file with the data you want to test with. For example:

```json
{
"command": "test"
}
```

Then, run `cargo lambda invoke --data-file ./data.json` to invoke the function with the data in `data.json`.


Read more about running the local server in [the Cargo Lambda documentation for the `watch` command](https://www.cargo-lambda.info/commands/watch.html).
Read more about invoking the function in [the Cargo Lambda documentation for the `invoke` command](https://www.cargo-lambda.info/commands/invoke.html).

## Deploying

To deploy the project, run `cargo lambda deploy`. This will create an IAM role and a Lambda function in your AWS account.

Read more about deploying your lambda function in [the Cargo Lambda documentation](https://www.cargo-lambda.info/commands/deploy.html).
1 change: 0 additions & 1 deletion functions/create-issue/__tests__/__snapshots__/intro.html

This file was deleted.

Loading
Loading