Skip to content

tv2/npp-aws-sam-local-secrets-public

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

15 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

npp-aws-sam-local-secrets-public

πŸ” Fetch secrets from AWS Secrets Manager and generate a .json file β€” to use with AWS SAM for local development.


βœ… Prerequisites

Before running the script, make sure you have:

  • AWS CLI installed and configured with the correct --profile.
  • jq installed. Install it via Homebrew:
    brew install jq

πŸš€ Usage

Run the script locally:

bash bin/fetch-secrets.sh <secrets.json> <output.json> [--region eu-central-1] [--profile tv2-cms-dev]

πŸ”— Run directly from GitHub

You can also run the script directly without cloning:

curl -sSL https://raw.githubusercontent.com/tv2/npp-aws-sam-local-secrets-public/main/bin/fetch-secrets.sh | bash -s -- <secrets.json> <output.json> [--region ...] [--profile ...]

Example:

# Fetch secrets and generate local.env.json from local.secrets.json
curl -sSL https://raw.githubusercontent.com/tv2/npp-aws-sam-local-secrets-public/main/bin/fetch-secrets.sh \
  | bash -s -- local.secrets.json local.env.json --region eu-central-1 --profile tv2-cms-dev

πŸ“‚ Example secrets.json

See example.secrets.json for the expected format of the input file.

βš™οΈ Using with AWS SAM

To use the generated secrets with AWS SAM, pass the output file using --env-vars:

sam local start-api --env-vars local.env.json

πŸ”’ Security tip

The generated secrets file (local.env.json) contains real secret values. Always add it to .gitignore so it’s never committed to Git! Example .gitignore:

# Local AWS secrets
local.env.json

βœ… That’s it β€” happy secret fetching!

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages