Giter Site home page Giter Site logo

terraformholsolved's Introduction

Terraform Hands-On Lab 2019

Create and deploy your first template using Terraform

Overview

This lab will guide you through the creation of 3 resources using Terraform configuration files.

The following diagram depicts the final infrastructure that you will have to deploy:

alt text

Requirements: the following tools are needed

Exercise 0 - Generate Resource Group

As an example, we have provisioned a folder with all the configuration files for creating a Resource Group: Resource group.

You can use them as a template for the following exercises.

In order to try this module, follow these steps:

  1. Login to Azure CLI

    az login
    
  2. Select the Azure Subscription where you want to deploy

    az account set -s <subscription_id>
    
  3. Verify if it has been selected

    az account show
    
  4. Itialize the Terraform configuration directory

    terraform init
    
  5. Validate the code

    terraform validate
    
  6. Create an execution plan

    terraform plan
    
  7. Create the resource group

    terraform apply
    

Once deployed, the Resource Group should have been created in your subscription.

Exercise 1 - Generate Key Vault

In this exercise, we will create the configuration files needed to generate a Key Vault.

In the repository you will find a folder named kvt . Inside it, you will find all the files that Terraform needs for deploying a resource.

alt text

The key vault should have the following attributes:

  • Disk encryption should be enabled.
  • Template deployment should be enabled.
  • (Optional) Access Policy: at least one user should have these permissions:
    • Secret: get, list, set
    • Storage: get
  • Two tags:
    • environment: should be inherited from RG.
    • channel.

Moreover, your module should have the following outputs:

  • Key Vault ID
  • Key Vault name

How can you start?

  1. Main.tf: fill the block resource bearing in mind all the requirements.
  2. Variables.tf: define all the variables. Remember that you should have already defined them in Main file.
  3. Output.tf: add all the requested outputs. Take a look at RG outputs file.
  4. versions.tf: as you are using Terraform 12, you should constrain terraform to a specific version or a range of versions.

Exercise 2 - Generate Log Analytics workspace

In this exercise, we will create the configuration files needed to generate a Log Analytics Workspace. You will need to create all the configuration files from scratch.

The Log Analytics should have the following attributes:

  • Tags: should be inherited from RG.
  • Location: inherit from RG.

Moreover, your module should have the following outputs:

  • Log Analytics ID
  • Log Analytics name

How can you start?

  1. Create the file structure.
  2. Follow same steps explained for exercise 2.

Exercise 3 (BONUS) - Create blueprint

If you have already finished the previous exercises, you are prepared to create your first blueprint, being blueprint a set of modules.

The goal of this exercise is to create a blueprint that generates a Resource Group, a Log Analytics Workspace and a Key Vault which sends its logs to the Log Analytics Workspace via diagnostic setting.

terraformholsolved's People

Contributors

ebatanero avatar elenabatanero avatar joselcaguilar avatar

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.