Skip to content

KEH-1797 Modularising lambda#37

Open
nimshi89 wants to merge 4 commits intomainfrom
KEH-1797-terraform-modularise
Open

KEH-1797 Modularising lambda#37
nimshi89 wants to merge 4 commits intomainfrom
KEH-1797-terraform-modularise

Conversation

@nimshi89
Copy link
Copy Markdown
Contributor

@nimshi89 nimshi89 commented Jan 27, 2026

What type of PR is this? (check all applicable)

  • Refactor
  • Feature
  • Bug Fix
  • Optimization
  • Documentation Update

What

Modified the terraform/lambda/main.tf, outputs.tf and variables.tf files.
Moved resources to a shared repository https://github.com/ONSdigital/ons-terraform-modular.

The "IAM role", "policies" and "security group" are now created by module.lambda_role_and_sg instead of inline.
The "Lambda function" is now created by module.tech_audit_lambda.lambda_function_arn / lambda_function_name instead of inline.

Testing

Have any new tests been added as part of this issue? If not, try to explain why test coverage is not needed here.

  • Yes
  • No
    The modification to the terraform does not have any dependent tests, therefore not require new tests or modification to existing tests.
  • Not as part of this ticket. (Could be done at a later point)

Documentation

Has any new documentation been written as part of this issue? We should try to keep documentation up to date
as new code is added, rather than leaving it for the future.

  • Yes
  • No
    Please write a brief description of why documentation is not necessary here.
  • Not as part of this ticket. (Could be done at a later point)

Related issues

KEH-1797

How to review

check if the terraform changes are up to the tickets acceptance

@co-opsw
Copy link
Copy Markdown

co-opsw commented Feb 9, 2026

LGTM, just make sure AWS functions the same when applying :)

@co-opsw co-opsw requested a review from a team February 9, 2026 10:45
@co-opsw co-opsw added the enhancement New feature or request label Feb 9, 2026
@co-opsw
Copy link
Copy Markdown

co-opsw commented Feb 9, 2026

LGTM, just make sure AWS functions the same when applying :)

Wait for two reviews before merging though!

Comment thread terraform/lambda/main.tf
}
#1. IAM Role and Security Group for Lambda
module "lambda_role_and_sg" {
source = "git::https://github.com/ONSdigital/ons-terraform-modular.git//terraform/lambda/lambda_role_and_sg?ref=KEH-1797-shared-terraform-repo"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this source name needs to be updated?

From ons-terraform-modular to ons-shared-terraform-repository

Other than that, LGTM otherwise

Copy link
Copy Markdown
Collaborator

@delterr delterr Feb 24, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this source name needs to be updated?

From ons-terraform-modular to ons-shared-terraform-repository

Other than that, LGTM otherwise

The old name seems to still point to the new repo - I guess its still better to have the new name instead

@delterr delterr self-requested a review February 24, 2026 06:53
Comment thread terraform/lambda/main.tf
image_uri = "${var.aws_account_id}.dkr.ecr.${var.region}.amazonaws.com/${var.ecr_repository}@${data.aws_ecr_image.lambda_image.image_digest}"
# 2. Create the Lambda function
module "tech_audit_lambda" {
source = "git::https://github.com/ONSdigital/ons-terraform-modular.git//terraform/lambda?ref=KEH-1797-shared-terraform-repo"
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

parroting on what was mentioned before with the new/old URL

Comment thread docs/infrastructure.md

The Lambda Terraform now composes shared modules for the IAM role/security group and the Lambda resource itself. You still provide the image details via `ecr_repository` and `container_ver` (tag). Optionally, you can pin to an immutable image digest using `container_digest` to avoid tag lookup issues.

After apply, you can confirm the exact image (including digest) via the `lambda_image_uri` Terraform output.
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nitpick - "After applying"

Copy link
Copy Markdown
Collaborator

@delterr delterr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, just a few nitpicks with regards to URLs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants