Skip to content

Examples

Both Module and Stack support the parameter examples.

Each example-item requires 3 fields:

  • name - Identity of the example in the module
  • description - Brief summary about this examples (markdown, so you can put links, images etc)
  • variables - Each variable you specify will guide the user how it should be entered. It should contain at least all “required” variables. Any non-required variable you don’t specify here will not be shown in the example, and will help making it easier for the user.

Here is an example of adding a simple and an advanced example for a module (notice the difference between Module and Stack below)

modules/vpc.yaml
apiVersion: infraweave.io/v1
kind: Module
metadata:
name: VPC
spec:
version: 0.1.5-alpha.1
reference: https://github.com/infraweave-io/example/module/vpc
description: |
Description about VPC here...
examples:
- name: simple-vpc
variables:
vpc_name: replace-me
description: |
# Simple Bucket
This example creates a simple VPC.
## Description
This creates a VPC with private /26 subnets in two availability zones.
- name: advanced-vpc
variables:
vpc_name: replace-me
cidr_block: 10.0.0.0/24
availability_zones: 3
enable_internet_gateway: true
enable_nat_gateway: true
enable_vpc_endpoints:
s3: true
dynamodb: true
enable_flow_logs: true
flow_logs_destination: cloudwatch
security_groups:
web_servers:
description: Security group for web servers
ingress:
- protocol: tcp
port: 80
cidr: 0.0.0.0/0
- protocol: tcp
port: 443
cidr: 0.0.0.0/0
egress:
- protocol: -1
port: all
cidr: 0.0.0.0/0
database:
description: Security group for database servers
ingress:
- protocol: tcp
port: 3306
sourceSecurityGroup: webServers
egress:
- protocol: -1
port: all
cidr: 0.0.0.0/0
tags:
Name: myvpc-14923
Environment: dev
description: |
# Advanced Bucket
## Description
This can be used to set up an advanced version of the VPC with much more options
### Some examples of advanced features include:
- **NAT Gateways**: Ensures that instances in private subnets can access the Internet securely without exposing them directly.
- **VPC Endpoints**: Provides secure and scalable connections to AWS services without traversing the public Internet.
- **Flow Logs**: Facilitates monitoring and troubleshooting by capturing detailed information about network traffic.
- **Enhanced Security Groups**: Implements granular access controls between different tiers of the application (e.g., web and database servers).

Purpose

These examples serves two purposes:

  • Describes how it is intended to use. In combination with Backstage it will automatically create a guided deployment
  • Template testing. These examples can be automatically set up as readymade regression-tests in pipelines for the Module/Stack

Variables

There is an important difference between Module and Stacks:

Module

Module examples are written with terraform code in mind, and you most likely tested locally running terraform code, hence examples uses snake_case to make it easy to port:

examples:
- name: advanced-bucket
description: |
# Some description here
variables:
bucket_name: mybucket-14923
tags:
Name: mybucket-14923
Environment: dev

Stacks

Stack examples are written from the perspective of an application team only exposed to the claims, where users likely have several working module deployment claims, and want to make it an established Stack, hence examples uses camelCase to follow the deployment manifest convention:

examples:
- name: bucketcollection
description: |
# Some description here
variables:
bucket1a: # Input for claim named "bucket1a"
bucketName: my-temp-bucket1a
bucket2: # Input for claim named "bucket2"
bucketName: another-bucket1a
tags:
Name: mybucket-14923
Environment: dev

Backstage

Backstage has great templating support for projects, InfraWeave adds an extra dimension by creating deployments with variable support inferred by the terraform module - no documentation needed, always up to date with the version you click! (including descriptions of the variables)