Index of every page on this site: llms.txt
All skills
jd-solanki avatar

/aws-best-practices

@372cfb1
by JD Solankijd-solanki/ai6 stars
2
Run it yourself

AWS service-specific best practices and configuration rules. Use when making decisions about RDS environment isolation, SSM Parameter Store, SQS consumer types, Lambda function structure, or SAM template conventions.

Use this Skill: https://skilld.dev/gh/jd-solanki/ai/aws-best-practices

Nothing lands on disk. Nothing to clean up.

Fork this Skill

Edit a local copy. It keeps the author and licence.

SSM.md

≈1.2k tokens on demand. Your agent reads this file only when SKILL.md points to it.

SSM Parameter Store — Best Practices

Rule 1: Never create SSM parameters via CloudFormation / SAM

AWS::SSM::Parameter in a SAM/CloudFormation template is an anti-pattern for any value you'll later populate with a real value.

Why it bites you:

CloudFormation has no ignore_changes equivalent. If you create a parameter with a placeholder and then set the real value out-of-band, the next sam deploy sees the template still says "PLACEHOLDER" and resets it — clobbering your real secret.

Additional hard blocker: CloudFormation only supports String and StringList parameter types. You cannot create a SecureString via CloudFormation. For anything sensitive, the in-template approach is not even available without a custom resource.

What the template should do instead:

Grant ssm:GetParameter permission and pass the parameter name (not value) as an env var:

# IAM — grant read access
- Effect: Allow
  Action: ssm:GetParameter
  Resource:
    - !Sub "arn:aws:ssm:${AWS::Region}:${AWS::AccountId}:parameter/myapp/prod/api-credentials"

# Lambda env var — name only, not the value
Environment:
  Variables:
    API_CREDENTIALS_PARAMETER_NAME: /myapp/prod/api-credentials

The parameter itself must exist before first deploy, created by a bootstrap step (see Rule 3).


Rule 2: Prefer runtime fetching over deploy-time resolution in Lambda

Two tempting but problematic patterns:

# Pattern A — SSM parameter type (deploy-time)
Parameters:
  DbHost:
    Type: AWS::SSM::Parameter::Value<String>
    Default: /myapp/prod/db-host

# Pattern B — dynamic reference (deploy-time)
Environment:
  Variables:
    DB_PASSWORD: '{{resolve:ssm-secure:/myapp/prod/db-password}}'

Both bake the value into the Lambda config at deploy time. If the secret rotates (API key, DB password, third-party token), the running function holds the stale value until you redeploy.

Lambda-specific nuance: Lambda caches environment variables for the lifetime of the execution environment (minutes to hours). A rotated secret won't reach your function until a cold start after redeploy — you may not even notice until failures start.

Prefer runtime fetching instead:

import boto3
import json
import os

ssm = boto3.client("ssm")

def get_credentials():
    response = ssm.get_parameter(
        Name=os.environ["API_CREDENTIALS_PARAMETER_NAME"],
        WithDecryption=True
    )
    return json.loads(response["Parameter"]["Value"])

For high-frequency invocations, cache the value in a module-level variable with a TTL rather than fetching on every call. The AWS Parameters and Secrets Lambda Extension handles this automatically (caches and refreshes without a redeploy) and is the preferred approach for production workloads.

When deploy-time resolution is acceptable: non-sensitive, environment-stable config (region names, feature flags, stack names) that never rotates and doesn't need to change without a redeploy.


Rule 3: Scalable pattern — separate parameter lifecycle from the app stack

Config values and secrets change on a different cadence than your application code. Coupling them into the same stack ties two independent concerns together.

The scalable approach:

Bootstrap step (runs once, before first sam deploy)
  └── aws ssm put-parameter --name /myapp/prod/api-credentials \
        --value '{"client_id":"...","client_secret":"..."}' \
        --type SecureString

App stack (sam deploy — every release)
  └── assumes parameter already exists, only reads it at runtime

Options for owning the parameter's lifecycle:

Owner When to use
CI pre-deploy script (aws ssm put-parameter --overwrite) Simple; good for per-environment secrets managed in CI
Separate bootstrap/foundation stack Parameters shared across multiple app stacks; clearer dependency
Secrets Manager (with SSM reference) Secrets that need rotation policies or cross-account access
Manual + documented runbook One-time credentials that never rotate; lowest overhead

Chicken-and-egg on first deploy: document required parameters in a BOOTSTRAP.md or in the SAM template's Parameters section description. The IAM ssm:GetParameter deny will fail loudly at Lambda invocation time if the parameter is missing — this is acceptable and surfaceable via CloudWatch alarms.


Decision tree

Is it a secret / credential?
├── Yes → SecureString, created outside the stack, fetched at runtime
│         Consider Secrets Manager if rotation is needed
└── No → Is it environment-stable config that never rotates?
          ├── Yes → deploy-time resolution is fine (SSM parameter type or {{resolve:}})
          └── No (rotates or changes independently) → runtime fetch, module-level cache

Source: SKILL.md on GitHub

skilld matched fixed text patterns in SKILL.md and file names. Patterns miss obfuscated code.

skilld run checks every file with the same patterns. It asks for approval before it loads a Skill with a behavior marked Needs approval.

No alerts2mo3 checks · Risk SAFE
  • Gen Agent Trust Hub2mo

    This skill provides architectural guidance and reusable templates for AWS services, focusing on security best practices like environment isolation and runtime secret fetching. No malicious patterns or security risks were detected.

  • Socket2mo

    No alerts

  • Snyk2mo

    Risk: LOW · No issues

Signed by skilld at 372cfb1. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub 4 days ago.

Activeupdated 3 months ago

README badge

README badge for jd-solanki/ai/aws-best-practices