Skip to content

Commit

Permalink
Start quickstart quide
Browse files Browse the repository at this point in the history
  • Loading branch information
EricGhildyal committed Nov 28, 2024
1 parent 4cbbdc1 commit 3e86ee2
Show file tree
Hide file tree
Showing 4 changed files with 148 additions and 27 deletions.
49 changes: 22 additions & 27 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<p align="center"><b>Your AI-powered, agentic deployment solution for seamless, risk-managed updates</b></p>

<p align="center">
🏡 <a href="https://www.multitool.run/">MultiTool website</a> | 🗪 <a href="https://www.multitool.run/contact">Contact us</a>
🏡 <a href="https://www.multitool.run/" target="_blank">MultiTool website</a> | 🗪 <a href="https://www.multitool.run/contact">Contact us</a>

## What is MultiTool Canary?

Expand All @@ -15,44 +15,40 @@ MultiTool Canary is an agentic deployment tool that quickly detects and rolls ba
This section explains how to deploy an AWS Lambda function to AWS API Gateway using MultiTool Canary. Just point MultiTool Canary to a pre-built Lambda zip, tell it which API Gateway, Stage, and Lambda to deploy to, and it will take care of the rest.

1. First, make sure your AWS credentials are configured:

```bash
$ aws sts get-caller-identity
```

If your credentials aren't set, either login with `aws sso login --profile my-profile` or set your Access Key Id and Secret Access Key:

```bash
$ export AWS_ACCESS_KEY_ID="${MY_ACCESS_KEY}"
$ export AWS_SECRET_ACCESS_KEY="${MY_SECRET_ACCESS_KEY}"
$ export AWS_REGION="us-east-2"
```

2. Next, tell MultiTool Canary which API Gateway, Stage, and Lambda it should deploy it.
```bash
$ export MULTI_GATEWAY_NAME="${MY_API_GATEWAY_NAME}"
$ export MULTI_GATEWAY_STAGE="${MY_STAGE}"
$ export MUTLI_LAMBDA_NAME="${MY_LAMBDA}"
```
1. Build your Lambda function. This should be a zipfile with your Lambda's source code. For instance, if you're using `cargo-lambda`:

3. Build your Lambda function. This should be a zipfile with your Lambda's source code. For instance, if you're using `cargo-lambda`:
```bash
$ cargo lambda build -o zip --release
$ mv ./target/lambda/my-app/bootstrap.zip ./my-release.zip
```

4. Finally, run MultiTool Canary, pointing to a pre-built zip:
1. Finally, run MultiTool Canary, pointing to a pre-built zip:
```bash
$ canary deploy ./my-release.zip
$ canary deploy deploy --aws-apig-name ${MY_APIGATEWAY_NAME} --aws-apig-stage ${MY_APIGATEWAY_STAGE} --aws-lambda ${MY_LAMBDA_NAME} ./my-release.zip
```

MultiTool Canary will upload the function to AWS, cut a canary release, and monitor it, progresssingly ramping up traffic as it gains confidence in the deployment. MultiTool Canary scans your CloudWatch metrics to see how your canary application is performing relative to the baseline, and models release confidence based on how they differ.
MultiTool Canary will upload the function to AWS, cut a canary release, and monitor it, progresssingly ramping up traffic as it gains confidence in the deployment. MultiTool Canary scans your CloudWatch metrics to see how your canary application is performing relative to the baseline, and models release confidence based on how they differ.

## Table of Contents

- [What is MultiTool Canary?](#what-is-multitool-canary-)
- [Getting Started](#getting-started)
- [Table of Contents](#table-of-contents)
- [Installation](#installation)
* [Building from source](#building-from-source)
- [Building from source](#building-from-source)
- [Architecture support](#architecture-support)
- [Mission](#mission)
- [Contributing](#contributing)
Expand Down Expand Up @@ -93,24 +89,24 @@ To build MultiTool Canary from source, refer to instructions in [CONTRIBUTING.md

## Features

* Automatic application deployment
* Automated rollback
* Cautious Mode (coming soon) and Optimistic Mode: Choose between preventing false positives and false negatives
* Measure release confidence
* Backward and forward traffic ramping
- Automatic application deployment
- Automated rollback
- Cautious Mode (coming soon) and Optimistic Mode: Choose between preventing false positives and false negatives
- Measure release confidence
- Backward and forward traffic ramping

## Platform Support

Currently, MultiTool Canary only supports deploying canaries for AWS Lambda functions running in AWS API Gateway. However, we are currently working on adding support for additional platforms. Our platform roadmap is presented in the table below.

| Platform | Support |
| :----------------------------------------------------------: | :----------------------------: |
| **AWS Lambda + API Gateway** | :sparkles: Available! |
| [Vercel](vercel.com) | :eyes: Up next |
| Platform | Support |
| :----------------------------------------------------------------------------------------------------------------------: | :----------------------------: |
| **AWS Lambda + API Gateway** | :sparkles: Available! |
| [Vercel](vercel.com) | :eyes: Up next |
| [CloudFlare](https://developers.cloudflare.com/workers/configuration/versions-and-deployments/gradual-deployments/#_top) | :eyes: Up next |
| [AWS Function Aliases](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-alias.html) | :watch: Soon |
| [Kubernetes](https://kubernetes.io/) | :hourglass_flowing_sand: Later |
| [Google Cloud Run Functions](https://cloud.google.com/functions) | :hourglass_flowing_sand: Later |
| [AWS Function Aliases](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-alias.html) | :watch: Soon |
| [Kubernetes](https://kubernetes.io/) | :hourglass_flowing_sand: Later |
| [Google Cloud Run Functions](https://cloud.google.com/functions) | :hourglass_flowing_sand: Later |

## Architecture support

Expand All @@ -123,13 +119,12 @@ MultiTool Canary has official builts for 64-bit Windows, macOS (Apple Silicon an
| Curl |||||
| Powershell |||||

## Mission
## Mission

We're building tools to take agentic deployments mainstream. Right now, operators must synchronously watch deployments go live, or rely on passive metric alerting to identify service disruptions. We want to empower operators to *proactively* identify and rollback disruptive deployments *before* they reach 100% of users with the help of an AI agent. MultiTool Canary is our foundational strategy to introduce agentic deployments to everyone. To learn more about us, visit [our company website](https://www.multitool.run/company).
We're building tools to take agentic deployments mainstream. Right now, operators must synchronously watch deployments go live, or rely on passive metric alerting to identify service disruptions. We want to empower operators to _proactively_ identify and rollback disruptive deployments _before_ they reach 100% of users with the help of an AI agent. MultiTool Canary is our foundational strategy to introduce agentic deployments to everyone. To learn more about us, visit [our company website](https://www.multitool.run/company).

## Contributing

:rocket: We accept pull requests! :guitar:

See [CONTRIBUTING.md](https://github.com/wack/canary/blob/trunk/CONTRIBUTING.md) for more information.

8 changes: 8 additions & 0 deletions guides/quickstart/lambda_code/base/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
exports.handler = function (_, context) {
return context.succeed({
statusCode: 200,
body: JSON.stringify({
message: "Hello World",
}),
});
};
19 changes: 19 additions & 0 deletions guides/quickstart/lambda_code/random_errors/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
exports.handler = function (_, context) {
const rand = Math.random();

if (rand < 0.5) {
return context.succeed({
statusCode: 200,
body: JSON.stringify({
message: "Hello World",
}),
});
} else {
return context.fail({
statusCode: 500,
body: JSON.stringify({
error: "Something went wrong",
}),
});
}
};
99 changes: 99 additions & 0 deletions guides/quickstart/quickstart.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
# MultiTool Canary Quickstart Guide

In this guide, you'll learn how to safely deploy an AWS Lambda function as an API endpoint using the AWS API Gateway.

# Prerequisites

1. You must have an AWS account with root user access or an IAM user with read and write permissions for Lambda and API Gateway
1. Install the AWS CLI. [Click here for instructions.](https://docs.aws.amazon.com/cli/latest/userguide/getting-started-install.html)

1. Either login with `aws sso login --profile my-profile` or set your Access Key Id and Secret Access Key:

```bash
$ aws sts get-caller-identity
$ export AWS_ACCESS_KEY_ID="${MY_ACCESS_KEY}"
$ export AWS_SECRET_ACCESS_KEY="${MY_SECRET_ACCESS_KEY}"
$ export AWS_REGION="us-east-2"
```

1. Install MultiTool Canary. [Click here for instructions.](https://github.com/wack/canary?tab=readme-ov-file#installation)

# Getting Started with AWS Lambda and API Gateway

## Package your Lambda as a zip file

```bash
$ zip -j base.zip guides/quickstart/lambda_code/base/index.js
```

## Create a Lambda execution IAM role

```bash
$ LAMBDA_EXECUTION_ROLE_ARN=$(aws iam create-role \
--role-name lambda-execution \
--assume-role-policy-document '{"Version": "2012-10-17","Statement": [{ "Effect": "Allow", "Principal": {"Service": "lambda.amazonaws.com"}, "Action": "sts:AssumeRole"}]}' --output text --query Role.Arn)
```

## Create a Lambda using the zip file

```bash
$ LAMBDA_ARN=$(aws lambda create-function --function-name canary-quickstart-lambda \
--runtime nodejs22.x \
--handler index.handler \
--role ${LAMBDA_EXECUTION_ROLE_ARN} \
--zip-file fileb://base.zip \
--output text \
--query FunctionArn)
```

## Create an API Gateway

```bash
$ API_ID=$(aws apigateway create-rest-api --name canary-quickstart-apig --output text --query id )
```

## Get the Root resource's auto-generated ID

```bash
$ ROOT_RESOURCE_ID=$(aws apigateway get-resources --rest-api-id ${API_ID} --output text --query items[0].id)
```

## Create a resource in the gateway

```bash
$ RESOURCE_ID=$(aws apigateway create-resource --rest-api-id ${API_ID} --parent-id ${ROOT_RESOURCE_ID} --path-part "demo" --output text --query 'id')
```

## Add a GET endpoint method to the resource

```bash
$ aws apigateway put-method --rest-api-id ${API_ID} --resource-id ${RESOURCE_ID} --http-method GET --authorization-type "NONE"
```

## Update the API Gateway to point at the lambda we created

```bash
$ aws apigateway put-integration \
--rest-api-id ${API_ID} \
--resource-id ${RESOURCE_ID} \
--http-method GET \
--type AWS_PROXY \
--integration-http-method POST \
--uri arn:aws:apigateway:${AWS_REGION:=us-east-2}:lambda:path/2015-03-31/functions/${LAMBDA_ARN}/invocations
```

## Create a deployment

```bash
$ $ aws apigateway create-deployment --rest-api-id $API_ID --stage-name prod
```

## Give permissions for the API Gateway to invoke the Lambda

```bash
$ aws lambda add-permission \
--function-name canary-quickstart-lambda \
--statement-id apigateway-permission-${API_ID} \
--action lambda:InvokeFunction \
--principal apigateway.amazonaws.com
```

0 comments on commit 3e86ee2

Please sign in to comment.