Skip to content

Instantly share code, notes, and snippets.

@heoelri
heoelri / deploy-ipv6-lb.sh
Created April 8, 2020 13:27
Azure VM with 3 NICs in different Subnets with a Frontend Loadbalancer and IPv6 enabled
#!/bin/bash
GROUPNAME=cet-testing # Azure Resource Group
LOCATION=westeurope # Azure Location
LBFRONTEND=cet-testing-lb # Load Balancer Resource Name
VNETNAME=cet-testing-vnet # Virtual Network Name
# Create a Azure Resource Group
GROUP=`az group create --name $GROUPNAME --location $LOCATION --query name -o tsv`
@heoelri
heoelri / iac-with-azurestack-and-terraform.tf
Created April 21, 2020 13:38
Sample Configuration deploying a VM on Azure Stack Hub with Terraform
# Configure the Azure Stack Provider
# https://www.terraform.io/docs/providers/azurestack/index.html
provider "azurestack" {
# NOTE: we recommend pinning the version of the Provider which should be used in the Provider block
# https://github.com/terraform-providers/terraform-provider-azurestack/releases
version = "=0.9.0"
# Connection Details (can be provided via variables)
arm_endpoint = "" # https://management.local.azurestack.external (for ASDK)
client_id = ""
/opt/hostedtoolcache/terraform/0.12.24/x64/terraform init -backend-config=storage_account_name=terraform -backend-config=container_name=terraform-state -backend-config=key=seattle.tfstate -backend-config=resource_group_name=terraform -backend-config=arm_subscription_id=49de790a-c9d6-4a10-a2a1-1d5fcff06c86 -backend-config=arm_tenant_id=*** -backend-config=arm_client_id=*** -backend-config=arm_client_secret=***
2020/05/06 10:17:30 [INFO] Terraform version: 0.12.24  
2020/05/06 10:17:30 [INFO] Go runtime version: go1.12.13
2020/05/06 10:17:30 [INFO] CLI args: []string{"/opt/hostedtoolcache/terraform/0.12.24/x64/terraform", "init", "-backend-config=storage_account_name=terraform", "-backend-config=container_name=terraform-state", "-backend-config=key=seattle.tfstate", "-backend-config=resource_group_name=terraform", "-backend-config=arm_subscription_id=49de790a-c9d6-4a10-a2a1-1d5fcff06c86", "-backend-config=arm_tenant_id=***", "-backend-config=arm_client_id=***", "-backend-config=arm_client_secret=***"
@heoelri
heoelri / locust-master-terraform.tf
Last active July 6, 2021 14:09
locust-master-terraform
resource "azurerm_container_group" "master" {
count = var.locustWorkerNodes >= 1 ? 1 : 0
name = "${random_pet.deployment.id}-locust-master"
location = azurerm_resource_group.deployment.location
resource_group_name = azurerm_resource_group.deployment.name
ip_address_type = "Public"
dns_name_label = "${random_pet.deployment.id}-locust-master"
os_type = "Linux"
container {
@heoelri
heoelri / locust-worker-terraform.tf
Last active March 30, 2021 07:10
locust-worker-terraform
resource "azurerm_container_group" "worker" {
count = var.locustWorkerNodes
name = "${random_pet.deployment.id}-locust-worker-${count.index}"
location = var.locustWorkerLocations[count.index % length(var.locustWorkerLocations)]
resource_group_name = azurerm_resource_group.deployment.name
ip_address_type = "Public"
os_type = "Linux"
container {
name = "${random_pet.deployment.id}-worker-${count.index}"
@heoelri
heoelri / locust-variables-terraform.tf
Last active March 30, 2021 07:10
locust-variables-terraform
variable "location" {
description = "The Azure Region in which the master and the shared storage account will be provisioned."
type = string
default = "northeurope"
}
variable "environment" {
description = "Environment Resource Tag"
type = string
default = "dev"
@heoelri
heoelri / azure-vmss-with-cloud-init.tf
Last active May 29, 2021 17:58
Azure VMSS deployed via Terraform with cloud init
resource "azurerm_linux_virtual_machine_scale_set" "deployment" {
name = "buildagent-vmss"
resource_group_name = azurerm_resource_group.deployment.name
location = azurerm_resource_group.deployment.location
sku = "Standard_F8s_v2"
instances = var.numberOfWorkerNodes # number of instances
overprovision = false
single_placement_group = false
@heoelri
heoelri / azure-vmss-cloud-init.conf
Last active May 6, 2021 08:00
Cloud Init for Azure VMSS
#cloud-config
apt:
preserve_sources_list: true
sources:
hashicorp.list:
source: "deb https://apt.releases.hashicorp.com focal main"
key: |
-----BEGIN PGP PUBLIC KEY BLOCK-----
mQINBF60TuYBEADLS1MP7XrMlRkn1Y54cb2UclUMH8HkIRfBrhk5Leo9kNZc/2QD
@heoelri
heoelri / simple-aks-with-az.sh
Last active October 6, 2021 07:10
This is a simple az example to deploy a resource group, virtual network, subnet and aks cluster.
prefix=tf71761
location=eastus2
# Create/Update an Azure Resource Group
resourceGroup=`az group create --name $prefix --location $location --query name -o tsv`
# Create/Update an Azure Virtual Network
virtualNetwork=`az network vnet create --name "$prefix-vnet" --resource-group $resourceGroup --address-prefixes 10.10.0.0/16 --query newVNet.name -o tsv`
# Create/Update an Azure Virtual Network Subnet
@heoelri
heoelri / locust_locals.tf
Last active January 4, 2022 12:08
Locust locals.tf file with definitions for headless and standalone
# see https://docs.locust.io/en/stable/configuration.html for details on individual Locust configuration options
environment_variables_common = {
"LOCUST_LOCUSTFILE" = "/home/locust/locust/${azurerm_storage_share_file.locustfile.name}"
}
# values which are needed when the Locust master schedules a load test
environment_variables_master = {
"LOCUST_HOST" = var.targeturl,
"LOCUST_MODE_MASTER" = "true"
"LOCUST_LOGFILE" = "/home/locust/locust/logs/${local.prefix}.log"