2 min read | by Jordi Prats
Sceptre is a command-line tool that allows you to manage AWS CloudFormation stacks. One of the features of sceptre is the ability to use stack outputs in other stacks, allowing you to create a dependent relationship between stacks, where one stack's output can be used as an input to another stack.
Let's assume we are creating a S3 bucket that one of it's outputs is the BucketName:
AWSTemplateFormatVersion: 2010-09-09
Description: Deploy the S3 Service Catalog Product
Parameters:
BucketName:
Type: String
(...)
Outputs:
BucketName:
Description: Name of created S3 Bucket
Value: !GetAtt Bucket.Outputs.BucketName
ARN:
Description: ARN of created S3 Bucket
Value: !GetAtt Bucket.Outputs.ARN
We can instantiate it as usual:
template_path: "s3.yaml"
parameters:
BucketName: test-s3
To use the output from one stack as an input in another, we can utilize the stack_output function in Sceptre. This function takes in two arguments: the name of the stack (including the full path if necessary) and the specific output that we want to use, separated by double colons.
template_path: "velero-backups-policy.yaml"
parameters:
PolicyNameSuffix: VeleroBackups
BucketName: !stack_output s3.yaml::BucketName
Since we are using the output of one stack as input for another, we are defining an implicit dependency.
Posted on 30/01/2023