Skip to main content

Blueprint Quickstart Guide

Now that you have seen how Torque works, it’s time to link your assets to Torque and see what you can do with them.

In this article:

Prerequisites

  • You have created your own space
  • Asset repository associated to the space
  • Execution host associated to the space

Let Torque autogenerate blueprints from your assets

Torque launches environments out of blueprints, which are YAML files that represent the environments. So the first step is to create blueprints out of your existing assets.

  1. In your space, go to Settings > Repositories and discover your assets.

Locale Dropdown

  1. Select the assets you want Torque to discover and click Generate Blueprints.

Locale Dropdown

Torque creates a blueprint YAML for each asset, and lists the blueprints in your space’s Blueprints page. You can click the blueprint to see the YAML file.

Locale Dropdown

  1. Publish the blueprints and you’re good to go.

Locale Dropdown

You and your space’s users can now launch these environments from the space.

In some cases, you may need to adjust your autogenerated blueprints. For details on what you can do, see Autogenerated Blueprints.

Create a multi-asset blueprint

So far, we’ve learned how to create single-asset blueprints. But what if you want to create an application-stack environment? This is easily done by nesting an existing blueprint within a master blueprint as a grain.

It is also possible to nest a single-asset blueprint, which can be an application or cloud service deployed via an asset, like a Terraform module, Helm chart, or CloudFormation template, to name a few. To do so, save the autogenerated blueprint as a blueprint yaml file in the space's blueprint repository, and follow the below steps.

To nest a blueprint as a grain in another blueprint:

  1. Open the new blueprint's YAML file.
  2. Add a new grain to the grains section.
  3. Define the grain's details. These are the mandatory settings:
    • Change the _kind param to: kind: blueprint
    • In store, specify the name of the blueprint repository defined in the space.
    • In path, specify blueprints/<blueprint file name without ".yaml">. Alternatively, specify only blueprints and change the grain name to the blueprint file name without ".yaml".
    • Specify the execution host as an input of type: execution-host on the blueprint level, and reference it from the grain, both as an input and in the host section.
  4. If the grain should run after the deployment of another grain, add __depends_on: <name of grain dependency>:
    grains:
    my-nested-blueprint-grain:
    kind: blueprint
    depends-on: infra-grain
    spec:
    source:
    store: <space's blueprint repository>
    path: blueprints/<blueprint file name without ".yaml">
    host:
    name: prod-host
    inputs:
    - my-excution-host: prod-host
  5. Define the rest of the grain's settings as appropriate. For details, see Blueprint YAML.

Example 1: Helm Application with MySQL and S3 Deployed by Terraform

This blueprint is available in the Sample space here, which deploys 2 Terraform modules and a Helm chart:

spec_version: 2
description: Robotshot microservices application deployed on K8S with Helm and RDS deployed with TF

outputs:
WebsiteUrl:
kind: link
value: 'https://portal.qtorque.io/static/demo-quick-links/stans-robot-shop.html'


grains:
mySqlDB:
kind: terraform
spec:
source:
path: github.com/QualiTorque/samples.git//terraform/rds
host:
name: eks-demo
inputs:
- sandbox_id: '{{ sandboxid | downcase }}'
- size: small
- allocated_storage: 20
- db_name: demo_db
- engine_version: 8.0.26
- engine: MySQL
- username: adminuser
- vpc_id: vpc-02e3bca90b081cd0f
- region: us-east-1
outputs:
- hostname
- connection_string

s3Bucket:
kind: terraform
spec:
source:
path: github.com/QualiTorque/samples.git//terraform/s3
host:
name: eks-demo
inputs:
- region: eu-west-1
- acl: public-read
- name: 'robotshop-s3-{{ sandboxid | downcase }}'
outputs:
- s3_bucket_arn

robotShopMicroservices:
kind: helm
depends-on: mySqlDB, s3Bucket
spec:
source:
path: https://github.com/QualiTorque/samples.git//helm/robotshop
host:
name: eks-demo
inputs:
- hostname: 'robotshop-{{ sandboxid | downcase }}'
- version: 0.4.3
- connectionString: '{{ .grains.mySqlDB.outputs.connection_string }}'
- objectStore.s3BucketArn: '{{ .grains.s3Bucket.outputs.s3_bucket_arn }}'
- redis.storageClassName: gp2

Example 2: Webgame on S3 (using CloudFormation and Terraform)

spec_version: 2
description: "S3 Bucket creation with Input and Output parameters"

inputs:
# The access_control property is case-sensitive and must be one of the following values:
# Private, PublicRead, PublicReadWrite, AuthenticatedRead, LogDeliveryWrite, BucketOwnerRead, BucketOwnerFullControl, or AwsExecRead
Access Control:
type: string
description: >
Type of access to configure on Bucket objects: Private, PublicRead, PublicReadWrite, AuthenticatedRead,
LogDeliveryWrite, BucketOwnerRead, BucketOwnerFullControl, or AwsExecRead
default: "PublicRead"
allowed-values: ["Private", "PublicRead", "PublicReadWrite"]
Bucket Name:
type: string
default: my-bucket-test
AWS Region:
description: "The name of the AWS Region to use"
default: "us-west-1"
allowed-values: ["us-west-1", "us-west-2", "eu-west-1"]


outputs:
S3 Bucket ARN:
value: '{{ .grains.my-S3-Bucket.outputs.Arn }}'
S3 Bucket Domain Name:
value: '{{ .grains.my-S3-Bucket.outputs.DomainName }}'
kind: link
Webgame Link:
value: '{{ .grains.S3-Upload-Webapp-File.outputs.website_link }}'
kind: link

grains:
CFN-S3-Bucket:
kind: cloudformation
spec:
source:
# store: autogen_repo_sandbox_2453f24g9
path: https://.../AWSS3Bucket.yaml
region: '{{ .inputs.["AWS Region"] }}'
authentication:
role-arn: arn:aws:iam::{{ .params.My_Torque_AWS }}:role/{{ .params.My_Torque_Agent_IAM_Role }}
external-id: '{{ .params.My_Torque_External_ID }}'
inputs:
- AccessControl: '{{ .inputs.["Access Control"] }}'
- BucketName: '{{ .inputs.["Bucket Name"] }}-{{ sandboxid | downcase }}'
outputs:
- Arn
- DomainName

S3-Upload-Webapp-File:
kind: terraform
depends-on: my-S3-Bucket
spec:
source:
store: assets
path: assets/terraform/s3-deploy-webapp
host:
name: demo-prod
service-account: app-sa
inputs:
- bucket_name: '{{ .inputs.["Bucket Name"] }}-{{ sandboxid | downcase }}'
- region: '{{ .inputs.["AWS Region"] }}'
outputs:
- website_link
# The terraform version that will be used to deploy the module
tf-version: 1.2.3