steering_docs/python-tech/readme_writeme.md
Generate and update README files and documentation using the writeme tool to ensure consistency and completeness.
python/example_code/{service}/
├── README.md # Generated service README
├── requirements.txt # Dependencies
└── {service}_metadata.yaml # Metadata (in .doc_gen/metadata/)
cd .tools/readmes
# Create virtual environment
python -m venv .venv
# Activate environment (Linux/macOS)
source .venv/bin/activate
# Activate environment (Windows)
.venv\Scripts\activate
# Install dependencies
python -m pip install -r requirements_freeze.txt
# Generate README for specific service
python -m writeme --languages Python:3 --services {service}
# {AWS Service} code examples for the SDK for Python
## Overview
This is a workspace where you can find the following AWS SDK for Python (Boto3)
{AWS Service} examples.
## ⚠ 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.
## Code examples
### Actions
The following examples show you how to perform actions using the AWS SDK for Python (Boto3).
* [Create a resource](action_file.py#L123) (`CreateResource`)
* [Get a resource](action_file.py#L456) (`GetResource`)
### Scenarios
The following examples show you how to implement common scenarios.
* [Get started with resources](scenario_file.py) - Learn the basics by creating and managing resources.
### Hello
* [Hello {Service}](hello_file.py) - Get started with {AWS Service}.
## Prerequisites
- You must have an AWS account, and have your default credentials and AWS Region configured.
- Python 3.6 or later
- Boto3 1.26.137 or later
- PyTest 5.3.5 or later (to run unit tests)
## Install
Install the prerequisites using pip:
pip install -r requirements.txt
## Run the examples
### Instructions
All examples can be run individually. For example:
python hello_{service}.py
### Hello {Service}
This example shows you how to get started using {AWS Service}.
python hello_{service}.py
### Get started with {Service} resources
This interactive scenario runs at a command prompt and shows you how to use {AWS Service} to do the following:
1. Create a resource
2. Use the resource
3. Clean up resources
python scenario_{service}_basics.py
## Run the tests
Unit tests in this module use the botocore Stubber. This captures requests before
they are sent to AWS, and returns a mocked response. To run all of the tests,
run the following in your [GitHub root]/python/example_code/{service} folder.
python -m pytest
## Additional resources
- [{AWS Service} User Guide](https://docs.aws.amazon.com/{service}/latest/ug/)
- [{AWS Service} API Reference](https://docs.aws.amazon.com/{service}/latest/APIReference/)
- [AWS SDK for Python ({AWS Service})](https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/{service}.html)
.doc_gen/metadata/{service}_metadata.yamlrequirements.txt with dependenciesThe writeme tool uses metadata to:
# Check for metadata errors
python -m writeme --languages Python:3 --services {service} --verbose
# Validate specific metadata file
python -c "import yaml; yaml.safe_load(open('.doc_gen/metadata/{service}_metadata.yaml'))"
# Check for missing snippet tags
grep -r "snippet-start" python/example_code/{service}/
# In CI/CD pipeline, validate README is up-to-date
cd .tools/readmes
source .venv/bin/activate
python -m writeme --languages Python:3 --services {service} --check
# Exit with error if README needs updates
if git diff --exit-code python/example_code/{service}/README.md; then
echo "README is up-to-date"
else
echo "README needs to be regenerated"
exit 1
fi
This ensures documentation stays synchronized with code changes.