Skip to content

Commit

Permalink
Merge pull request #10 from Pamir/master
Browse files Browse the repository at this point in the history
modules sample added
  • Loading branch information
Pamir authored Apr 12, 2020
2 parents 972517f + 848122f commit 26eaba9
Show file tree
Hide file tree
Showing 22 changed files with 130 additions and 0 deletions.
Binary file modified .DS_Store
Binary file not shown.
File renamed without changes.
File renamed without changes.
28 changes: 28 additions & 0 deletions 04-variables/05-operators/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/*
variable "customer" {
type = map(object({
name = string
id = number,
is_active = bool,
}))
}
*/


locals {
three = 1 + 2
logical = 2 < 3
time = timestamp()
}

output "sum_result" {
value = local.three
}

output "logical_result" {
value = local.logical
}

output "apply_date" {
value = formatdate("YYYYMMDD",local.time)
}
3 changes: 3 additions & 0 deletions 04-variables/05-operators/providers.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
provider "random" {
version = "=2.2.1"
}
22 changes: 22 additions & 0 deletions 04-variables/06-loops/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
variable "locations" {
type = list
default = [
"westeurope",
"westus",
"eastus",
"easteurope"
]
}

locals {
numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9]
evens = [for i in local.numbers : (i + 10) if i % 2 == 0]

}
output "upper_locations" {
value = [for l in var.locations : upper(l)]
}

output "even_numbers" {
value = local.evens
}
4 changes: 4 additions & 0 deletions 04-variables/06-loops/providers.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
provider "random" {
version = "=2.2.1"
}

Empty file.
55 changes: 55 additions & 0 deletions 08-modules/01-module-usage/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/*
terraform apply \
-var-file='secret.tfvars' \
-var-file='production.tfvars'
*/

resource "azurerm_resource_group" "example" {
name = "example-resources"
location = "West Europe"
}

module "linuxservers" {
source = "Azure/compute/azurerm"
resource_group_name = azurerm_resource_group.example.name
vm_os_simple = "UbuntuServer"
public_ip_dns = ["linsimplevmips"] // change to a unique name per datacenter region
vnet_subnet_id = module.network.vnet_subnets[0]
}

module "windowsservers" {
source = "Azure/compute/azurerm"
resource_group_name = azurerm_resource_group.example.name
is_windows_image = true
vm_hostname = "mywinvm" // line can be removed if only one VM module per resource group
admin_password = "ComplxP@ssw0rd!"
vm_os_simple = "WindowsServer"
public_ip_dns = ["winsimplevmips"] // change to a unique name per datacenter region
vnet_subnet_id = module.network.vnet_subnets[1]
}

module "network" {
source = "Azure/network/azurerm"
version = "3.0.0"
resource_group_name = azurerm_resource_group.example.name
subnet_prefixes = ["10.0.1.0/24", "10.0.2.0/24"]
subnet_names = ["subnet1", "subnet2"]
}

#todo: version will be added
#Search for warnings in tf apply
module "aks" {
source = "Azure/aks/azurerm"
resource_group_name = azurerm_resource_group.example.name
client_id = var.client_id
client_secret = var.client_secret
prefix = "az"
}

output "linux_vm_public_name" {
value = module.linuxservers.public_ip_dns_name
}

output "windows_vm_public_name" {
value = module.windowsservers.public_ip_dns_name
}
9 changes: 9 additions & 0 deletions 08-modules/01-module-usage/providers.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#export TF_CLI_CONFIG_FILE=$PWD/terraform.rc
#export TF_LOG=TRACE
#export TF_LOG_PATH=./terraform.log

provider "azurerm" {
# whilst the `version` attribute is optional, we recommend pinning to a given version of the Provider
version = "=2.0.0"
features {}
}
3 changes: 3 additions & 0 deletions 08-modules/01-module-usage/terraform.tfvars
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#az ad sp create-for-rbac -n "terraform-aks"
client_id = "xxxx"
client_secret = "xxxx"
6 changes: 6 additions & 0 deletions 08-modules/01-module-usage/variables.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
variable "client_id" {
type = string
}
variable "client_secret" {
type = string
}
Empty file.
Empty file.
Empty file added 09-workspace/Readme.md
Empty file.
Empty file added 10-backends/Readme.md
Empty file.
Empty file.
Empty file added 12-opa-integration/Readme.md
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.

0 comments on commit 26eaba9

Please sign in to comment.