Introduction

Blueprints are ordinary stack configuration, but unlike stacks, can't be deployed. Stacks can inherit configuration from them and also override parts or all of the inherited configuration. Blueprints can help you to reduce repetitive configuration.

Blueprints can contain the same properties as ordinary stacks. You place blueprint files to blueprints directory or its subdirectories. Each blueprint file must have .yml extension.

In stack configuration, you use blueprint property to specify from which blueprint the stack inherits its configuration.

Example

Our project looks like this:

1.
2├─ stacks
3│  ├─ frontend.yml
4│  ├─ backend.yml
5│  ├─ operative-database.yml
6│  └─ reporting-database.yml
7├─ templates
8│  ├─ application-template.yml
9│  ├─ database-template.yml
10│  └─ custom-database-template.yml
11└─ blueprints
12   ├─ application.yml
13   └─ database.yml

We have four stacks and two blueprints. Let's look at the blueprints first.

blueprints/application.yml is blueprint for applications. It doesn't specify any parameters, so any stack using it, must provide values for the parameters found in templates/application-template.yml template file.

blueprints/application.yml
1template: application-template.yml
2regions: eu-west-1

templates/application-template.yml is template used by blueprints/application.yml blueprint.

templates/application-template.yml
1Parameters:
2  Environment:
3    Type: String
4    Description: Application environment
5  Name:
6    Type: String
7    Description: Application name
8  DockerImage:
9    Type: String
10    Description: Application docker image
11
12Resources:
13  # ...Resources omitted for brevity

Our project has two application stacks: frontend.yml and backend.yml. They both use blueprints/application.yml and provide value for its parameters.

stacks/frontend.yml
1blueprint: application.yml
2paramters:
3  Environment: dev
4  Name: Frontend App
5  DockerImage: frontend:1.0.0
stacks/backend.yml
1blueprint: application.yml
2paramters:
3  Environment: dev
4  Name: Backend App
5  DockerImage: backend:2.0.0

blueprints/database.yml is blueprint for databases. It provides some default values for its parameters.

blueprints/database.yml
1template: database-template.yml
2regions: eu-west-1
3parameters:
4  InstanceClass: db.m4.large
5  AllocatedStorage: 50
6  Engine: mariadb
7  EngineVersion: 10.6.8

templates/database-template.yml is template used by blueprints/application.yml blueprint.

templates/database-template.yml
1Parameters:
2  Environment:
3    Type: String
4    Description: Database environment
5  InstanceClass:
6    Type: String
7    Description: Database instance class
8  AllocatedStorage:
9    Type: Number
10    Description: Database allocated storage
11  Engine:
12    Type: String
13    Description: Database engine
14  EngineVersion:
15    Type: String
16    Description: Database engine version
17    
18Resources:
19  # ...Resources omitted for brevity

templates/custom-database-template.yml is some customized database template with fewer parameters.

templates/custom-database-template.yml
1Parameters:
2  Environment:
3    Type: String
4    Description: Database environment
5  AllocatedStorage:
6    Type: Number
7    Description: Database allocated storage
8    
9Resources:
10  # ...Resources omitted for brevity

Finally, there are two database stacks: operative-database.yml and reporting-database.yml. They both use blueprints/database.yml but the latter uses an alternative template.

stacks/operative-database.yml
1blueprint: database.yml
2paramters:
3  Environment: dev
4  InstanceClass: db.m4.medium
5  AllocatedStorage: 25
stacks/reporting-database.yml
1blueprint: database.yml
2template: custom-database-template.yml
3paramters:
4  Environment: dev
5  AllocatedStorage: 100
ON THIS PAGE