Sceptre - AWS Cloud Provisioning Tool

4.6.0 · active · verified Fri Apr 17

Sceptre is an AWS Cloud Provisioning Tool that simplifies the deployment and management of CloudFormation stacks and stack groups. It extends CloudFormation with features like template generation, environment-specific configurations, and programmatic resolution of values. The current version is 4.6.0, and it maintains an active development cycle with regular releases addressing features and bug fixes, typically on a quarterly or bi-annual basis for major versions.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to programmatically invoke Sceptre commands using its Python API. It runs a simple version check that doesn't require an AWS environment or a Sceptre project structure. For full functionality like deploying stacks, you would need a properly configured Sceptre project (with `config/` and `templates/` directories) and AWS credentials.

import os
import sys
from io import StringIO
from unittest.mock import patch
from sceptre.cli import sceptre

# Sceptre is primarily a CLI tool that operates on a project structure.
# For full functionality (e.g., `launch`, `validate`), you need:
# 1. A Sceptre project directory (e.g., `./config`, `./templates`).
# 2. AWS credentials configured (e.g., via ~/.aws/credentials, environment variables).

# This example demonstrates how to call a simple Sceptre command programmatically
# that does not require a project setup or AWS credentials, making it runnable.

print("Attempting to get Sceptre version programmatically...")

# Mock sys.stdout to capture output without affecting the console directly
with patch('sys.stdout', new_callable=StringIO) as mock_stdout:
    try:
        # Call the Sceptre CLI programmatically to get its version
        # This command is safe and does not require AWS setup.
        sceptre(["--version"])
        output = mock_stdout.getvalue()
        print(f"Sceptre version output:\n{output.strip()}")

    except SystemExit as e:
        # Sceptre CLI often uses sys.exit(), which `sceptre.cli.sceptre` reflects.
        # A SystemExit with code 0 usually indicates success for '--version'.
        if e.code != 0:
            print(f"Error: Sceptre command exited with code {e.code}")
        else:
            print(f"Sceptre command finished (exit code {e.code}).")

print("\nTo run actual Sceptre deployment commands (e.g., 'launch'):")
print("  1. Ensure you have a Sceptre project structure (config/ and templates/ directories).")
print("  2. Configure your AWS credentials (e.g., environment variables or ~/.aws/credentials).")
print("  Example (if project set up): # sceptre([\"launch\", \"dev/my-stack\"])")

view raw JSON →