Hello World

Hi

This is one of those obligatory first posts…

I started a blog to put some stuff out there that needed to be shared. I’d tried sharing personal GitHub links, but that didn’t work. We have a corporate Medium account, but personally I found the deployment and writing a headache. Then, through the help of a colleague I came across Victor-Hugo, Netlify and a solution that matched my needs.

During that journey, I went on a discovery mission… During a chat he kind of made the process sound like this:

  1. Get Netlify
  2. Install Victor-Hugo
  3. Write some stuff
  4. Profit

But, in reality things were slightly different. I wanted (want) to personalise the whole process. No point creating a brand (this blog) if it’s not personal. So, that journey has been fun (really!). I’m on holiday, the kids are in bed and I am looking to fulfil my creative outlet.

On that journey, I came across something neat. I work for HashiCorp - who, amongst other things, are the makers of Terraform. And, what kind of employee would I be if I didn’t have the correct syntax highlighting in my personal blog? Do you want the same? Here’s how you can too:

  1. Checkout this page about syntax highlighting
  2. And then follow the link to configure the syntax highlighting in your config file (Note: it might already be done, in which case you can pick and chose options to suit your needs or skip these steps and just try using the syntax after step 4 below)
  3. Make any adjustments you might want (I changed the style to abap) (Note: You can find the complete style list here)
  4. Then, when you want to highlight code in your article, you can use the highlighting syntax:
    ```tf
    your terraform code here
    ```

So here is default code block:

module "vpc" {
  source = "terraform-aws-modules/vpc/aws"

  name = "my-vpc"
  cidr = "10.0.0.0/16"

  azs             = ["ap-southeast-2a", "ap-southeast-2b", "ap-southeast-2c"]
  private_subnets = ["10.0.1.0/24", "10.0.2.0/24", "10.0.3.0/24"]
  public_subnets  = ["10.0.101.0/24", "10.0.102.0/24", "10.0.103.0/24"]

  enable_nat_gateway = true
  enable_vpn_gateway = true

  tags = {
    Terraform = "true"
    Environment = "dev"
  }
}

And then now with Terraform syntax highlighting.

module "vpc" {
  source = "terraform-aws-modules/vpc/aws"

  name = "my-vpc"
  cidr = "10.0.0.0/16"

  azs             = ["ap-southeast-2a", "ap-southeast-2b", "ap-southeast-2c"]
  private_subnets = ["10.0.1.0/24", "10.0.2.0/24", "10.0.3.0/24"]
  public_subnets  = ["10.0.101.0/24", "10.0.102.0/24", "10.0.103.0/24"]

  enable_nat_gateway = true
  enable_vpn_gateway = true

  tags = {
    Terraform = "true"
    Environment = "dev"
  }
}

Pretty neat, right?

You can also use the syntax highlighting shortcode, which allows overriding default values. Eg, lets add some line numbers to the same code block with linenos=table

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
module "vpc" {
  source = "terraform-aws-modules/vpc/aws"

  name = "my-vpc"
  cidr = "10.0.0.0/16"

  azs             = ["ap-southeast-2a", "ap-southeast-2b", "ap-southeast-2c"]
  private_subnets = ["10.0.1.0/24", "10.0.2.0/24", "10.0.3.0/24"]
  public_subnets  = ["10.0.101.0/24", "10.0.102.0/24", "10.0.103.0/24"]

  enable_nat_gateway = true
  enable_vpn_gateway = true

  tags = {
    Terraform = "true"
    Environment = "dev"
  }
}

In the future, I may even take this further with custom highlighting per line when detailing ideas and how-to’s.

Anyway, if you’ve made it this far - Hi!