Skip to content

caolucl/hello-world

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

53 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Azure Infrastructure Operations Project: Deploying a scalable IaaS web server in Azure

Introduction

For this project, you will write a Packer template and a Terraform template to deploy a customizable, scalable web server in Azure.

Getting Started

  1. Clone this repository

  2. Create your infrastructure as code

  3. Update this README to reflect how someone would use your code.

Dependencies

  1. Create an Azure Account
  2. Install the Azure command line interface
  3. Install Packer
  4. Install Terraform

Instructions

Create image by packer

  • Create a resource group (if not existed) in which the image will be deployed by azure cli:
IMAGE_LOCATION="East US"
RESOURCE_GROUP="packer-rg"
az group create --location "$IMAGE_LOCATION" \
                --name "$RESOURCE_GROUP" \
                --tags 'environment=dev'
  • Create a service prinpal by running the following commands from azure cli:
let "randomIdentifier=$RANDOM*$RANDOM"  
servicePrincipalName="msdocs-sp-$randomIdentifier"
roleName="Contributor"
subscriptionID=$(az account show --query id -o tsv)
# Verify the ID of the active subscription
echo "Using subscription ID $subscriptionID"
RESOURCE_GROUP="packer-rg"

echo "Creating SP for RBAC with name $servicePrincipalName, with role $roleName and in scopes /subscriptions/$subscriptionID/resourceGroups/$RESOURCE_GROUP"
az ad sp create-for-rbac --name $servicePrincipalName --role $roleName --scopes /subscriptions/$subscriptionID/resourceGroups/$RESOURCE_GROUP 
  • Capture the output from the above commands
{
  "appId": "***",
  "displayName": "msdocs-sp-110966904",
  "password": "PasswordOfTheApp",
  "tenant": "tenantID"
}
  • Change variables in the file server.json

    • Change client_id variable with appId value
    • Change client_secret variable with password value
    • Change subscription_id variable with yout subscritopn id
  • Running the following command to create image:

packer build server.json

Using terraform to deploy infrastructure

  • Change variables in file vars.tf as needed
  • Replace your public key by change the content of file id_rsa.pub
  • Running the following commands to deploy infrastructure
terraform plan -out solution.plan
terraform apply solution.plan

Output

Outputs from Terraform

  • The output after running terraform apply
Outputs:

public_ip_address = [
    "20.232.162.79",
]
vmss_public_ip_fqdn = "cdtkpp.eastus.cloudapp.azure.com"
  • Running the following command to see the whole output of the deployment
terraform show

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages

  • Java 67.3%
  • Dockerfile 32.7%