Skip to content

Commit f9f4c1e

Browse files
[NDR-54] Stopping Terraform overwriting Lambdas (#291)
* [NDR-54] Add lifecycle blocks to Lambda resources to ignore changes during CI/CD deployments * [NDR-54] Add layers to ignore_changes in Lambda lifecycle to prevent unnecessary updates during CI/CD * [NDR-54] Remove last_modified from ignore_changes in Lambda lifecycle to streamline CI/CD deployments
1 parent d37f3af commit f9f4c1e

2 files changed

Lines changed: 15 additions & 0 deletions

File tree

infrastructure/modules/lambda/main.tf

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,14 @@ resource "aws_lambda_function" "lambda" {
2020
"arn:aws:lambda:eu-west-2:580247275435:layer:LambdaInsightsExtension:53",
2121
"arn:aws:lambda:eu-west-2:282860088358:layer:AWS-AppConfig-Extension:120"
2222
]
23+
24+
lifecycle {
25+
ignore_changes = [
26+
# These are required as Lambdas are deployed via the CI/CD pipelines
27+
source_code_hash,
28+
layers
29+
]
30+
}
2331
}
2432

2533
resource "aws_api_gateway_integration" "lambda_integration" {

infrastructure/modules/lambda_layers/main.tf

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,11 @@ resource "aws_lambda_layer_version" "lambda_layer" {
1313
layer_name = local.lambda_layer_aws_name
1414
compatible_runtimes = ["python3.11"]
1515
compatible_architectures = ["x86_64"]
16+
17+
lifecycle {
18+
ignore_changes = [
19+
# These are required as Lambdas are deployed via the CI/CD pipelines
20+
filename
21+
]
22+
}
1623
}

0 commit comments

Comments
 (0)