Command Line Interface¶
Sceptre can be used as a command line tool. Running Sceptre without a sub-command will display help, showing a list of the available commands.
Running Sceptre without a subcommand will display help, showing a list of the available commands.
Autocomplete¶
To enable CLI autocomplete for subcommands and parameters execute the following command:
shell |
command |
---|---|
bash |
eval “$(_SCEPTRE_COMPLETE=source sceptre)” |
zsh |
eval “$(_SCEPTRE_COMPLETE=source_zsh sceptre)” |
Export Stack Outputs to Environment Variables¶
Stack outputs can be exported as environment variables with the command:
eval $(sceptre --ignore-dependencies list outputs STACKGROUP/STACK.yaml --export=envvar)
Note that Sceptre prepends the string SCEPTRE_
to the name of the
environment variable:
env | grep SCEPTRE
SCEPTRE_<output_name>=<output_value>
Variable Handling¶
You can pass variables into your project using --var-file
and --var
.
Varibles passed in with --var
will overwrite any matching variables specified in
--var-file
. If you use multiple --var
flags then the right-most --var
will
overwrite any matching --vars
to the left. For example, in the following command
sceptre --var var1=one --var var2=two --var var1=three launch stack
var1
will equal three
.
You can also use --var
to overwrite nested keys in a --var-file
. For example,
given a variable file “vars.yaml”:
# vars.yaml
---
top:
middle:
nested: hello
middle2:
nested: world
we could overwrite nested: world
to nested: hi
using:
sceptre --var-file vars.yaml --var top.middle2.nested=hi launch stack
Note
Sceptre will load your entire project to build a full dependency graph.
This means that all stacks that use variables will need to have a value
provided to them - even if they are not in your command_path
or are not
a dependency. Using a –var-file with all variables set can help meet this
requirement.
It is also possible to have keys merged according to a deep merge
algorithm from successive var files, by specifying --merge-vars
. So, if we
had a second variable file “vars2.yaml”:
# other_vars.yaml
---
top:
middle3:
nested: more world
We could merge all of this together using:
sceptre --merge-vars --var-file vars.yaml --var-file other_vars.yaml launch stack
The top
dictionary would then be expected to contain:
{
"top": {
"middle": {"nested": "hello"},
"middle2": {"nested": "world"},
"middle3": {"nested": "more world"}
}
}
Command reference¶
Command options differ depending on the command, and can be found by running:
sceptre
sceptre --help
sceptre COMMAND --help
sceptre¶
Sceptre is a tool to manage your cloud native infrastructure deployments.
sceptre [OPTIONS] COMMAND [ARGS]...
Options
- --version¶
Show the version and exit.
- --debug¶
Turn on debug logging.
- --dir <directory>¶
Specify sceptre directory.
- --output <output>¶
The formatting style for command output.
- Options
text | yaml | json
- --no-colour¶
Turn off output colouring.
- --var <var>¶
A variable to replace the value of an item in config file.
- --var-file <var_file>¶
A YAML file of variables to replace the values of items in config files.
- --ignore-dependencies¶
Ignore dependencies when executing command.
- --merge-vars¶
Merge variables from successive –vars and var files
create¶
Creates a stack for a given config PATH. Or if CHANGE_SET_NAME is specified creates a change set for stack in PATH.
sceptre create [OPTIONS] PATH [CHANGE_SET_NAME]
Options
- -y, --yes¶
Assume yes to all questions.
Arguments
- PATH¶
Required argument
- CHANGE_SET_NAME¶
Optional argument
delete¶
Deletes a stack for a given config PATH. Or if CHANGE_SET_NAME is specified deletes a change set for stack in PATH.
sceptre delete [OPTIONS] PATH [CHANGE_SET_NAME]
Options
- -y, --yes¶
Assume yes to all questions.
Arguments
- PATH¶
Required argument
- CHANGE_SET_NAME¶
Optional argument
describe¶
Commands for describing attributes of stacks.
sceptre describe [OPTIONS] COMMAND [ARGS]...
diff¶
Indicates the difference between the currently DEPLOYED stacks in the command path and the stacks configured in Sceptre right now. This command will compare both the templates as well as the subset of stack configurations that can be compared.
Some settings (such as sceptre_user_data) are not available in a CloudFormation stack description, so the diff will not be indicated. Currently compared stack configurations are:
Important: There are resolvers (notably !stack_output, among others) that rely on other stacks to be already deployed when they are resolved. When producing a diff on Stack Configs that have such resolvers that point to non-deployed stacks, this presents a challenge, since this means those resolvers cannot be resolved. This particularly applies to stack parameters and when a stack’s template uses sceptre_user_data with resolvers in it. In order to continue to be useful when producing a diff in these conditions, this command will do the following:
1. If the resolver CAN be resolved, it will be resolved and the resolved value will be in the diff results. 2. If the resolver CANNOT be resolved, it will be replaced with a string that represents the resolver and its arguments. For example: !stack_output my_stack.yaml::MyOutput will resolve in the parameters to “{ !StackOutput(my_stack.yaml::MyOutput) }”.
Particularly in cases where the replaced value doesn’t work in the template as the template logic requires and causes an error, there is nothing further Sceptre can do and diffing will fail.
sceptre diff [OPTIONS] PATH
Options
- -t, --type <differ>¶
The type of differ to use. Use “deepdiff” for recursive key/value comparison. “difflib” produces a more traditional “diff” result. Defaults to deepdiff.
- Options
deepdiff | difflib
- -s, --show-no-echo¶
If set, will display the unmasked values of NoEcho parameters generated LOCALLY (NoEcho parameters for deployed stacks will always be masked when retrieved from CloudFormation.). If not set (the default), parameters identified as NoEcho on the local template will be masked when presented in the diff.
Arguments
- PATH¶
Required argument
estimate-cost¶
Prints a URI to STOUT that provides an estimated cost based on the resources in the stack. This command will also attempt to open a web browser with the returned URI.
sceptre estimate-cost [OPTIONS] PATH
Arguments
- PATH¶
Required argument
execute¶
Executes a Change Set.
sceptre execute [OPTIONS] PATH CHANGE_SET_NAME
Options
- -y, --yes¶
Assume yes to all questions.
Arguments
- PATH¶
Required argument
- CHANGE_SET_NAME¶
Required argument
fetch-remote-template¶
Prints the remote template used for stack in PATH.
sceptre fetch-remote-template [OPTIONS] PATH
Arguments
- PATH¶
Required argument
generate¶
Prints the template used for stack in PATH.
sceptre generate [OPTIONS] PATH
Arguments
- PATH¶
Required argument
launch¶
Launch a Stack or StackGroup for a given config PATH.
sceptre launch [OPTIONS] PATH
Options
- -y, --yes¶
Assume yes to all questions.
Arguments
- PATH¶
Required argument
list¶
Commands for listing attributes of stacks.
sceptre list [OPTIONS] COMMAND [ARGS]...
change-sets¶
List change sets for stack.
sceptre list change-sets [OPTIONS] PATH
Options
- -U, --url¶
Instead write a URL.
Arguments
- PATH¶
Required argument
new¶
Commands for initialising Sceptre projects.
sceptre new [OPTIONS] COMMAND [ARGS]...
set-policy¶
Sets a specific Stack policy for either a file or using a built-in policy.
sceptre set-policy [OPTIONS] PATH [POLICY_FILE]
Options
- -b, --built-in <built_in>¶
Specify a built in stack policy.
- Options
deny-all | allow-all
Arguments
- PATH¶
Required argument
- POLICY_FILE¶
Optional argument
status¶
Prints the stack status or the status of the stacks within a stack_group for a given config PATH.
sceptre status [OPTIONS] PATH
Arguments
- PATH¶
Required argument
update¶
Updates a stack for a given config PATH. Or perform an update via change-set when the change-set flag is set.
sceptre update [OPTIONS] PATH
Options
- -c, --change-set¶
Create a change set before updating.
- -v, --verbose¶
Display verbose output.
- -y, --yes¶
Assume yes to all questions.
Arguments
- PATH¶
Required argument