Skip to main content

Sceptre resolver to execute generic shell commands

Project description

Sceptre shell command resolver

This resolver can be used to execute any shell command.

Why?

This resolver is handy, because it allows you to dynamically resolve parameters at runtime. The beautiful thing about it is that it's infintely extensible! You can use it to connect any command line tool to Sceptre.

Use it in conjunction with the typical unix tools (cat, cut, grep etc...) or third party ones (vault, op, etc...)

Use the !rcmd tag to activate the resolver. You can also use pipe commands, and generic bash (maybe powershell too but I haven't tried it).

The yaml tag !cmd is already used by sceptre hooks, unfortunately it wasn't possible to use the same YAML tag for this custom resolver, so the tag !rcmd was used instead.

Installation

# To install directly from PyPI
pip install sceptre-cmd-resolver

# To install from this git repo
pip install git+https://github.com/Sceptre/sceptre-resolver-cmd.git

Usage / Examples

Use the !rcmd tag to activate the resolver. You can also use pipe commands, and generic bash (perhaps even powershell but I haven't tested it).

# Resolve the contents of a file with cat
parameters:
  DatabasePassword: !rcmd cat .env/dev/password
# Resolve data from a json file with cat + jq
parameters:
  DatabasePassword: !rcmd cat .env/data | jq -r '.Passwords.dev'
# Resolve a secret in vault using the vault CLI (you must be logged in!)
parameters:
  DatabasePassword: !rcmd vault kv get -field=password myapp/database/dev
parameters:
  # Resolve the EC2 AMI Image ID to the latest official version of Ubuntu 20.04 at deploy time
  EC2ImageIdUbuntu: !rcmd >-
    aws ssm get-parameters
      --region eu-west-2
      --names /aws/service/canonical/ubuntu/server/20.04/stable/current/amd64/hvm/ebs-gp2/ami-id
      --query 'Parameters[0].[Value]' --output text

  # Resolve the EC2 AMI Image ID to the latest official version Windows Server 2019 at deploy time
  EC2ImageIdWindows: !rcmd >-
    aws ssm get-parameters
      --region eu-west-2
      --names /aws/service/ami-windows-latest/Windows_Server-2019-English-Full-Base
      | jq -r '.Parameters[0].Value' | jq -r '.image_id'
# Add a human readable comment with the deployment date
parameters:
  DeployNote: !rcmd echo "Deployed by `whoami` on `date` :-)"
# Execute the command with the same AWS profile provided to Sceptre
parameters:
  CanonicalUserId: !rcmd
    command: "aws s3api list-buckets --query Owner.ID --output text"
# Override the command execution with a specific AWS profile, region, and/or sceptre_role
parameters:
  CanonicalUserId: !rcmd
    command: "aws s3api list-buckets --query Owner.ID --output text"
    profile: "my-profile"
    region: "us-west-2"
    sceptre_role: "arn:aws:iam::123456:role/my-role-to-override-the-stack-role"

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

sceptre-cmd-resolver-2.0.0.tar.gz (4.3 kB view details)

Uploaded Source

Built Distribution

sceptre_cmd_resolver-2.0.0-py2.py3-none-any.whl (4.7 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file sceptre-cmd-resolver-2.0.0.tar.gz.

File metadata

  • Download URL: sceptre-cmd-resolver-2.0.0.tar.gz
  • Upload date:
  • Size: 4.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.8.8

File hashes

Hashes for sceptre-cmd-resolver-2.0.0.tar.gz
Algorithm Hash digest
SHA256 155c47e2f4f55c7b6eb64bfe8760174701442ecaddba1a6f5cb7715a1c95be99
MD5 2e93640641114162f041d30bc77ed2dd
BLAKE2b-256 6580acb986323af0b3e5e3eb59bb293e6671cdc43ded91620a24a1a58b2e28f7

See more details on using hashes here.

File details

Details for the file sceptre_cmd_resolver-2.0.0-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for sceptre_cmd_resolver-2.0.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 eea8ce4cfcd9199f726b4280e7e35923c9d4ea5d75cbe4a8ee78c0d6d2996d09
MD5 9cf830bf0c2d5510d6c88ebe937e960a
BLAKE2b-256 038f465ac4b87e967d9d023aaad7a9595d82e1cfdb5d532c8f50ab046adef0e3

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page