-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #10 from Pamir/master
modules sample added
- Loading branch information
Showing
22 changed files
with
130 additions
and
0 deletions.
There are no files selected for viewing
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
provider "random" { | ||
version = "=2.2.1" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
provider "random" { | ||
version = "=2.2.1" | ||
} | ||
|
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.