Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#30 Adding App Terraform Deployment #39

Merged
merged 23 commits into from
Mar 27, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
60171cc
Initialize branch and Add Keyvault to Gobal Resources
manojvazirani Mar 18, 2019
93454af
adding azure-pipelines yaml
code4clouds Mar 18, 2019
2b2a11b
Add Container Registry to Gobal Resources using Terraform
manojvazirani Mar 18, 2019
0e1558d
Add provider for Azure in Terraform
manojvazirani Mar 18, 2019
0114198
Added .terraform and .vscode file to the .ignore
code4clouds Mar 18, 2019
24908af
Adding additional Terraforms file to the .gitignore
code4clouds Mar 18, 2019
bf7f0c6
Update description for ACR variabes
manojvazirani Mar 18, 2019
b0af8fd
Merge branch 'tfglobal' of github.com:Microsoft/entref-appservice-con…
manojvazirani Mar 18, 2019
d7c44c3
Add keyvault policy and user permissions to access keyvault
manojvazirani Mar 19, 2019
f311175
Update folder name and test usage with environment variables
manojvazirani Mar 19, 2019
f8073ab
WIP: Terraform and shell draft code.
code4clouds Mar 20, 2019
43055b1
Update deploy script with presumption of existing service principal
manojvazirani Mar 21, 2019
8f33d5a
Adding cluster md
code4clouds Mar 22, 2019
47fbc1a
#30 Adding TF for local app developer
code4clouds Mar 22, 2019
41333f6
#30 Adding AutoApprove
code4clouds Mar 22, 2019
a79abab
added link to the readme inside /app
code4clouds Mar 22, 2019
56f8fe5
PR updates
code4clouds Mar 25, 2019
f933fb7
added new naming conventions
code4clouds Mar 25, 2019
830561c
Adding permissions to deploy.sh
code4clouds Mar 25, 2019
ee151da
Removed the ./README.md
code4clouds Mar 25, 2019
9c9c7d8
Update to Readme.md
code4clouds Mar 25, 2019
39918c4
removed deploy.sh on ./shared
code4clouds Mar 25, 2019
22adc02
Added .env loading command and tf vars sample
code4clouds Mar 26, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -328,3 +328,15 @@ ASALocalRun/

# MFractors (Xamarin productivity tool) working folder
.mfractor/

# VSCode Files
.vscode/

# Terraform Files
**/.terraform/
**/terraform.tfstate.*
**/terraform.tfstate
**/.terraform.tfstate.lock.info

# ENV files
**/.env
14 changes: 0 additions & 14 deletions README.md

This file was deleted.

70 changes: 70 additions & 0 deletions shared/README.md
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"
}

```
11 changes: 11 additions & 0 deletions shared/azure/provider/main.tf
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"
}
47 changes: 47 additions & 0 deletions shared/main.tf
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}"
}
17 changes: 17 additions & 0 deletions shared/variables.tf
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"
}