Emit Stack Templates
Emit stack templates within the given command path to stdout or to files.
This operation is like deploy but doesn't perform actual deploy for stacks. Instead, stack templates are written to stdout or to a specified dir. Stack parameters are resolved and hooks are executed just like in deploy operation. In some cases, especially when stacks have dependencies, this will cause problems as resolvers might try to get values for parameters from stacks that do not exist yet. If you face these issues, you can use --skip-parameters and --skip-hooks options to skip parameter resolving and executing hooks, respectively. Bear in mind though that using these options might break something in your templates if you are using dynamic templating.
Usage
1tkm stacks emit [command-path] \
2 [--ignore-dependencies] \
3 [--interactive|-i] \
4 [--out-dir <path to dir where templates are emitted>]
5 [--skip-parameters] \
6 [--skip-hooks]
Positional arguments
command-path
- Command path to select which stacks to include in the operation.
- Optional, all stacks are included by default.
Options
In addition to the common options, this command has the following options.
--ignore-dependencies
- Ignore stack dependencies.
--interactive, -i
- Choose the command path using autocompleting search.
--out-dir <path to dir where templates are emitted>
- Path to directory where template files are written.
- If this options is omitted, templates are written only to stdout.
--skip-parameters
- Skip resolving values for parameters using parameter resolvers and set stack parameters as an empty array.
- Skip validating parameter values.
--skip-hooks
IAM permissions
These are the minimum IAM permissions required to run this command.
1# Minimum permissions. Additional permissions might be needed if hooks or
2# parameter resolvers are used.
3Statement:
4 - Sid: CloudFormation
5 Effect: Allow
6 Action:
7 - cloudformation:GetTemplate
8 - cloudformation:ValidateTemplate
9 - cloudformation:DescribeStacks
10 - cloudformation:GetTemplateSummary
11 Resource: "*"
12
13 # S3 permissions needed only if template bucket is used.
14 # Specify resource to restrict access to specific buckets.
15 - Sid: S3
16 Effect: Allow
17 Action:
18 - s3:PutObject
19 Resource: "*"
20
21 # IAM permissions needed only if command roles are used
22 # Specify resource to restrict access to specific roles.
23 - Sid: IAM
24 Effect: Allow
25 Action:
26 - sts:AssumeRole
27 Resource: "*"
Examples
Emit templates for all stacks:
Emit templates to /tmp dir:
1tkm stacks emit --out-dir /tmp
Omit all logging expect the templates themselves:
Emit templates for stacks within the given command path:
Emit template only for stack /dev/vpc.yml stack and its dependencies:
1tkm stacks emit /dev/vpc.yml
The region part must be specified if the stack has more than one region and you want to choose only one region.
1tkm stacks emit /dev/vpc.yml/eu-west-1
Emit template of exactly one stack and skip its dependencies:
1tkm stacks emit /cloudtrail.yml --ignore-dependencies