Skip to content

Check that CLI examples use approved placeholders and fix existing violations - #10823

Merged
luigi617 merged 2 commits into
code-example-ci-8from
code-example-ci-9
Oct 30, 2026
Merged

luigi617 merged 2 commits into
code-example-ci-8from
code-example-ci-9

Conversation

@luigi617

Copy link
Copy Markdown
Contributor

Issue #, if available:

Description of changes:
Check that CLI examples use approved placeholders and fix existing violations

Rules from the "Sanitizing sensitive information" section of the Style guide:

  1. "Sanitize your examples. Replace all sensitive information with placeholders such as:"
  2. "Account IDs: 123456789012. If your example requires multiple account IDs, then use this pattern: 123456789111, 123456789222, 123456789333, …"
  3. "GUIDs: a1b2c3d4-5678-90ab-cdef-EXAMPLE11111. If your example requires multiple GUIDs, then use this pattern: a1b2c3d4-5678-90ab-cdef-EXAMPLE22222, a1b2c3d4-5678-90ab-cdef-EXAMPLE33333, …"
  4. "Regions: us-west-2. Unless the resource can only exist in a different region."
  5. "Bucket names: amzn-s3-demo-bucket. If your example requires multiple buckets, then use this pattern: amzn-s3-demo-bucket1, amzn-s3-demo-bucket2, amzn-s3-demo-bucket3, …"
  • Added test_example_sanitization to tests/functional/docs/test_examples.py:
    • Account IDs, GUIDs, bucket names (in s3://, S3 ARNs, --bucket, and "Bucket" keys) and regions must use the approved placeholders.
    • Examples that use two or more regions (for example a cross-region copy or a DynamoDB global table) are not checked for regions.
    • Digits inside longer IDs (such as ami-066877671789bd71b) and S3 access point URIs (s3://arn:...) are not flagged.
  • Replaced account IDs, GUIDs, bucket names and regions with the approved placeholders in 2455 example files, keeping related values consistent:
    • Availability Zones match the new region.
    • Cross-account examples use a second account (123456789111).
    • Lists that would repeat a region after the change were deduplicated.
  • Examples that need a real value are listed per example in example_style_exceptions.json (92 examples), each with its reason:
    • Resources that only exist in one region, such as CloudFront certificates and global WAF web ACLs, and the ECR Public, Route 53 Domains and Cost and Usage Report APIs (all us-east-1)
    • AWS-owned accounts, such as the Amazon AMI owner, Inspector rules packages and the predefined patch baselines
    • AWS-owned buckets, such as the EMR sample bucket, CodeDeploy agent buckets and the GameLift build bucket
    • Fixed IDs, such as the AWS managed CloudFront cache policy ID and the DRM SystemId

Testing

  • Run pytest tests/functional/docs/test_examples.py -n auto
=== 64297 passed in 25.82s =====

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

luigi liu added 2 commits October 29, 2026 15:28
Use the style guide placeholders for account IDs, GUIDs, bucket names
and regions. Follows https://aws.github.io/aws-cli/docs_styleguide.html.
Add a check for the sanitizing sensitive information rule of the AWS CLI
code example style guide: account IDs, GUIDs, bucket names and regions
use the approved placeholders.

Examples that need a real value are listed in
example_style_exceptions.json: resources that only exist in one region
(such as CloudFront certificates or the ECR Public API in us-east-1),
examples that need several regions or accounts, and AWS-owned accounts
and buckets.
@luigi617
luigi617 added this pull request to stack #10814 October 29, 2026 19:49
@luigi617
luigi617 requested a review from a team as a code owner October 29, 2026 19:49
@luigi617 luigi617 changed the title Code example ci 9 Check that CLI examples use approved placeholders and fix existing violations Oct 29, 2026
@luigi617
luigi617 merged commit bd0ae4f into v2 Oct 30, 2026
162 of 166 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants