Skip to content

Je0pardy/cloudformazure

Repository files navigation

                                              Hello! I'm Burak. 

About me

  • 💼 Senior DevOps Engineer at Intertech
  • ❤️ I love writing automation scripts and building infrastructures
  • 💬 For contacting me Linkedin

Project Description

This project is used to create a virtual machine, install Prometheus with Grafana on Azure Cloud and monitor current temperature in Tallinn/Estonia.

Pre-requisites

Terraform installed on your system
Az Cli installed on your system

Nice to have

It's nice to have an azure storage for storing tfstate if you would like to store it first of all you should create Azure Storage Account Azure Storage If you don't want to use azure storage you can delete or comment out backend tf.

  • An accessible Azure bucket to store Terraform state (specified in backend.tf).

Variables

  • A Terraform variables file customized for assessment environment, for example:

    • resource_group_name = "my_terraform_rg"
    • resource_group_location = "West Europe"
    • virtual_network_name = "vnetprod019"
    • subnet_name = "subnet019"
    • public_ip_name = "publicip019"
    • network_security_group_name = "nsgprod019"
    • network_interface_name = "nicprod019"
    • linux_virtual_machine_name = "linuxvm019"

Secrets

Secrets are stored in github Repositry secrets used in workflow yaml files.

 - TF_ARM_CLIENT_ID  //Azure Client ID
 - TF_ARM_CLIENT_SECRET  //Azure Clint Secret
 - TF_ARM_SUBSCRIPTION_ID  //Azure Subscription ID  
 - TF_ARM_TENANT_ID  //Azure Tenant ID
 - AUTH_PASSWORD  //Prometheus Password
 - VM_IP  //Virtual Machine IP
 - VM_KEY  //Virtual Machine private key
 - VM_USER //Virtual Machine user

Building the Terraform-based infrastructure

First off all you need login azure portal via azure cli
"az login" initialize terraform Azure modules
"terraform init"
plan and save the infra changes into tfplan file
"terraform plan -out tfplan"
apply the plan
"terraform apply tfplan"
delete the infra
"terraform destroy"

If you would like top deploy Weather Application you should trigger Deploy Weather Project or do this steps manually after getting VM IP and Private key
Deploy Weather Project You can get these variables from outputs.tf with command "terraform output vm_ip" "terraform output tls_private_key"

Acces Temperature in Grafana

You need to get Public IP of VM, which is desribed above.

From web browser VM IP:3000 login Grafana with default password (admin:admin) you can change the password after login. There is a predefined Dashboard called as Weather in Estonia(Tallinn) (weatherestonia.json) Weather is currently based

Github Actions

For automate the flow, github actions is used. There are four workflows for terraform plan and apply.
Terraform Plan runs when a PR created to master branch
Terraform Apply runs when a PR merged to master or a commit pushed.
Terraform Destroy Destroys whole infrastructure with manual trigger
Deploy Weather Project Deploys python code and copies custom dashboard to grafana with manual trigger

Resources

Name Type
Terraform Registry resource
terraform templates resource
weather api resource
prometheus and grana docker-compose repo resource