For this project, Packer is used to build an image and Terraform is used to deploy infrastructure as code on 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
- Log in your Azure account
az login
- Deploy azure policy
- Create a policy definition
az policy definition create --name tagging-policy --rules azurepolicy.rules.json --params azurePolicy.parm.json
- Create a policy assignment
az policy assignment create --name tagging-policy --policy tagging-policy --params "{ \"tagName\":
{ \"value\": \"YourTag\" } }"
- Check whether your policy assignment is successful
az policy assignment list
- Run Packer
packer build
- Customize You can customize several things in variables.tf Customize default and description as you like.
variable "prefix"
{
description = "The prefix which should be used for all resources in this example"
type = string
default = "WebAzureProject-Terraform"
}
- Run Terraform
terraform init
terraform apply "solution"
Please check the following docs:
- Sample Successful Azure Policy assignment is azPolicyOutput1.jpg and azPolicyOutput2.jpg
- Sample successful terraform apply is terraform apply output