-
Notifications
You must be signed in to change notification settings - Fork 79
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'feature/WIP_terraform_app'
- Loading branch information
Showing
6 changed files
with
273 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
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
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,70 @@ | ||
# Infrastructure deployment | ||
|
||
## Requirements | ||
|
||
- Azure Subscription User (with deployment rights) | ||
- [Terraform](https://www.terraform.io/downloads.html) | ||
|
||
## Resources | ||
|
||
The following respources will be deployed | ||
- Azure Resource Group | ||
|
||
## Deployment | ||
|
||
1. Authenticate using your Azure Principal or an Azure account with privileges to deploy resource groups. | ||
|
||
``` bash | ||
$ az login | ||
``` | ||
|
||
2. Execute the following commands: | ||
|
||
``` bash | ||
$ cd ./shared | ||
$ terraform init | ||
$ terraform apply | ||
``` | ||
|
||
## Environmental Variables | ||
|
||
To stop the command line from prompting questions use a .env file with the following environmental variables: | ||
|
||
``` | ||
export TF_VAR_app_name=cblt | ||
export TF_VAR_org=cse | ||
export TF_VAR_env=dev | ||
export TF_VAR_location=eastus | ||
``` | ||
|
||
After saving the file set environment using: | ||
|
||
``` bash | ||
. .env | ||
``` | ||
|
||
Alternative use the variable.tf files in the directories and add the default key on the file as shown on the example below: | ||
|
||
``` json | ||
variable "location" { | ||
type = "string" | ||
description = "The name of the target location" | ||
default = "eastus" | ||
} | ||
variable "env" { | ||
type = "string", | ||
description = "The short name of the target env (i.e. dev, staging, or prod)" | ||
defailt = "dev" | ||
} | ||
variable "org" { | ||
type = "string", | ||
description = "The short name of the organization" | ||
default = "cse" | ||
} | ||
variable "app_name" { | ||
type = "string", | ||
description = "The short name of the application" | ||
default = "cblt" | ||
} | ||
|
||
``` |
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,11 @@ | ||
provider "azurerm" { | ||
version = "~>1.21.0" | ||
} | ||
|
||
provider "null" { | ||
version = "~>2.0.0" | ||
} | ||
|
||
terraform { | ||
required_version = "~> 0.11.11" | ||
} |
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,47 @@ | ||
module "azure-provider" { | ||
source = "./azure/provider" | ||
} | ||
|
||
locals { | ||
location_suffixes = { | ||
eastasia = "asea", | ||
southeastasia = "assw", | ||
centralus = "usce", | ||
eastus = "usea", | ||
eastus2 = "use2", | ||
westus = "uswe", | ||
westus2 = "usw2", | ||
northcentralus = "usnc", | ||
southcentralus = "ussc", | ||
westcentralus = "uswc", | ||
northeurope = "euno", | ||
westeurope = "euwe", | ||
japanwest = "jawe", | ||
japaneast = "jaea", | ||
brazilsouth = "brso", | ||
australiaeast = "auea", | ||
australiasoutheast = "ause", | ||
southindia = "inso", | ||
centralindia = "ince", | ||
westindia = "inwe", | ||
canadacentral = "cace", | ||
canadaeast = "caea", | ||
uksouth = "ukso", | ||
ukwest = "ukwe", | ||
koreacentral = "koce", | ||
koreasouth = "koso", | ||
francecentral = "frce", | ||
francesouth = "frso", | ||
australiacentral = "auce", | ||
australiacentral2 = "auc2", | ||
southafricanorth= "sano", | ||
southafricawest = "sawe", | ||
} | ||
location_suffix = "${local.location_suffixes[var.location]}" | ||
suffix = "${var.app_name}-${var.env}-${local.location_suffix}-${var.org}" | ||
} | ||
|
||
resource "azurerm_resource_group" "rg_core" { | ||
name = "rg-${local.suffix}" | ||
location = "${var.location}" | ||
} |
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,17 @@ | ||
variable "location" { | ||
type = "string" | ||
description = "The name of the target location" | ||
} | ||
variable "env" { | ||
type = "string", | ||
description = "The short name of the target env (i.e. dev, staging, or prod)" | ||
} | ||
variable "org" { | ||
type = "string", | ||
description = "The short name of the organization" | ||
} | ||
variable "app_name" { | ||
type = "string", | ||
description = "The short name of the application" | ||
} | ||
|