For this project, you will write a Packer template and a Terraform template to deploy a customizable, scalable web server in Azure.
-
Clone this repository
-
Create your infrastructure as code
-
Update this README to reflect how someone would use your code.
- Create an Azure Account
- Install the Azure command line interface
- Install Packer
- Install Terraform
-
server.json
contains your Packer VM image configuration -
There are a couple of items you might need to modify before running it:
- Make sure to export the environment variables listed under section
variables
. For that you might want to create a.env
file and then you can export then in your current terminal session with with the following commandexport $(cat .env | xargs)
NOTE: remember not to add the `.env`` file under version control! That might reveal your secrets to 3rd parties.
- Depending on your needs you might want to change your VM image configuration under
builders
. For starters, I would suggest to continue with the default version. You might just want to update themanaged_image_resource_group_name
andmanaged_image_name
keys as you need.
NOTE:
managed_image_resource_group_name
value will need to match your resource group in yourmain.tf
file andmanaged_image_name
will need to matchpacker_image_name
fromvars.tf
(see below) - Make sure to export the environment variables listed under section
-
Build and deploy your image with the following command:
packer build server.json
.
-
main.tf
andvars.tf
contains your Terraform infrastructure configuration -
Possible adjustments to the
main.tf
file:"azurerm_resource_group
-name
must match the resource group name you gave in Packer'smanaged_image_resource_group_name
. The main part of the name is imported from thevars.tf
file fromprefix
.
-
Possible adjustments to the
vars.tf
file:prefix
- defines the beginning of the name of all resources created for this deployment. Defaults toproject-web-server
location
- defines the deployment location. Defaults toWest Europe
packer_image_name
- defines the name of the image. Defaults topacker_image_name
n_update_domains
- defines the number of update domains of the VM in the availability set. Depending on your needs, you might want to adjust this number during deployment to increase/ decrease availability. Defaults to5
admin_username
- defines the name to use as the admin account on the VMs that will be part of the VM scale set. Defaults tokonradino
admin_password
- defines the password for you VMs admin account. There is no default and Terraform will ask you to provide it during the deploymenttags
- defines a set of tags attached to created resources. Defaults toproject = "udacity-ws"
-
Create and persist your Terraform plan using the following command:
terraform plan -out solution.plan
-
Deploy your created plan using:
terraform apply "solution.plan"
.
Once your terminal is filled with green notifications saying:
+ "Builds finished"
and
+ "Apply complete! Resources ..."
it means your resources are up and running! :)