Coder Social home page Coder Social logo

azureterraformtemplates's Introduction

Infrastructure as Code on Azure

Overview

Deploy a sample Tomcat Application on an Azure Virtual Machine Scale Set

Pre-requisites

Option 1 for Ubuntu management VM

  • Create a Terraform Ubuntu virtual machine with managed identities using a marketplace template here

Option 2 for CentOS management VM

  • Create a Terraform Centos virtual machine with managed identities.
    • Source code - AzureTerraformTemplates/POCtoPattern/MgmtVmMI/
    • Populate variables.tf and run terraform apply within folder

Setup Steps

  • Contributor permission helps MSI on VM to use Terraform to create resources outside the VM resource group. You can easily achieve this action by running a script once inside the Terraform Linux vm. ~/tfEnv.sh
  • The VM has a Terraform remote state back end. To enable it on your Terraform deployment, copy the remoteState.tf file from tfTemplate directory to the root of the Terraform scripts. cp ~/tfTemplate/remoteState.tf .
  • Install the Packer precompiled binary on the Terraform VM download
  • Clone the Github repository to the Terraform VM download

Recommended Reading

  • Series of Labs for Terraform on Azure here

Architecture Diagram

  • Process flow alt text

Goals of the Lab

  1. Create a customized Ubuntu managed image with Tomcat installed
  2. Store the image in a shared image gallery
  3. Create a Key Vault enabled for disk encryption and a Key
  4. Deploy a Virtual machine scale set
    • Enable service endpoint for Key Vault.
    • Update key vault access policy to allow scale set subnet.
    • Enable disk encryption extension and associate with key
  5. Access Tomcat webpage

Exercises

Custom Ubuntu Tomcat image with Packer

Start Here by reading the following document on how to build an Azure build pipeline POCtoPattern/Azure Build pipeline - Customized image in Shared Image Gallery.docx

  1. Create an Azure DevOps project

  2. Import the Packer json into Azure repot

  3. Install the hosted build agent into the Terraform linux vm

  4. Setup a build pipeline with tasks using the replace tokens module to populate environment variables into the json file.

  • Documentation is in Azure Build pipeline - Customized image in Shared Image Gallery.docx
  1. The output is a customized managed image.

  2. Note the resource group and name of the final managed image.

Create the key vault disk encryption with key

1.Login to Terraform vm with a managed identity where github repository was cloned and run the following commands.

  1. Change to the Source directory for key vault which is AzureTerraformTemplates/POCtoPattern/KeyVaultDiskEncryption/

export ARM_USE_MSI=true

Terraform init

Terraform apply -out output

Deploy a Virtual machine scale set

Create a release pipeline using the shared image gallery build artificat created in

AzureTerraformTemplates/POCtoPattern/Azure Release pipeline - Deply Scale Set using customized tomcat image in SIG.docx

Access Tomcat webpage

azureterraformtemplates's People

Contributors

preddy727 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.