---
title: Using Cfhighlander to create reusable AWS CloudFormation templates
description: Learn how to create reusable CloudFormation templates for managing AWS resources in a modular way. This developer workshop covers creating a VPC, deploying bastion and ECS components, and more. | How-to tech post | Code sample
image: https://blog.base2services.com/hubfs/cfhighlander.jpg
---

[![base2Services - The Cloud Services People](https://www.base2services.com/images/base2.svg)](https://www.base2services.com/)

- [Solutions](https://www.base2services.com/services/) 
    - Get Started Here
    - [KickOff](https://www.base2services.com/products/kickoff/)
    - [Secure Compass](https://www.base2services.com/products/securecompass/)
    - [Focused AWS Review](https://www.base2services.com/consulting/services/discovery-and-review/)
    - Managed Services
    - [Cloud Management](https://www.base2services.com/cloudmanagement/)
    - [Platform Engineering](https://www.base2services.com/platform-engineering/)
    - [Compliance & Risk](https://www.base2services.com/security/)
    - Bundled Engagement
    - [DevOps as a Service](https://www.base2services.com/devops/)
    - [Prototype to Production](https://www.base2services.com/prototype-to-production/)
    - Specialist Engagements
    - [Migration](https://www.base2services.com/consulting/services/cloud-migration/)
    - [AI Factory](https://www.base2services.com/artificialintelligence/aifactory/)
    - [Generative AI](https://www.base2services.com/artificialintelligence/generativeai/)
    - [SaaS CTO](https://www.base2services.com/consulting/services/saas-cto/)
- [Industries](https://www.base2services.com/industries/) 
    - [SaaS & ISVs](https://www.base2services.com/industries/saas-and-isvs/)
    - [Financial Services](https://www.base2services.com/industries/financial-services/)
    - [Healthcare & Life Sciences](https://www.base2services.com/industries/healthcare-and-life-sciences/)
    - [Government & Enterprise](https://www.base2services.com/industries/government-and-enterprise/)
    - [Media](https://www.base2services.com/industries/media/)
    - [Education](https://www.base2services.com/industries/education/)
- [AWS Advanced Partner](https://www.base2services.com/partners/partner-pages/aws.html) 
    - [AWS DevOps Competency](https://www.base2services.com/partners/partner-pages/aws.html)
    - [AWS SaaS Competency](https://www.base2services.com/aws-saas-solutions/index.html)
    - [Enablement Tools](https://www.base2services.com/partners/)
- [Explore](https://www.base2services.com/community/) 
    - [Blog](https://blog.base2services.com)
    - [Videos](https://www.base2services.com/community/videos/)
    - Toolkit
    - [Cloud Monitoring](https://www.base2services.com/products/cloud-monitoring-aws/)
    - [Start/Stop](https://www.base2services.com/products/start-stop-aws/)
    - [Safe Test Data](https://www.base2services.com/products/safe-test-data/)
    - [App Configuration](https://www.base2services.com/products/application-config/)
    - [Secure Access](https://www.base2services.com/products/secure-access-aws/)
    - [Ask about AWS](https://www.base2services.com/products/ai-access-aws/)
    - [Resource Documenter](https://www.base2services.com/products/resource-documenter/)
- [Talk to Us](https://www.base2services.com/contact/)
- [About](https://www.base2services.com/about/) 
    - [About Us](https://www.base2services.com/about/)
    - [Why Choose Us](https://www.base2services.com/how-we-work/why-choose-us/)
    - [How We Work](https://www.base2services.com/how-we-work/)
    - [Case Studies](https://www.base2services.com/customers/)

<https://blog.base2services.com/using-cfhighlander-to-create-reusable-and-modular-aws-cloudformation-templates#mobile-nav>

- [Solutions](https://www.base2services.com/services/)
  
  ##### Get Started Here
  
    - [KickOff](https://www.base2services.com/products/kickoff/)
    - [Secure Compass](https://www.base2services.com/products/securecompass/)
    - [Focused AWS Review](https://www.base2services.com/consulting/services/discovery-and-review/)

  ##### Managed Services
  
    - [Cloud Management](https://www.base2services.com/cloudmanagement/)
    - [Platform Engineering](https://www.base2services.com/platform-engineering/)
    - [Compliance & Risk](https://www.base2services.com/security/)

  ##### Bundled Engagement
  
    - [DevOps as a Service](https://www.base2services.com/devops/)
    - [Prototype to Production](https://www.base2services.com/prototype-to-production/)

  ##### Specialist Engagements
  
    - [Migration](https://www.base2services.com/consulting/services/cloud-migration/)
    - [AI Factory](https://www.base2services.com/artificialintelligence/aifactory/)
    - [Generative AI](https://www.base2services.com/artificialintelligence/generativeai/)
    - [SaaS CTO](https://www.base2services.com/consulting/services/saas-cto/)
- [Industries](https://www.base2services.com/industries/) 
    - [SaaS & ISVs](https://www.base2services.com/industries/saas-and-isvs/)
    - [Financial Services](https://www.base2services.com/industries/financial-services/)
    - [Healthcare & Life Sciences](https://www.base2services.com/industries/healthcare-and-life-sciences/)
    - [Government & Enterprise](https://www.base2services.com/industries/government-and-enterprise/)
    - [Media](https://www.base2services.com/industries/media/)
    - [Education](https://www.base2services.com/industries/education/)
- More 
    - [AWS Advanced Partner](https://www.base2services.com/partners/partner-pages/aws.html)
    - [Explore](https://www.base2services.com/community/)
    - [About Us](https://www.base2services.com/about/)
    - [Case Studies](https://www.base2services.com/customers/)
- [AWS Advanced Partner](https://www.base2services.com/partners/partner-pages/aws.html) 
    - [AWS DevOps Competency](https://www.base2services.com/partners/partner-pages/aws.html)
    - [AWS SaaS Competency](https://www.base2services.com/aws-saas-solutions/index.html)
    - [Amazon Foundational Technical Review](https://www.base2services.com/consulting/amazon-foundational-technical-review-ftr/index.html)
    - [Other partners](https://www.base2services.com/partners/)
- [Explore](https://www.base2services.com/community/) 
    - [Blog](https://blog.base2services.com)
    - [Videos](https://www.base2services.com/community/videos/)
    - Toolkit
    - [Cloud Monitoring](https://www.base2services.com/products/cloud-monitoring-aws/)
    - [Start/Stop](https://www.base2services.com/products/start-stop-aws/)
    - [Safe Test Data](https://www.base2services.com/products/safe-test-data/)
    - [App Configuration](https://www.base2services.com/products/application-config/)
    - [Secure Access](https://www.base2services.com/products/secure-access-aws/)
    - [Ask about AWS](https://www.base2services.com/products/ai-access-aws/)
    - [Resource Documenter](https://www.base2services.com/products/resource-documenter/)
- [About](https://www.base2services.com/about/) 
    - [About Us](https://www.base2services.com/about/)
    - [Why Choose Us](https://www.base2services.com/how-we-work/why-choose-us/)
    - [How We Work](https://www.base2services.com/how-we-work/)
    - [Case Studies](https://www.base2services.com/customers/)
- <https://www.base2services.com/search.html> 
    - [Search](https://www.base2services.com/search.html)
- [Talk to Us](https://www.base2services.com/contact/)

[1300 713 559](tel:1300713559) [646 586 9485](tel:3474670942)

[← Blogs](https://blog.base2services.com/)

[AWS](https://blog.base2services.com/tag/aws) [Tech](https://blog.base2services.com/tag/tech)

# Using Cfhighlander to create reusable and modular AWS CloudFormation templates

![Angus Vine](https://blog.base2services.com/hs-fs/hubfs/MWM48599-1.jpg?width=100) Angus Vine ·  2 Minute Read

Share [in](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fblog.base2services.com%2Fusing-cfhighlander-to-create-reusable-and-modular-aws-cloudformation-templates) [X](https://twitter.com/intent/tweet?url=https%3A%2F%2Fblog.base2services.com%2Fusing-cfhighlander-to-create-reusable-and-modular-aws-cloudformation-templates&text=%3Cspan+id%3D%22hs_cos_wrapper_name%22+class%3D%22hs_cos_wrapper+hs_cos_wrapper_meta_field+hs_cos_wrapper_type_text%22+style%3D%22%22+data-hs-cos-general-type%3D%22meta_field%22+data-hs-cos-type%3D%22text%22+%3EUsing+Cfhighlander+to+create+reusable+and+modular+AWS+CloudFormation+templates%3C%2Fspan%3E) [f](https://www.facebook.com/sharer/sharer.php?u=https%3A%2F%2Fblog.base2services.com%2Fusing-cfhighlander-to-create-reusable-and-modular-aws-cloudformation-templates) [↗](mailto:?subject=%3Cspan+id%3D%22hs_cos_wrapper_name%22+class%3D%22hs_cos_wrapper+hs_cos_wrapper_meta_field+hs_cos_wrapper_type_text%22+style%3D%22%22+data-hs-cos-general-type%3D%22meta_field%22+data-hs-cos-type%3D%22text%22+%3EUsing+Cfhighlander+to+create+reusable+and+modular+AWS+CloudFormation+templates%3C%2Fspan%3E&body=https%3A%2F%2Fblog.base2services.com%2Fusing-cfhighlander-to-create-reusable-and-modular-aws-cloudformation-templates)

I recently co-hosted a developer workshop at the Melbourne AWS Programming & Tools Meetup that I wanted to share with anybody who wants to learn how to create reusable CloudFormation templates for managing AWS resources in a modular way.

The workshop focussed on how to create a VPC with both private and public subnets, and how to deploy bastion and ECS components into these subnets, using Cfhighlander, a feature rich tool & DSL for infrastructure coders that came out of the base2Services R&D lab. Additionally, the workshop covered how to deploy a single nginx service into an ECS cluster using CloudFormation.

More advanced users can also try and deploy a custom-built image to ECR, and then configure ECS service component to use it.

Try it for yourself. You can follow the workshop by visiting the GitHub link below, and completing the steps outlined on this page.

Workshop: [github.com/theonestack/cfhighlander-workshops/tree/master/ecs-nginx](https://github.com/theonestack/cfhighlander-workshops/tree/master/ecs-nginx)

### Preperation

For successfull completion of all of the steps you will need the Docker image theonestack/workshop-tools:light. If you wish to go the extra step (advanced) section below, you will need the theonestack/workshop-tools:full Dockerfile.

To pull the docker image, execute below from your shell

```
docker pull theonestack/workshop-tools:light
```

To start the docker container from the image with interactive prompt, execute below from your shell. It will mount your AWS credentials to the container

```
docker run -it -e AWS_REGION=ap-southeast-2 -e AWS_DEFAULT_REGION=ap-southeast-2 -w /src -v $PWD:/src -v $HOME/.aws:/root/.aws theonestack/workshop-tools:light bash
```

You will also need the latest cfhighlander gem. Install it using gem command:

```
gem install cfhighlandercfhighlander helpcfhighlander cfcompile
```

 

### Step 2

- Create local key and upload to AWS
- Add bastion component
- Configure bastion component with custom keypair
- Deploy, update stack, and login to bastion via SSH

 

### Step 3

- Add ECS component
- Add Loadbalanacer component
- Deploy, update stack, visit the web url

 

### Step 4

- Add Nginx as service on ECS component
- Deploy, update stack, visit the web url

 

### Extra Step

- Build custom docker image & push to ECR
- Configure ECS Service component to use custom docker images

 

### Available resources

- [Cfhighlander](https://github.com/theonestack/cfhighlander)
- [Cfhighlander Workshops](https://github.com/theonestack/cfhighlander-workshops)
- [ECS + nginx Workshop](https://github.com/theonestack/cfhighlander-workshops/tree/master/ecs-nginx)

#### Stay in the loop

### DevOps & AI insights, straight to your inbox

Our best content, services and events. Roughly every second month.

### Keep reading

#### [devops AWS · Cloud-Native Hack Day: Supabase, Vercel, and Where PaaS Fits with AWS](https://blog.base2services.com/hack-day-supabase-vercel-and-where-paas-fits-with-aws)

#### [devops SaaS · AWS · Cloud AMS Advanced Is Being Retired, Here Are Your Options Before June 2027](https://blog.base2services.com/ams-advanced-is-being-retired-here-are-your-options-before-june-2027)

#### [devops AWS · Cloud · Tech · AI Unlocking Enterprise Knowledge with Amazon Kendra and AI](https://blog.base2services.com/unlocking-enterprise-knowledge-with-amazon-kendra-and-ai)

#### [devops AWS · AI Hack Day: Teaching Our Tools to Think for Themselves](https://blog.base2services.com/hack-day-teaching-our-tools-to-think-for-themselves)

## Send an enquiry

Tell us about your environment, a project in flight or a problem you are trying to solve.

- For regulated, SaaS and product teams on AWS
- No pitch deck, a practical conversation first

Or book a time that suits you

[Book a 30-minute chat](https://info.base2services.com/meetings/m-shelton/contact-us)

[![base2Services](https://www.base2services.com/images/base2_white.svg)](https://www.base2services.com/)

<https://www.linkedin.com/company/base2services> <https://x.com/base2Services> <https://www.facebook.com/pages/base2Services/91506069748> <https://www.youtube.com/c/Base2services>

base2Services is an ISO 27001:2022 certified AWS managed services partner, running platform engineering, cloud operations, AI operations and compliance for SaaS companies, ISVs and regulated software teams since 2005.

### Get Started Here

- [KickOff](https://www.base2services.com/products/kickoff/)
- [Secure Compass](https://www.base2services.com/products/securecompass/)
- [Focused AWS Review](https://www.base2services.com/consulting/services/discovery-and-review/)

### Managed Services

- [Cloud Management](https://www.base2services.com/cloudmanagement/)
- [Platform Engineering](https://www.base2services.com/platform-engineering/)
- [Compliance & Risk](https://www.base2services.com/security/)
- [DevOps as a Service](https://www.base2services.com/devops/)

### Specialist Engagements

- [Prototype to Production](https://www.base2services.com/prototype-to-production/)
- [Migration](https://www.base2services.com/consulting/services/cloud-migration/)
- [AI Factory](https://www.base2services.com/artificialintelligence/aifactory/)
- [Generative AI](https://www.base2services.com/artificialintelligence/generativeai/)
- [SaaS CTO](https://www.base2services.com/consulting/services/saas-cto/)

### Toolkit

- [Cloud Monitoring](https://www.base2services.com/products/cloud-monitoring-aws/)
- [Start/Stop](https://www.base2services.com/products/start-stop-aws/)
- [Safe Test Data](https://www.base2services.com/products/safe-test-data/)
- [App Configuration](https://www.base2services.com/products/application-config/)
- [Secure Access](https://www.base2services.com/products/secure-access-aws/)
- [Ask about AWS](https://www.base2services.com/products/ai-access-aws/)
- [Resource Documenter](https://www.base2services.com/products/resource-documenter/)

### Company

- [About Us](https://www.base2services.com/about/)
- [Customers](https://www.base2services.com/customers/)
- [How We Work](https://www.base2services.com/how-we-work/)
- [Why Choose Us](https://www.base2services.com/how-we-work/why-choose-us/)
- [Explore](https://www.base2services.com/community/)
- [Blog](https://blog.base2services.com/)
- [Videos](https://www.base2services.com/community/videos/)

![ISO 27001 Certified](https://www.base2services.com/images/ISO-27001-certified_white.svg) [![JASANZ Certified](https://www.base2services.com/images/jasanz.svg)](https://register.jas-anz.org/certified-organisations)

 © base2Services | [Terms & Conditions](https://www.base2services.com/community/terms.html) | [Privacy](https://www.base2services.com/community/privacy.html)

```json
{
  "@context" : "https://schema.org",
  "@type" : "BlogPosting",
  "author" : {
    "@type" : "Person",
    "name" : "Angus Vine",
    "url" : "https://blog.base2services.com/author/angus-vine"
  },
  "dateModified" : "2023-09-06T13:19:53.318Z",
  "datePublished" : "2022-07-20T08:43:00.000Z",
  "headline" : "Using Cfhighlander to create reusable AWS CloudFormation templates",
  "image" : [ "https://blog.base2services.com/hubfs/cfhighlander.jpg" ],
  "mainEntityOfPage" : {
    "@id" : "https://blog.base2services.com/using-cfhighlander-to-create-reusable-and-modular-aws-cloudformation-templates",
    "@type" : "WebPage"
  },
  "publisher" : {
    "@type" : "Organization",
    "logo" : {
      "@type" : "ImageObject",
      "url" : "https://blog.base2services.com/hubfs/B2S_logo_600x400px.png"
    },
    "name" : "base2Services"
  }
}
```