Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update_281124_2 #8853

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion terraform/environments/ppud/data.tf
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,16 @@ data "aws_acm_certificate" "WAM_PROD_ALB" {
count = local.is-production == true ? 1 : 0
domain = "wam.ppud.justice.gov.uk"
statuses = ["ISSUED"]
}
}

# Klayers Account ID - used by lambda layer ARNs - https://github.com/keithrozario/Klayers?tab=readme-ov-file
data "aws_ssm_parameter" "klayers_account_dev" {
count = local.is-development == true ? 1 : 0
name = "klayers-account"
with_decryption = true
}

output "klayers_account_dev" {
value = data.aws_ssm_parameter.klayers_account_dev[0].value
description = "The Klayers AWS account ID"
}
23 changes: 23 additions & 0 deletions terraform/environments/ppud/iam.tf
Original file line number Diff line number Diff line change
Expand Up @@ -1183,6 +1183,29 @@ resource "aws_iam_policy" "iam_policy_for_lambda_cloudwatch_get_metric_data_dev"
"arn:aws:cloudwatch:eu-west-2:${local.environment_management.account_ids["ppud-development"]}:*"
]
},
{
"Sid" : "S3BucketPolicy",
"Effect" : "Allow",
"Action" : [
"s3:GetObject",
"s3:PutObject",
"s3:DeleteObject"
],
"Resource" : [
"arn:aws:s3:::moj-release-management",
"arn:aws:s3:::moj-release-management/*"
]
},
{
"Sid" : "SSMPolicy",
"Effect" : "Allow",
"Action" : [
"ssm:GetParameter"
],
"Resource" : [
"arn:aws:ssm:eu-west-2:${local.environment_management.account_ids["ppud-development"]}:parameter/klayers-account"
]
},
{
"Sid" : "LogPolicy",
"Effect" : "Allow",
Expand Down
18 changes: 17 additions & 1 deletion terraform/environments/ppud/lambda.tf
Original file line number Diff line number Diff line change
Expand Up @@ -516,6 +516,9 @@ resource "aws_lambda_function" "terraform_lambda_func_send_cpu_graph_dev" {
layers = [
"arn:aws:lambda:eu-west-2:770693421928:layer:Klayers-p312-numpy:8", #Publically available ARN for numpy package
"arn:aws:lambda:eu-west-2:770693421928:layer:Klayers-p312-pillow:1" #Publically available ARN for pillow package
# "arn:aws:lambda:eu-west-2:${data.aws_ssm_parameter.klayers_account_dev[0].value}:layer:Klayers-p312-numpy:8",
# "arn:aws:lambda:eu-west-2:${data.aws_ssm_parameter.klayers_account_dev[0].value}:layer:Klayers-p312-pillow:1",
# aws_lambda_layer_version.lambda_layer_matplotlib_dev[0].arn
]
}

Expand All @@ -526,4 +529,17 @@ data "archive_file" "zip_the_send_cpu_graph_code_dev" {
type = "zip"
source_dir = "${path.module}/lambda_scripts/"
output_path = "${path.module}/lambda_scripts/send_cpu_graph_dev.zip"
}
}

# Lambda Layer for Matplotlib

/*
resource "aws_lambda_layer_version" "lambda_layer_matplotlib_dev" {
count = local.is-development == true ? 1 : 0
layer_name = "matplotlib-layer"
description = "matplotlib-layer for python 3.12"
s3_bucket = aws_s3_bucket.MoJ-Release-Management[0].id
filename = "/lambda_layers/matplotlib-layer.zip"
compatible_runtimes = ["python3.12"]
}
*/
3 changes: 2 additions & 1 deletion terraform/environments/ppud/s3.tf
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,8 @@ resource "aws_s3_bucket_policy" "MoJ-Release-Management" {
"Principal" : {
"AWS" : [
"arn:aws:iam::${local.environment_management.account_ids["ppud-development"]}:role/ec2-iam-role",
"arn:aws:iam::${local.environment_management.account_ids["ppud-preproduction"]}:role/ec2-iam-role"
"arn:aws:iam::${local.environment_management.account_ids["ppud-preproduction"]}:role/ec2-iam-role",
"arn:aws:iam::${local.environment_management.account_ids["ppud-development"]}:role/lambda_role_cloudwatch_get_metric_data_dev"
]
}
}
Expand Down
Loading