Ludwig Tutorial 4: Route Table

This tutorial is actually a Ludwig composition. You can download it here and fugue run it like you would any other composition. You can use lwc, the Ludwig compiler, to compile the composition.

If you’re interested in text editor plug-ins, you can find them here.

Ready?

Let’s Go!

We’ll begin with the work from the last tutorial.

composition

import Fugue.AWS as AWS
import Fugue.AWS.EC2 as EC2

my-vpc: EC2.Vpc.new {
  cidrBlock: "10.0.0.0/16",
  region: AWS.Us-west-2
}

subnet1: EC2.Subnet.new {
  cidrBlock: '10.0.1.0/24',
  vpc: my-vpc,
  availabilityZone: AWS.A,
  mapPublicIpOnLaunch: True
}

my-igw: EC2.InternetGateway.new {
  vpc: my-vpc
}

Here, a route table is added.

route-table: EC2.RouteTable.new {
  vpc: my-vpc,
  routes: [

Lists in Ludwig are homogenous. Values can either be literals, or functions that return a value of the same type as the rest in the list, just like a binding. Therefore, this function call in the middle of a list is perfectly valid.

EC2.Route.new {
  destinationCidrBlock: "0.0.0.0/0",

This is a positional argument function. Idiomatic Ludwig only uses this notation for single-argument functions (with the exception proving the rule being the tag function). The function shown here takes an internet gateway value, performs some validation, and returns a route target.

      target: EC2.GatewayTarget(my-igw)
    }
  ],
  associations: [subnet1]
}

Running and Compiling the Composition

You can run this composition with the following command:

fugue run Tutorial4.lw

This will create the following infrastructure in your AWS account:

  • VPC
  • Subnet
  • Internet gateway
  • Route table

Optionally, if you have a process running from previous tutorials, you can simply update the process like this:

fugue update [ALIAS or FID] Tutorial4.lw

To just check compilation, invoke lwc, the Ludwig compiler:

lwc Tutorial4.lw