# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. # SPDX-License-Identifier: MIT-0 resource "aws_iam_role" "connection_gateway_api_auth_function" { name = "${var.project}-${var.environment}-connection-gateway-api-auth" assume_role_policy = < filemd5("${path.module}/functions/auth/src/${filename}") } } data "archive_file" "connection_gateway_api_auth_function_code" { depends_on = [ null_resource.install_dependencies ] excludes = [ "__pycache__", "venv", ".venv" ] type = "zip" source_dir = "${path.module}/functions/auth/src/" output_path = "${path.module}/functions/auth/${random_uuid.connection_gateway_api_auth_src_hash.result}.zip" } resource "aws_lambda_function" "connection_gateway_api_auth_function" { #checkov:skip=CKV_AWS_117:The Lambda function needs to access to cognito and there is no VPC endpoint for cognito, thus not in a VPC depends_on = [aws_iam_role_policy_attachment.connection_gateway_api_auth_function_policy_attachment] filename = data.archive_file.connection_gateway_api_auth_function_code.output_path source_code_hash = data.archive_file.connection_gateway_api_auth_function_code.output_base64sha256 function_name = "${var.project}-${var.environment}-connection-gateway-api-auth" role = aws_iam_role.connection_gateway_api_auth_function.arn handler = "index.lambda_handler" runtime = "python3.9" tracing_config { mode = "Active" } timeout = 30 environment { variables = { COGNITO_USER_POOL_ID = var.user_pool_id APP_CLIENT_ID = var.user_pool_client_id AD_DOMAIN_NAME = var.active_directory_domain_name } } }