# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. # SPDX-License-Identifier: MIT-0 resource "aws_iam_role" "build_image_function_role" { name = "${var.project}-${var.environment}-build-image-function-role" assume_role_policy = < filemd5("${path.module}/functions/build-image/src/${filename}") } } data "archive_file" "build_image_function_code" { type = "zip" source_dir = "${path.module}/functions/build-image/src/" output_path = "${path.module}/functions/build-image/${random_uuid.build_image_function_src_hash.result}.zip" } # function that triggers the image builder pipeline after deployment resource "aws_lambda_function" "build_image_function" { depends_on = [aws_iam_role_policy_attachment.build_image_function_policy_attachment] filename = data.archive_file.build_image_function_code.output_path source_code_hash = data.archive_file.build_image_function_code.output_base64sha256 function_name = "${var.project}-${var.environment}-build-image" role = aws_iam_role.build_image_function_role.arn handler = "index.lambda_handler" runtime = "python3.9" tracing_config { mode = "Active" } timeout = 30 }