For this project, we will use a Packer template and a Terraform template to deploy a customizable, scalable web server in Azure.
The original starter template of this project lives at this repository
-
Clone or make a fresh copy of this repository, so you can tweak'n'squeeze it.
-
Follow the instructions
-
Enjoy your new magical abilities
- Create an Azure Account
- Install the Azure command line interface
- Install Packer
- Install Terraform
az login
- delete
terraform.tfstate
,solution.plan
,.terraform.lock.hcl
artifacts from previous builds
Check-out the policy.rules.json
file
az policy definition create --name "TaggingPolicyDef" --description "Deny all not idexed resources" --display-name "Deny if not taggd" --mode "Indexed" --rules ./policy.rules.json
az policy assignment create --name "TaggingPolicy" --policy "TaggingPolicyDef" --display-name "Assignment of policy Deny if not tagged" --description "Assignment of denying non tagged indexed resources"
az policy assignment list
In order to support application deployment, we'll need to create an image that different organizations can take advantage of to deploy their own apps! To do this, we'll create a packer image that anyone can use, and we'll leverage in our own Terraform template.
Things we need to do here are:
- use the template provided
- use Ubuntu 18.04-LTS as a base image
- modify the provisioners according the requirements
- ensure the resource group names in Packer and Terraform are the same
- assign the proper values to environment variables
Make sure that you place the right values at the: packer.vars.json
packer build -var-file=packer.vars.json server.json
- verify the newly created image by running:
az image list
Check-out the vars.tf
file!
There you may need to fill-out with the right values:
- prefix
- client ID
- client secret
- subscription ID
- tenant ID
- username ( for the VMs)
- password ( for the VMs)
- VM's number
- location
terraform init
terraform plan -out solution.plan
terraform apply solution.plan
The main important thing after deploying is destroying. Make sure that all your unused resources are destroyed before going to sleep.
terraform destroy
Please check docs/output-n-screenshots
folder, where you can find example console outputs
received after executing the various commands.