layout | title |
---|---|
docs |
Resolvers |
This is a set of resolvers to retrieve additional information about the current stack and make it available to jinja templates.
Fetches the current stack name.
Syntax:
parameter|sceptre_user_data:
<name>: !stack_name
Examples:
sceptre_user_data:
stackenv: !stack_name
Fetches the current stack configuration environment name.
Syntax:
parameter|sceptre_user_data:
<name>: !stack_env
Examples:
sceptre_user_data:
stackenv: !stack_env
config/dev/buckets.yaml:
template_path: buckets.j2
stack_name: mystack
sceptre_user_data:
stackname: !stack_name
stackenv: !stack_env
buckets_count: 4
bucket_name_prefix: mybucket
templates/buckets.j2:
{# Jinja template to deploy multiple buckets #}
AWSTemplateFormatVersion: '2010-09-09'
Description: S3 buckets
Resources:
{% for n in range(sceptre_user_data.buckets_count|int) %}
{{ sceptre_user_data.stackenv }}S3Bucket{{ loop.index }}:
Type: AWS::S3::Bucket
Properties:
BucketName: {{ sceptre_user_data.stackenv }}-{{ sceptre_user_data.stackenv }}-{{ sceptre_user_data.bucket_name_prefix }}-{{ loop.index }}
{% endfor %}
sceptre --output yaml generate dev/buckets.yaml
AWSTemplateFormatVersion: '2010-09-09'
Description: S3 buckets
Resources:
mystackS3Bucket1:
Properties:
BucketName: mystack-dev-mybucket-1
Type: AWS::S3::Bucket
mystackS3Bucket2:
Properties:
BucketName: mystack-dev-mybucket-2
Type: AWS::S3::Bucket
mystackS3Bucket3:
Properties:
BucketName: mystack-dev-mybucket-3
Type: AWS::S3::Bucket
mystackS3Bucket4:
Properties:
BucketName: mystack-dev-mybucket-4
Type: AWS::S3::Bucket