forked from mate-academy/devops_todolist_terraform_task
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
terrafrom apply successfull / local tfstate
- Loading branch information
1 parent
5195e21
commit f2401f6
Showing
4 changed files
with
179 additions
and
0 deletions.
There are no files selected for viewing
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 @@ | ||
locals { | ||
custom_script_url = "https://${module.storage_module.strg_account.name}.blob.core.windows.net/${module.storage_module.strg_container.name}/${var.blob_name}" | ||
sensitive = true | ||
} |
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,44 @@ | ||
resource "azurerm_resource_group" "main" { | ||
name = var.rg_name | ||
location = var.region | ||
} | ||
|
||
module "network_module" { | ||
depends_on = [azurerm_resource_group.main] | ||
source = "./modules/network" | ||
net_resource_group_name = var.rg_name | ||
net_location = var.region | ||
net_vnet_name = var.vnet_name | ||
net_vnet_address_space = var.vnet_address_space | ||
net_subnet_name = var.subnet_name | ||
net_subnet_address_prefixes = var.subnet_address_prefixes | ||
net_pubip_name = var.pubip_name | ||
net_nsg_name = var.nsg_name | ||
net_pubip_dns_prefix = var.pubip_dns_prefix | ||
} | ||
|
||
module "compute_module" { | ||
depends_on = [module.network_module, module.storage_module] | ||
source = "./modules/compute" | ||
comp_resource_group_name = var.rg_name | ||
comp_location = var.region | ||
comp_nic_ip_conf_name = var.nic_ip_conf_name | ||
comp_nic_subnet_id = module.network_module.net_subnet.id | ||
comp_pubip_id = module.network_module.net_pubip.id | ||
comp_vm_name = var.vm_name | ||
comp_vm_size = var.vm_size | ||
comp_vm_user_name = var.vm_user_name | ||
comp_vm_user_password = var.vm_user_password | ||
comp_custom_script_url = local.custom_script_url | ||
comp_custom_script_filename = var.blob_name | ||
} | ||
|
||
module "storage_module" { | ||
depends_on = [azurerm_resource_group.main] | ||
source = "./modules/storage" | ||
strg_resource_group_name = var.rg_name | ||
strg_location = var.region | ||
strg_container_name = var.container_name | ||
strg_blob_name = var.blob_name | ||
strg_blob_source = var.blob_source | ||
} |
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,12 @@ | ||
terraform { | ||
required_providers { | ||
azurerm = { | ||
source = "hashicorp/azurerm" | ||
version = "3.115.0" | ||
} | ||
} | ||
} | ||
|
||
provider "azurerm" { | ||
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,119 @@ | ||
variable "region" { | ||
description = "Azure Region" | ||
default = "uksouth" | ||
validation { | ||
condition = contains( | ||
[ | ||
"eastus", "eastus2", "southcentralus", "westus2", "westus3", "australiaeast", "southeastasia", "northeurope", "swedencentral", "uksouth", "westeurope", | ||
"centralus", "southafricanorth", "centralindia", "eastasia", "japaneast", "koreacentral", "canadacentral", "francecentral", "germanywestcentral", | ||
"italynorth", "norwayeast", "polandcentral", "spaincentral", "switzerlandnorth", "mexicocentral", "uaenorth", "brazilsouth", "israelcentral", "qatarcentral", | ||
"centralusstage", "eastusstage", "eastus2stage", "northcentralusstage", "southcentralusstage", "westusstage", "westus2stage", "asia", "asiapacific", | ||
"australia", "brazil", "canada", "europe", "france", "germany", "global", "india", "israel", "italy", "japan", "korea", "newzealand", "norway", | ||
"poland", "qatar", "singapore", "southafrica", "sweden", "switzerland", "uae", "uk", "unitedstates", "unitedstateseuap", "eastasiastage", | ||
"southeastasiastage", "brazilus", "eastusstg", "northcentralus", "westus", "japanwest", "jioindiawest", "centraluseuap", "eastus2euap", | ||
"westcentralus", "southafricawest", "australiacentral", "australiacentral2", "australiasoutheast", "jioindiacentral", "koreasouth", "southindia", | ||
"westindia", "canadaeast", "francesouth", "germanynorth", "norwaywest", "switzerlandwest", "ukwest", "uaecentral", "brazilsoutheast" | ||
], var.region | ||
) | ||
error_message = ( | ||
<<EOF | ||
The region name must be one of the allowed regions. | ||
Follow the Link to see available region Names | ||
https://github.com/YegorVolkov/az_regions | ||
EOF | ||
) | ||
} | ||
} | ||
|
||
variable "rg_name" { | ||
description = "The name of the resource group" | ||
type = string | ||
default = "mate-azure-task-12" | ||
validation { | ||
condition = ( | ||
length(var.rg_name) >= 1 && | ||
length(var.rg_name) <= 90 && | ||
can(regex("^[a-zA-Z0-9-_]+$", var.rg_name)) && | ||
!can(regex("\\s", var.rg_name)) | ||
) | ||
error_message = ( | ||
<<EOF | ||
The resource group name must be between 1 and 90 characters long; | ||
can only contain alphanumeric characters, hyphens `-`, and underscores `_`; | ||
spaces are not allowed. | ||
EOF | ||
) | ||
} | ||
} | ||
|
||
/* | ||
_____________________________________________________ | ||
/ *|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|* \ | ||
Module variables below | ||
All validations for them are processed in the modules | ||
*/ | ||
|
||
variable "vnet_name" { | ||
default = "vnet" | ||
} | ||
|
||
variable "vnet_address_space" { | ||
default = ["10.0.0.0/16"] | ||
} | ||
|
||
variable "subnet_name" { | ||
default = "default" | ||
} | ||
|
||
variable "subnet_address_prefixes" { | ||
default = ["10.0.0.0/24"] | ||
} | ||
|
||
variable "pubip_name" { | ||
default = "linuxboxpip" | ||
} | ||
|
||
variable "nsg_name" { | ||
default = "defaultnsg" | ||
} | ||
|
||
variable "pubip_dns_prefix" { | ||
default = "matetask" | ||
} | ||
|
||
variable "nic_ip_conf_name" { | ||
default = "ipconfig1" | ||
} | ||
|
||
variable "vm_name" { | ||
default = "matebox" | ||
} | ||
|
||
variable "vm_size" { | ||
default = "Standard_B1s" | ||
} | ||
|
||
variable "vm_user_name" { | ||
default = "yegor" | ||
sensitive = true | ||
} | ||
|
||
variable "vm_user_password" { | ||
default = "P@sswor9.!@#" | ||
sensitive = true | ||
} | ||
|
||
variable "container_name" { | ||
default = "installer" | ||
} | ||
|
||
variable "blob_name" { | ||
default = "install-app.sh" | ||
} | ||
|
||
variable "blob_source" { | ||
default = "C:\\study\\MateStudy\\Terraform\\devops_todolist_terraform_task\\install-app.sh" | ||
} |