Skip to content

Instantly share code, notes, and snippets.

View guillermo-musumeci's full-sized avatar

Guillermo Musumeci guillermo-musumeci

View GitHub Profile
@guillermo-musumeci
guillermo-musumeci / terraform-validation.tf
Created October 6, 2022 21:08
Variable Validation in Terraform
variable "storage_account_name" {
type = string
description = "Azure Storage Account Name (3 to 24 characters, lowercase letters and numbers only)"
validation {
condition = length(var.storage_account_name) >= 3 && length(var.storage_account_name) <= 24
error_message = "The storage_account_name variable name must be 3-24 characters in length"
}
validation {
@guillermo-musumeci
guillermo-musumeci / terraform-validation.tf
Last active October 6, 2022 21:00
Variable Validation in Terraform
variable "server_name" {
type = string
description = "Server name in letters and numbers only)"
validation {
condition = can(regex("^[0-9A-Za-z]+$", var.storage_account_name))
error_message = "The server name variable must have letters and numbers only"
}
}
@guillermo-musumeci
guillermo-musumeci / terraform-validation.tf
Created October 6, 2022 20:53
Variable Validation in Terraform
variable "app_name" {
type = string
description = "Application name in lower case"
validation {
condition = lower(var.app_name) == var.app_name
error_message = "Application name value must be in all lower case"
}
}
@guillermo-musumeci
guillermo-musumeci / terraform-validation.tf
Last active October 6, 2022 20:52
Variable Validation in Terraform
variable "app_name" {
type = string
description = "Application name in upper case"
validation {
condition = upper(var.app_name) == var.app_name
error_message = "Application name value must be in all upper case"
}
}
@guillermo-musumeci
guillermo-musumeci / terraform-validation.tf
Created October 6, 2022 17:43
Variable Validation in Terraform
variable "ip_address" {
type = string
description = "Web Server IP address"
validation {
condition = can(regex("^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$",var.ip_address))
error_message = "Invalid Web Server IP address provided"
}
}
@guillermo-musumeci
guillermo-musumeci / terraform-validation.tf
Last active October 6, 2022 17:42
Variable Validation in Terraform
variable "company_shortname" {
description = "The company name"
type = string
validation {
condition = (length(var.company_shortname) > 3)
error_message = "The company must be over 3 characters in length"
}
}
@guillermo-musumeci
guillermo-musumeci / terraform-validation.tf
Created October 6, 2022 10:22
Variable Validation in Terraform
variable "vm_size" {
type = string
description = "VM instance size"
validation {
condition = contains(["Standard_DS3_v2", "Standard_D2s_v4", "Standard_D4s_v4", "Standard_D8s_v4"], var.vm_size)
error_message = "Invalid VM instance size provided"
}
}
@guillermo-musumeci
guillermo-musumeci / terraform-validation.tf
Created October 6, 2022 09:57
Variable Validation in Terraform
## Service Plan Variable
variable "service_plan_sku_name" {
type = string
description = "The SKU for the plan. Possible values include EP1, EP2 and EP3."
validation {
condition = contains(["EP1", "EP2", "EP3"], var.service_plan_sku_name)
error_message = "Valid values for the service_plan_sku_name variable are EP1, EP2, EP3"
}
}
# Update following variables to your environment
$TempLocation = "C:\Temp"
$SQLServiceAccount = "sql-packer-vm\SVC_SQLPACKERVM_SQL" #Account used for the SQL Service
$SQLInstance = "MSSQLSERVER"
# Check if temp location exists and create if it doesn't
IF ((Test-Path $TempLocation) -eq $false)
{
New-Item -ItemType Directory -Force -Path $TempLocation
Write-Host "Folder $TempLocation created"
# SQL Server Ports Firewall Rules
New-NetFirewallRule -DisplayName "SQL Server" -Direction Inbound –Protocol TCP –LocalPort 1433 -Action allow
New-NetFirewallRule -DisplayName "SQL Admin Connection" -Direction Inbound –Protocol TCP –LocalPort 1434 -Action allow
New-NetFirewallRule -DisplayName "SQL Server Browser" -Direction Inbound –Protocol UDP –LocalPort 1434 -Action allow
New-NetFirewallRule -DisplayName "SQL Service Broker" -Direction Inbound –Protocol TCP –LocalPort 4022 -Action allow
New-NetFirewallRule -DisplayName "Transact-SQL Debugger / RPC" -Direction Inbound –Protocol TCP –LocalPort 135 -Action allow
# SQL Analysis Ports Firewall Rules
New-NetFirewallRule -DisplayName "SQL Analysis Service" -Direction Inbound –Protocol TCP –LocalPort 2383 -Action allow
New-NetFirewallRule -DisplayName "SQL Analysis Browser" -Direction Inbound –Protocol TCP –LocalPort 2382 -Action allow