Giter VIP home page Giter VIP logo

tf-maps-lookups's Introduction

Use of Terraform map variables and dynamic lookup into them

The purpose of this repo is to show how to use variables of type map and how to dynamically reference them with lookup to build separate Dev and Prod Docker environments using Terraform Workspaces and modules

Prerequisites

  • Vagrant
  • Git
  • VirtualBox

Get the repo and run lab

git clone https://github.com/achuchulev/tf-maps-lookups.git
cd tf-maps-lookups
vagrant up

Vagrant up will run scripts/provision.sh that will install:

  • Docker
  • Terraform

How to build

ssh to vagrant box and go to repo folder

vagrant ssh
sudo su -
cd /vagrant

Initialize terraform

terraform init

Create new Terraform workspaces for Dev and Prod

terraform workspace new dev
terraform workspace new prod

Build

Dev

terraform workspace select dev
terraform apply

typing dev when asked, to specify which environment you are going to deploy

Prod

terraform workspace select prod
terraform apply

typing prod when asked, to specify which environment you are going to deploy

How to test

Open the links below in new browser tab to test:

Dev

Prod

How to destroy

Dev

terraform workspace select dev
terraform destroy

typing dev when asked, to specify which environment you are going to destroy

Prod

terraform workspace select prod
terraform destroy

typing prod when asked, to specify which environment you are going to destroy

Lab

Leave vagrant box ssh, and run

cd tf-maps-lookups
vagrant destroy

confirming yes once prompted

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.