Stacks
A stack in Smokestack literally represents a CloudFormation stack.
Your project will contain a smokestack.Stack
class for each stack to be deployed.
Describing a minimal stack
At the very least, your stack class must implement:
smokestack.Stack.body
: Return either the body of the template as a string or apathlib.Path
that describes the location of a template file.smokestack.Stack.name
: Return the name of the stack.smokestack.Stack.region
: Return the Amazon Web Services region to deploy into.
from pathlib import Path
from smokestack import Stack
class ApplicationStack(Stack):
@property
def body(self) -> Path:
return Path("templates") / "app.cf.yml"
@property
def name(self) -> str:
return "Application"
@property
def region(self) -> str:
return "us-east-1"
Capabilities
To describe any capabilities that your stack requires, override smokestack.Stack.capabilities
to return a string list.
from smokestack import Capabilities, Stack
class ApplicationStack(Stack):
@property
def capabilities(self) -> Capabilities:
return [
"CAPABILITY_IAM",
]
Dependencies
To describe any upstream stacks that must be deployed before this one, override smokestack.Stack.needs
to return the other stack types.
from smokestack import Capabilities, Stack
import myproject.stacks
class ApplicationStack(Stack):
@property
def needs(self) -> : List[Type[Stack]]:
return [
myproject.stacks.DatabaseStack,
myproject.stacks.LoggingStack,
]
Parameters
To describe any parameter values that your stack requires, override the smokestack.Stack.parameters()
function. This will provide a CFP StackParameters
instance to add parameter values to.
from cfp import StackParameters
from smokestack import Capabilities, Stack
class ApplicationStack(Stack):
def parameters(self, params: StackParameters) -> None:
params.add("InstanceType", "t3.large")
See the CFP documentation for StackParameters
tips and tricks.
Post-execution actions
To perform some post-execution action (e.g. to copy files into an S3 bucket that your stack deployed) override the smokestack.Stack.post()
function.
Stack
class
- class smokestack.Stack
An Amazon Web Services CloudFormation stack.
- abstract property body: Union[str, pathlib.Path]
Gets the template body or path to the template file.
- property capabilities: Sequence[Literal['CAPABILITY_AUTO_EXPAND', 'CAPABILITY_IAM', 'CAPABILITY_NAMED_IAM']]
Gets the capabilities required to deploy this stack.
- abstract property name: str
Gets the stack’s name.
- property needs: List[Type[smokestack.stack.Stack]]
Gets the stacks that must be deployed before this one.
- parameters(params: cfp.stack_parameters.StackParameters) None
Populates this stack’s parameters.
- Arguments:
params: Stack parameters. Provided by CFP: https://cariad.github.io/cfp/
- post(operation: smokestack.types.operation.Operation, out: IO[str]) None
Performs any post-execution actions.
- Arguments:
operation: Operation. out: Output writer.
- abstract property region: str
Gets the Amazon Web Services region to deploy this stack into.