-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: Added container only deployments
- Loading branch information
1 parent
af0bd2c
commit 4376bd0
Showing
10 changed files
with
304 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,29 @@ | ||
module "ctx" { | ||
source = "../../../global/context" | ||
environment = var.environment | ||
} | ||
|
||
data "azurerm_container_app_environment" "aca_env" { | ||
name = module.ctx.labels.core.resourceNames["azurerm_container_app_environment"] | ||
resource_group_name = module.ctx.resource_group_name | ||
} | ||
|
||
data "azurerm_postgresql_flexible_server" "ops_dbs" { | ||
name = module.ctx.labels.db.resourceNames["azurerm_postgresql_flexible_server"] | ||
resource_group_name = module.ctx.resource_group_name | ||
} | ||
|
||
data "azurerm_key_vault" "vault" { | ||
name = module.ctx.labels.core.resourceNames["azurerm_key_vault"] | ||
resource_group_name = module.ctx.resource_group_name | ||
} | ||
|
||
data "azurerm_key_vault_secret" "ops-pw" { | ||
name = "ops-role-password" | ||
key_vault_id = data.azurerm_key_vault.vault.id | ||
} | ||
|
||
data "azurerm_key_vault_secret" "ops-jwt-private-key" { | ||
name = "ops-jwt-private-key" | ||
key_vault_id = data.azurerm_key_vault.vault.id | ||
} |
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,77 @@ | ||
|
||
|
||
resource "azurerm_container_app" "backend" { | ||
name = module.ctx.labels.be.resourceNames["azurerm_container_app"] | ||
container_app_environment_id = data.azurerm_container_app_environment.aca_env.id | ||
resource_group_name = module.ctx.resource_group_name | ||
revision_mode = "Multiple" | ||
|
||
template { | ||
revision_suffix = substr(var.container_tag, 0, 8) | ||
min_replicas = 1 | ||
container { | ||
name = var.container_name | ||
image = "${var.container_image}:${var.container_tag}" | ||
cpu = var.cpu | ||
memory = var.memory | ||
env { | ||
name = "OPS_CONFIG" | ||
value = "environment/azure/dev.py" | ||
} | ||
env { | ||
name = "PGUSER" | ||
value = "ops" | ||
} | ||
env { | ||
name = "PGPASSWORD" | ||
secret_name = "pgpassword" | ||
} | ||
env { | ||
name = "PGHOST" | ||
value = data.azurerm_postgresql_flexible_server.ops_dbs.fqdn | ||
} | ||
env { | ||
name = "PGPORT" | ||
value = 5432 | ||
} | ||
env { | ||
name = "PGDATABASE" | ||
value = "postgres" | ||
} | ||
env { | ||
name = "JWT_PRIVATE_KEY" | ||
secret_name = "jwt-private-key" | ||
} | ||
env { | ||
name = "OPS_FRONTEND_URL" | ||
value = "https://${module.ctx.labels.fe.resourceNames["azurerm_container_app"]}.${data.azurerm_container_app_environment.aca_env.default_domain}" | ||
} | ||
} | ||
} | ||
|
||
ingress { | ||
external_enabled = true | ||
target_port = var.port | ||
traffic_weight { | ||
percentage = 100 | ||
latest_revision = true | ||
} | ||
} | ||
secret { | ||
name = "pgpassword" | ||
value = data.azurerm_key_vault_secret.ops-pw.value | ||
} | ||
secret { | ||
name = "jwt-private-key" | ||
value = data.azurerm_key_vault_secret.ops-jwt-private-key.value | ||
} | ||
} | ||
|
||
output "fe_domain" { | ||
value = "https://${module.ctx.labels.fe.resourceNames["azurerm_container_app"]}.${data.azurerm_container_app_environment.aca_env.default_domain}" | ||
} | ||
|
||
output "be_domain" { | ||
value = "https://${module.ctx.labels.be.resourceNames["azurerm_container_app"]}.${data.azurerm_container_app_environment.aca_env.default_domain}" | ||
} | ||
|
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 "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,15 @@ | ||
terraform { | ||
required_providers { | ||
azurerm = { | ||
source = "hashicorp/azurerm" | ||
version = "3.79.0" | ||
} | ||
} | ||
|
||
backend "azurerm" { | ||
resource_group_name = "opre-ops-dev-eus-tf-rg" | ||
storage_account_name = "opreopsdeveustfst" | ||
container_name = "opre-ops-dev-eus-tf-sc" | ||
key = "ops-be-deployment.tfstate" | ||
} | ||
} |
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,61 @@ | ||
variable "owner" { | ||
description = "Name of the owner of the workload and resources" | ||
type = string | ||
default = "OPRE" | ||
} | ||
|
||
variable "project" { | ||
description = "Project name that resources fall under" | ||
type = string | ||
default = "ops" | ||
} | ||
|
||
variable "environment" { | ||
description = "Environment tag for the resources" | ||
type = string | ||
default = "dev" | ||
} | ||
|
||
variable "location" { | ||
description = "Azure location for the resources" | ||
type = string | ||
default = "eastus" | ||
} | ||
|
||
### Container Details | ||
|
||
variable "container_name" { | ||
description = "Name of the container" | ||
type = string | ||
default = "ops-backend" | ||
} | ||
|
||
variable "container_image" { | ||
description = "Container image" | ||
type = string | ||
default = "ghcr.io/hhs/opre-ops/ops-backend" | ||
} | ||
|
||
variable "container_tag" { | ||
description = "Container image tag" | ||
type = string | ||
default = "764bc3296bcdc1abeac2b230088857a54bf4c84e" | ||
} | ||
|
||
variable "cpu" { | ||
description = "CPU requirements. This has specific ration with memory... (beta)" | ||
type = number | ||
default = 0.25 | ||
} | ||
|
||
variable "memory" { | ||
description = "Memory requirements. This has specific ration with cpu... (beta)" | ||
type = string | ||
default = "0.5Gi" | ||
} | ||
|
||
variable "port" { | ||
description = "Port for application" | ||
type = number | ||
default = 8080 | ||
} |
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 @@ | ||
module "ctx" { | ||
source = "../../../global/context" | ||
environment = var.environment | ||
} | ||
|
||
data "azurerm_container_app_environment" "aca_env" { | ||
name = module.ctx.labels.core.resourceNames["azurerm_container_app_environment"] | ||
resource_group_name = module.ctx.resource_group_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,31 @@ | ||
resource "azurerm_container_app" "frontend" { | ||
name = module.ctx.labels.fe.resourceNames["azurerm_container_app"] | ||
container_app_environment_id = data.azurerm_container_app_environment.aca_env.id | ||
resource_group_name = module.ctx.resource_group_name | ||
revision_mode = "Multiple" | ||
|
||
template { | ||
revision_suffix = substr(var.container_tag, 0, 8) | ||
min_replicas = 1 | ||
container { | ||
name = var.container_name | ||
image = "${var.container_image}:${var.container_tag}" | ||
cpu = var.cpu | ||
memory = var.memory | ||
|
||
env { | ||
name = "REACT_APP_BACKEND_DOMAIN" | ||
value = "https://${module.ctx.labels.be.resourceNames["azurerm_container_app"]}.${data.azurerm_container_app_environment.aca_env.default_domain}" | ||
} | ||
} | ||
} | ||
|
||
ingress { | ||
external_enabled = true | ||
target_port = var.port | ||
traffic_weight { | ||
percentage = 100 | ||
latest_revision = 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,3 @@ | ||
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,15 @@ | ||
terraform { | ||
required_providers { | ||
azurerm = { | ||
source = "hashicorp/azurerm" | ||
version = "3.79.0" | ||
} | ||
} | ||
|
||
backend "azurerm" { | ||
resource_group_name = "opre-ops-dev-eus-tf-rg" | ||
storage_account_name = "opreopsdeveustfst" | ||
container_name = "opre-ops-dev-eus-tf-sc" | ||
key = "ops-fe-deployment.tfstate" | ||
} | ||
} |
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,61 @@ | ||
variable "owner" { | ||
description = "Name of the owner of the workload and resources" | ||
type = string | ||
default = "OPRE" | ||
} | ||
|
||
variable "project" { | ||
description = "Project name that resources fall under" | ||
type = string | ||
default = "ops" | ||
} | ||
|
||
variable "environment" { | ||
description = "Environment tag for the resources" | ||
type = string | ||
default = "dev" | ||
} | ||
|
||
variable "location" { | ||
description = "Azure location for the resources" | ||
type = string | ||
default = "eastus" | ||
} | ||
|
||
### Container Details | ||
|
||
variable "container_name" { | ||
description = "Name of the container" | ||
type = string | ||
default = "ops-frontend" | ||
} | ||
|
||
variable "container_image" { | ||
description = "Container image" | ||
type = string | ||
default = "ghcr.io/hhs/opre-ops/ops-frontend" | ||
} | ||
|
||
variable "container_tag" { | ||
description = "Container image tag" | ||
type = string | ||
default = "a6c6948ff0cc6ac68d9aba32059b14e61e924640" | ||
} | ||
|
||
variable "cpu" { | ||
description = "CPU requirements. This has specific ration with memory... (beta)" | ||
type = number | ||
default = 0.25 | ||
} | ||
|
||
variable "memory" { | ||
description = "Memory requirements. This has specific ration with cpu... (beta)" | ||
type = string | ||
default = "0.5Gi" | ||
} | ||
|
||
variable "port" { | ||
description = "Port for application" | ||
type = number | ||
default = 80 | ||
} |