Skip to content

Commit

Permalink
Writeme: Add support for snippet_files in writeme. (awsdocs#5016)
Browse files Browse the repository at this point in the history
  • Loading branch information
DavidSouther authored Jul 5, 2023
1 parent 665a529 commit c0ebfa4
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 15 deletions.
10 changes: 8 additions & 2 deletions .doc_gen/readmes/scanner.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,15 +106,21 @@ def snippet(self, example, sdk_ver, readme_folder, api_name):
if ex_ver['sdk_version'] == sdk_ver:
github = ex_ver.get('github')
if github is not None:
excerpt = ex_ver['excerpts'][0]
tags = excerpt.get('snippet_tags', [])
if 'excerpts' in ex_ver:
for t in ex_ver['excerpts'][0]['snippet_tags']:
for t in tags:
if api_name in t:
tag = t
if tag is None:
tag = ex_ver['excerpts'][0]['snippet_tags'][0]
tag = next(iter(tags), None)
elif 'block_content' in ex_ver:
tag_path = github
if github is not None and tag_path is None:
snippet_files = excerpt.get("snippet_files", None)
if snippet_files is not None:
# TODO: Find the best (or all?) snippet files, not the first.
tag_path = snippet_files[0]
for root, dirs, files in os.walk(github):
for f in files:
try:
Expand Down
68 changes: 55 additions & 13 deletions rust_dev_preview/examples/lambda/README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<!--Generated by WRITEME on 2023-06-06 21:26:13.280925 (UTC)-->

<!--Generated by WRITEME on 2023-07-04 16:03:54.273097 (UTC)-->
# Lambda code examples for the SDK for Rust

## Overview
Expand All @@ -9,14 +8,14 @@ Shows how to use the AWS SDK for Rust to work with AWS Lambda.
<!--custom.overview.start-->
<!--custom.overview.end-->

_Lambda allows you to run code without provisioning or managing servers._
*Lambda allows you to run code without provisioning or managing servers.*

## ⚠ Important

- Running this code might result in charges to your AWS account.
- Running the tests might result in charges to your AWS account.
- We recommend that you grant your code least privilege. At most, grant only the minimum permissions required to perform the task. For more information, see [Grant least privilege](https://docs.aws.amazon.com/IAM/latest/UserGuide/best-practices.html#grant-least-privilege).
- This code is not tested in every AWS Region. For more information, see [AWS Regional Services](https://aws.amazon.com/about-aws/global-infrastructure/regional-product-services).
* Running this code might result in charges to your AWS account.
* Running the tests might result in charges to your AWS account.
* We recommend that you grant your code least privilege. At most, grant only the minimum permissions required to perform the task. For more information, see [Grant least privilege](https://docs.aws.amazon.com/IAM/latest/UserGuide/best-practices.html#grant-least-privilege).
* This code is not tested in every AWS Region. For more information, see [AWS Regional Services](https://aws.amazon.com/about-aws/global-infrastructure/regional-product-services).

<!--custom.important.start-->
<!--custom.important.end-->
Expand All @@ -25,18 +24,39 @@ _Lambda allows you to run code without provisioning or managing servers._

### Prerequisites

For prerequisites, see the [README](../README.md#Prerequisites) in the `rust_dev_preview` folder.
For prerequisites, see the [README](../../README.md#Prerequisites) in the `rust_dev_preview` folder.


<!--custom.prerequisites.start-->

Additionally, to compile Lambda functions written in the Rust programming language, use [Cargo Lambda](https://www.cargo-lambda.info/).

<!--custom.prerequisites.end-->

### Single actions

Code excerpts that show you how to call individual service functions.

* [Create a function](src/actions.rs#L233) (`CreateFunction`)
* [Delete a function](src/actions.rs#L472) (`DeleteFunction`)
* [Get a function](src/actions.rs#L380) (`GetFunction`)
* [Invoke a function](src/actions.rs#L405) (`Invoke`)
* [List functions](src/actions.rs#L393) (`ListFunctions`)
* [Update function code](src/actions.rs#L421) (`UpdateFunctionCode`)
* [Update function configuration](src/actions.rs#L447) (`UpdateFunctionConfiguration`)

### Scenarios

Code examples that show you how to accomplish a specific task by calling multiple
functions within the same service.

* [Get started with functions](rust_dev_preview/examples/lambda/Cargo.toml)

## Run the examples

### Instructions


<!--custom.instructions.start-->

Before running the scenario, compile the Lambda functions.
Expand All @@ -57,21 +77,43 @@ Other single action examples write directly to stdout, and can be executed with

<!--custom.instructions.end-->



#### Get started with functions

This example shows you how to do the following:

* Create an IAM role and Lambda function, then upload handler code.
* Invoke the function with a single parameter and get results.
* Update the function code and configure with an environment variable.
* Invoke the function with new parameters and get results. Display the returned execution log.
* List the functions for your account, then clean up resources.

<!--custom.scenario_prereqs.lambda_Scenario_GettingStartedFunctions.start-->
<!--custom.scenario_prereqs.lambda_Scenario_GettingStartedFunctions.end-->


<!--custom.scenarios.lambda_Scenario_GettingStartedFunctions.start-->
<!--custom.scenarios.lambda_Scenario_GettingStartedFunctions.end-->

### Tests

⚠ Running tests might result in charges to your AWS account.

To find instructions for running these tests, see the [README](../README.md#Tests)

To find instructions for running these tests, see the [README](../../README.md#Tests)
in the `rust_dev_preview` folder.



<!--custom.tests.start-->
<!--custom.tests.end-->

## Additional resources

- [Lambda Developer Guide](https://docs.aws.amazon.com/lambda/latest/dg/welcome.html)
- [Lambda API Reference](https://docs.aws.amazon.com/lambda/latest/dg/API_Reference.html)
- [SDK for Rust Lambda reference](https://docs.rs/aws-sdk-lambda/latest/aws_sdk_lambda/)
* [Lambda Developer Guide](https://docs.aws.amazon.com/lambda/latest/dg/welcome.html)
* [Lambda API Reference](https://docs.aws.amazon.com/lambda/latest/dg/API_Reference.html)
* [SDK for Rust Lambda reference](https://docs.rs/aws-sdk-lambda/latest/aws_sdk_lambda/)

<!--custom.resources.start-->

Expand All @@ -82,4 +124,4 @@ in the `rust_dev_preview` folder.

Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.

SPDX-License-Identifier: Apache-2.0
SPDX-License-Identifier: Apache-2.0

0 comments on commit c0ebfa4

Please sign in to comment.