mirror of
https://github.com/Hestia-Homes/Model.git
synced 2026-06-08 11:17:27 +00:00
Merge pull request #711 from Hestia-Homes/deploy-categorisation
New ECR repository for Categorisation
This commit is contained in:
commit
abf0a036d9
6 changed files with 88 additions and 3 deletions
1
.github/workflows/deploy_terraform.yml
vendored
1
.github/workflows/deploy_terraform.yml
vendored
|
|
@ -52,6 +52,7 @@ jobs:
|
|||
runs-on: ubuntu-latest
|
||||
env:
|
||||
STAGE: ${{ needs.determine_stage.outputs.stage }}
|
||||
TERRAFORM_APPLY: ${{ needs.determine_stage.outputs.terraform_apply }}
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
### 1. Create the Lambda scaffold
|
||||
- Copy the template:
|
||||
|
||||
cp -r lambda/_template lambda/<lambda_name>
|
||||
`cp -r lambda/_template lambda/<lambda_name>`
|
||||
|
||||
---
|
||||
|
||||
|
|
@ -12,8 +12,7 @@
|
|||
|
||||
infrastructure/terraform/shared/main.tf
|
||||
|
||||
- Apply the shared stack
|
||||
- This requires commenting 'if env.stage == "prod"' in .github/workflows/deploy_terraform.yml
|
||||
- Create a PR to deploy this to main then dev in order to deploy the shared stack
|
||||
|
||||
- Verify the ECR repository exists in AWS
|
||||
|
||||
|
|
|
|||
27
infrastructure/terraform/lambda/categorisation/main.tf
Normal file
27
infrastructure/terraform/lambda/categorisation/main.tf
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
data "terraform_remote_state" "shared" {
|
||||
backend = "s3"
|
||||
config = {
|
||||
bucket = "assessment-model-terraform-state"
|
||||
key = "env:/${var.stage}/terraform.tfstate"
|
||||
region = "eu-west-2"
|
||||
}
|
||||
}
|
||||
|
||||
module "lambda" {
|
||||
source = "../modules/lambda_with_sqs"
|
||||
|
||||
name = "categorisation"
|
||||
stage = var.stage
|
||||
|
||||
image_uri = local.image_uri
|
||||
|
||||
|
||||
environment = merge(
|
||||
{
|
||||
STAGE = var.stage
|
||||
LOG_LEVEL = "info"
|
||||
DB_USERNAME = local.db_credentials.db_assessment_model_username
|
||||
DB_PASSWORD = local.db_credentials.db_assessment_model_password
|
||||
}
|
||||
)
|
||||
}
|
||||
16
infrastructure/terraform/lambda/categorisation/provider.tf
Normal file
16
infrastructure/terraform/lambda/categorisation/provider.tf
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
terraform {
|
||||
required_providers {
|
||||
aws = {
|
||||
source = "hashicorp/aws"
|
||||
version = "~> 4.16"
|
||||
}
|
||||
}
|
||||
|
||||
backend "s3" {
|
||||
bucket = "categorisation"
|
||||
key = "terraform.tfstate"
|
||||
region = "eu-west-2"
|
||||
}
|
||||
|
||||
required_version = ">= 1.2.0"
|
||||
}
|
||||
27
infrastructure/terraform/lambda/categorisation/variables.tf
Normal file
27
infrastructure/terraform/lambda/categorisation/variables.tf
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
variable "lambda_name" {
|
||||
type = string
|
||||
description = "Logical name of the lambda (e.g. address2uprn)"
|
||||
}
|
||||
|
||||
variable "stage" {
|
||||
description = "Deployment stage (e.g. dev, prod)"
|
||||
type = string
|
||||
}
|
||||
variable "ecr_repo_url" {
|
||||
type = string
|
||||
description = "ECR repository URL (no tag, no digest)"
|
||||
}
|
||||
|
||||
variable "image_digest" {
|
||||
type = string
|
||||
description = "Image digest (sha256:...)"
|
||||
}
|
||||
|
||||
|
||||
locals {
|
||||
image_uri = "${var.ecr_repo_url}@${var.image_digest}"
|
||||
}
|
||||
|
||||
output "resolved_image_uri" {
|
||||
value = local.image_uri
|
||||
}
|
||||
|
|
@ -392,4 +392,19 @@ module "postcode_splitter_s3_read" {
|
|||
|
||||
output "postcode_splitter_s3_read_arn" {
|
||||
value = module.postcode_splitter_s3_read.policy_arn
|
||||
}
|
||||
|
||||
################################################
|
||||
# Categorisation – Lambda ECR
|
||||
################################################
|
||||
module "categorisation_state_bucket" {
|
||||
source = "../modules/tf_state_bucket"
|
||||
bucket_name = "categorisation-terraform-state"
|
||||
|
||||
}
|
||||
|
||||
module "categorisation_registry" {
|
||||
source = "../modules/container_registry"
|
||||
name = "categorisation"
|
||||
stage = var.stage
|
||||
}
|
||||
Loading…
Add table
Reference in a new issue