-
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.
ER-698: Azure - Deploy Background Worker (#727)
* ER-701: Log Analytics workspace * ER-698: Terraform script * ER-691: Docker Image name * ER-698: Omit default credentials * ER-698: Formatting * ER-698: Startup command * ER-698: Startup command * ER-698: Azure Container Instances * Formatting * ER-698: Unit test * Supress checkov --------- Co-authored-by: Sunny Sidhu <[email protected]>
- Loading branch information
1 parent
9f9bc22
commit eb34efd
Showing
15 changed files
with
278 additions
and
114 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,37 @@ | ||
locals { | ||
# Common tags to be assigned resources | ||
common_tags = { | ||
"Environment" = var.environment | ||
"Parent Business" = "Children’s Care" | ||
"Portfolio" = "Newly Onboarded" | ||
"Product" = "EY Recovery" | ||
"Service" = "Newly Onboarded" | ||
"Service Line" = "Newly Onboarded" | ||
"Service Offering" = "EY Recovery" | ||
} | ||
|
||
# Web App Configuration | ||
webapp_app_settings = { | ||
"DATABASE_URL" = var.webapp_database_url | ||
"WEBSITES_ENABLE_APP_SERVICE_STORAGE" = "false" | ||
"GOVUK_APP_DOMAIN" = "london.cloudapps.digital" #TODO: Remove this dependency post-migration to Azure | ||
"GOVUK_WEBSITE_ROOT" = "ey-recovery-dev" #TODO: Remove this dependency post-migration to Azure | ||
"BOT_TOKEN" = var.webapp_config_bot_token | ||
"CONTENTFUL_ENVIRONMENT" = var.webapp_config_contentful_environment | ||
"CONTENTFUL_PREVIEW" = var.webapp_config_contentful_preview | ||
"DOMAIN" = var.webapp_config_domain | ||
"EDITOR" = var.webapp_config_editor | ||
"FEEDBACK_URL" = var.webapp_config_feedback_url | ||
"GROVER_NO_SANDBOX" = var.webapp_config_grover_no_sandbox | ||
"GOOGLE_CLOUD_BUCKET" = var.webapp_config_google_cloud_bucket | ||
"NODE_ENV" = var.webapp_config_node_env | ||
"RAILS_ENV" = var.webapp_config_rails_env | ||
"RAILS_LOG_TO_STDOUT" = var.webapp_config_rails_log_to_stdout | ||
"RAILS_MASTER_KEY" = var.webapp_config_rails_master_key | ||
"RAILS_MAX_THREADS" = var.webapp_config_rails_max_threads | ||
"RAILS_SERVE_STATIC_FILES" = var.webapp_config_rails_serve_static_files | ||
"TRAINING_MODULES" = var.webapp_config_training_modules | ||
"WEB_CONCURRENCY" = var.webapp_config_web_concurrency | ||
"WEBSITES_CONTAINER_START_TIME_LIMIT" = 1800 | ||
} | ||
} |
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,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2022 DFE-Digital | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
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 @@ | ||
# Azure App Module | ||
|
||
This module provisions a new Azure Container Instances resource to host a Docker container for a background job Application. |
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,42 @@ | ||
# Create Background Worker Application | ||
resource "azurerm_container_group" "app_worker" { | ||
name = var.app_worker_name | ||
location = var.location | ||
resource_group_name = var.resource_group | ||
ip_address_type = "None" | ||
os_type = "Linux" | ||
restart_policy = "OnFailure" | ||
|
||
container { | ||
name = var.container_name | ||
image = "${var.app_worker_docker_registry}/${var.app_worker_docker_image}:${var.app_worker_docker_image_tag}" | ||
cpu = "1.0" | ||
memory = "2.0" | ||
environment_variables = var.app_worker_environment_variables | ||
commands = var.app_worker_startup_command | ||
} | ||
|
||
diagnostics { | ||
log_analytics { | ||
workspace_id = azurerm_log_analytics_workspace.app_worker_logs.workspace_id | ||
workspace_key = azurerm_log_analytics_workspace.app_worker_logs.primary_shared_key | ||
} | ||
} | ||
|
||
subnet_ids = [var.app_worker_subnet_id] | ||
|
||
#checkov:skip=CKV2_AZURE_28:Using VNet | ||
} | ||
|
||
# Create Log Analytics | ||
resource "azurerm_log_analytics_workspace" "app_worker_logs" { | ||
name = "${var.resource_name_prefix}-log" | ||
location = var.location | ||
resource_group_name = var.resource_group | ||
sku = "PerGB2018" | ||
retention_in_days = 30 | ||
|
||
lifecycle { | ||
ignore_changes = [tags] | ||
} | ||
} |
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,54 @@ | ||
variable "location" { | ||
description = "Name of the Azure region to deploy resources" | ||
type = string | ||
} | ||
|
||
variable "resource_group" { | ||
description = "Name of the Azure Resource Group to deploy resources" | ||
type = string | ||
} | ||
|
||
variable "resource_name_prefix" { | ||
description = "Prefix for resource names" | ||
type = string | ||
} | ||
|
||
variable "app_worker_name" { | ||
description = "Name for the Application" | ||
type = string | ||
} | ||
|
||
variable "container_name" { | ||
description = "Name for the Container" | ||
type = string | ||
} | ||
|
||
variable "app_worker_subnet_id" { | ||
description = "ID of the delegated Subnet for the Application" | ||
type = string | ||
} | ||
|
||
variable "app_worker_environment_variables" { | ||
description = "Environment Variables to expose to the Application" | ||
type = map(string) | ||
} | ||
|
||
variable "app_worker_docker_registry" { | ||
description = "Docker Registry Server" | ||
type = string | ||
} | ||
|
||
variable "app_worker_docker_image" { | ||
description = "Docker Image to deploy" | ||
type = string | ||
} | ||
|
||
variable "app_worker_docker_image_tag" { | ||
description = "Tag for the Docker Image" | ||
type = string | ||
} | ||
|
||
variable "app_worker_startup_command" { | ||
description = "Startup command to pass into the Application" | ||
type = list(string) | ||
} |
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
Oops, something went wrong.