Skip to content

Commit

Permalink
add v2 function zip
Browse files Browse the repository at this point in the history
  • Loading branch information
aimeeu committed Nov 27, 2023
1 parent 07c8305 commit 26a71b2
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 2 deletions.
Binary file not shown.
44 changes: 42 additions & 2 deletions content/en/get-started/lambda/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -392,8 +392,45 @@ targets:
- staging
{{< /highlight >}}

## Upload function v2

#### Create an AWS Lambda alias
1. <a href="/get-started/lambda/files/just-sweet-potatoes-v2.zip" download>Download the function v2 zip file</a>.
1. Rename the zip file to `just-sweet-potatoes.zip`.
1. Upload the file to each of your `armory-demo-lambda-deploy` S3 buckets, overwriting the existing `just-sweet-potatoes.zip` file.

<details><summary>Expand to see the v2 code</summary>

```js

exports.handler = async (event) => {
// Get a random sweet potato fact
const randomFact = potatolessFacts[Math.floor(Math.random() * potatolessFacts.length)];

// Prepare the response
const response = {
statusCode: 200,
body: randomFact,
};

return response;
};

const potatolessFacts = [
"Sweet potatoes are a great source of vitamin A, which is important for vision health.",
"There are over 400 varieties of sweet potatoes around the world.",
"Sweet potatoes are not related to regular potatoes; they belong to the morning glory family.",
"Sweet potatoes are high in fiber, making them good for digestion.",
"Sweet potatoes come in different colors, including orange, purple, and white.",
"Sweet potatoes are one of the oldest vegetables known to man.",
"North Carolina is the largest producer of sweet potatoes in the United States.",
"Sweet potatoes are often used in Thanksgiving dishes like casseroles and pies.",
"Sweet potatoes and yams are not the same vegetable even though many Americans use the two names interchangeably.",
];
```

</details>

## Create an AWS Lambda alias

Check warning on line 433 in content/en/get-started/lambda/index.md

View workflow job for this annotation

GitHub Actions / vale

[vale] content/en/get-started/lambda/index.md#L433

[Google.Headings] 'Create an AWS Lambda alias' should use sentence-style capitalization.
Raw output
{"message": "[Google.Headings] 'Create an AWS Lambda alias' should use sentence-style capitalization.", "location": {"path": "content/en/get-started/lambda/index.md", "range": {"start": {"line": 433, "column": 4}}}, "severity": "WARNING"}

CD-as-a-Service uses an AWS Lambda [alias](https://docs.aws.amazon.com/lambda/latest/dg/configuration-aliases.html) when routing traffic between old and new versions of your function. Before you can use use the `trafficSplit` strategy, create an AWS Lambda alias for the functions you deployed to `prod-west-1` and `prod-west-2`.

Expand All @@ -404,7 +441,7 @@ In your AWS Lambda console, make sure you are in region `us-west-1`. Access the

Repeat for the `just-sweet-potatoes-prod-west-2` function.

#### Add traffic management info
## Add traffic management configuration

Now that you've created aliases, you need to declare those in a new `trafficManagement` section so CD-as-a-Service can perform the traffic split strategy. Add the following top-level section to your deployment config file:

Expand All @@ -421,6 +458,9 @@ trafficManagement:
{{< /highlight >}}





## Deploy your function for a second time

Start your second deployment using the CLI:
Expand Down

0 comments on commit 26a71b2

Please sign in to comment.