From 143c2b772e2d05ca5dac4578a2d3f881bade3053 Mon Sep 17 00:00:00 2001 From: Andrew Pearce Date: Mon, 30 Oct 2023 19:39:28 +0000 Subject: [PATCH] add insights to replication job --- lambda/create_s3_replication_job/Dockerfile | 12 +++++++++++- .../region/modules/uploads_s3_bucket/lambda.tf | 6 ++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/lambda/create_s3_replication_job/Dockerfile b/lambda/create_s3_replication_job/Dockerfile index b036fec8d7..226cf06d30 100644 --- a/lambda/create_s3_replication_job/Dockerfile +++ b/lambda/create_s3_replication_job/Dockerfile @@ -34,8 +34,18 @@ RUN python -m pip install \ --target ${FUNCTION_DIR} \ --requirement requirements.txt +FROM public.ecr.aws/lambda/provided:al2 AS production + +RUN curl -O https://lambda-insights-extension.s3-ap-northeast-1.amazonaws.com/amazon_linux/lambda-insights-extension.rpm && \ + rpm -U lambda-insights-extension.rpm && \ + rm -f lambda-insights-extension.rpm + +# RUN curl -O https://lambda-insights-extension-arm64.s3-ap-northeast-1.amazonaws.com/amazon_linux/lambda-insights-extension-arm64.rpm && \ +# rpm -U lambda-insights-extension-arm64.rpm && \ +# rm -f lambda-insights-extension-arm64.rpm + # Multi-stage build: grab a fresh copy of the base image -FROM python-alpine +# FROM python-alpine # Include global arg in this stage of the build ARG FUNCTION_DIR diff --git a/terraform/environment/region/modules/uploads_s3_bucket/lambda.tf b/terraform/environment/region/modules/uploads_s3_bucket/lambda.tf index 7dffa270f0..c6e0bce074 100644 --- a/terraform/environment/region/modules/uploads_s3_bucket/lambda.tf +++ b/terraform/environment/region/modules/uploads_s3_bucket/lambda.tf @@ -116,3 +116,9 @@ data "aws_iam_policy_document" "scheduler_invoke_lambda" { } provider = aws.region } + +resource "aws_iam_role_policy_attachment" "cloudwatch_lambda_insights" { + role = module.s3_create_batch_replication_jobs.lambda_role.id + policy_arn = "arn:aws:iam::aws:policy/CloudWatchLambdaInsightsExecutionRolePolicy" + provider = aws.region +}