Unverified Commit f9e5d64a authored by John DiSanti's avatar John DiSanti Committed by GitHub
Browse files

Implement a canary Lambda for the SDK (#956)

parent 979c7034
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -7,6 +7,7 @@
import "source-map-support/register";
import * as cdk from "@aws-cdk/core";
import { PullRequestCdnStack } from "../lib/smithy-rs/pull-request-cdn-stack";
import { CanaryStack } from "../lib/aws-sdk-rust/canary-stack";
import { OidcProviderStack } from "../lib/oidc-provider-stack";

const app = new cdk.App();
@@ -16,3 +17,7 @@ const oidcProviderStack = new OidcProviderStack(app, "oidc-provider-stack", {});
new PullRequestCdnStack(app, "smithy-rs-pull-request-cdn-stack", {
    githubActionsOidcProvider: oidcProviderStack.githubActionsOidcProvider,
});

new CanaryStack(app, "aws-sdk-rust-canary-stack", {
    githubActionsOidcProvider: oidcProviderStack.githubActionsOidcProvider,
});
+3 −0
Original line number Diff line number Diff line
# The Cargo.toml should be generated every time it's needed
/Cargo.toml
/Cargo.lock
+32 −0
Original line number Diff line number Diff line
Canary Lambda
=============

This is a Rust Lambda that exercises the AWS SDK for Rust in a real Lambda
environment. It is intended to be rebuilt with the latest or previous AWS
SDK version in the `aws-sdk-rust` repository, deployed, and then run to
determine that that version is still OK.

For example, after releasing a new version of the SDK to crates.io, this
can be compiled against that new version, deployed, and run to verify the
deployed SDK is functioning correctly. Similarly, it can be used to verify
the previous version of the SDK continues to work after the deployment
of the new version.

Building locally for Lambda
---------------------------

1. Make sure the `musl-gcc` wrapper is installed.
2. Add the musl target for Rust:

```
$ rustup target add x86_64-unknown-linux-musl
```

3. Build a code bundle:

```
$ ./build-bundle.sh
```

This will place a zip file in `smithy-rs/target/x86_64-unknown-linux-musl/release` that can be
uploaded and tested against Lambda.
+84.2 KiB

File added.

No diff preview for this file type.

+30 −0
Original line number Diff line number Diff line
#!/bin/bash
#
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
# SPDX-License-Identifier: Apache-2.0.
#

set -e

if [[ $# -ne 1 ]]; then
    echo "Usage: $0 <sdk version>"
    exit 1
fi
SDK_VERSION=$1

cd `dirname $0`
./write-cargo-toml.py --sdk-version ${SDK_VERSION}
cargo build --release --target=x86_64-unknown-linux-musl

TARGET_PATH="$(git rev-parse --show-toplevel)/target/x86_64-unknown-linux-musl/release"
pushd "${TARGET_PATH}" &>/dev/null

BIN_NAME="bootstrap"
BIN_SHA1_HASH="$(sha1sum ${BIN_NAME} | awk '{ print $1; }')"
BUNDLE_NAME="canary-lambda-${BIN_SHA1_HASH}.zip"

zip --quiet "${BUNDLE_NAME}" "${BIN_NAME}"
popd &>/dev/null

# Output: the path to the bundle
echo "${TARGET_PATH}/${BUNDLE_NAME}"
Loading