# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. # SPDX-License-Identifier: MIT-0 resource "aws_iam_role" "connection_gateway_resolve_session_function" { name = "${var.project}-${var.environment}-connection-gateway-api-resolve-session" assume_role_policy = < filemd5("${path.module}/functions/resolve-session/src/${filename}") } } data "archive_file" "connection_gateway_resolve_session_function_code" { type = "zip" source_dir = "${path.module}/functions/resolve-session/src" output_path = "${path.module}/functions/resolve-session/${random_uuid.connection_gateway_resolve_session_src_hash.result}.zip" } resource "aws_lambda_function" "connection_gateway_resolve_session_function" { depends_on = [aws_iam_role_policy_attachment.connection_gateway_resolve_session_function_policy_attachment] filename = data.archive_file.connection_gateway_resolve_session_function_code.output_path source_code_hash = data.archive_file.connection_gateway_resolve_session_function_code.output_base64sha256 function_name = "${var.project}-${var.environment}-connection-gateway-api-resolve-session" role = aws_iam_role.connection_gateway_resolve_session_function.arn handler = "index.lambda_handler" runtime = "python3.9" timeout = 30 tracing_config { mode = "Active" } vpc_config { subnet_ids = var.private_subnets_id security_group_ids = [aws_security_group.connection_gateway_functions_sg.id] } environment { variables = { TCP_PORT = var.tcp_port UDP_PORT = var.udp_port } } }