# terraform.azure.automation Terraform repository to perform automatic tasks in Azure cloud. ## Requirements First you must have *terraform* installed on host who run your automatism. To install *terraform*, you should have **wget** and **unzip**. ```bash sudo apt install wget unzip ``` ```bash wget -O terraform_0.12.20_linux_amd64.zip https://releases.hashicorp.com/terraform/0.12.20/terraform_0.12.20_linux_amd64.zip \ && wget -O terraform_0.12.20_SHA256SUMS https://releases.hashicorp.com/terraform/0.12.20/terraform_0.12.20_SHA256SUMS \ && sha256sum --ignore-missing -c terraform_0.12.20_SHA256SUMS \ && unzip -qn terraform_0.12.20_linux_amd64.zip \ && mv terraform ${PATH%%:*}/ \ && rm terraform_0.12.20_linux_amd64.zip terraform_0.12.20_SHA256SUMS ``` To run terraform against Azure cloud, you should have Azure variable (credentials and location) set in environment ``` $ export ARM_CLIENT_ID="00000000-0000-0000-0000-000000000000" $ export ARM_CLIENT_CERTIFICATE_PATH="/path/to/my/client/certificate.pfx" $ export ARM_CLIENT_CERTIFICATE_PASSWORD="Pa55w0rd123" $ export ARM_SUBSCRIPTION_ID="00000000-0000-0000-0000-000000000000" $ export ARM_TENANT_ID="00000000-0000-0000-0000-000000000000" ``` ## Run To run terraform, we'll use wrapper script run.sh To run default infrastructure playbook *infra.tf* who create all the infra ``` ./run.sh -v ``` To only play another state file *state.tf* ``` TERRAFORM_FILE=state.tf ./run.sh -v ``` ## Docker We'll have a Dockerfile in order to generate a docker image to use it for running play in an controled environment. - Build image: ```docker build -t devops-docker .``` - Run terraform using this image: ``` docker run -e "TERRAFORM_FILE=state.tf" --entrypoint "./run.sh" devops-docker -v ```