# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. # SPDX-License-Identifier: MIT-0 resource "aws_iam_role" "connection_gateway_api_cloudwatch" { name_prefix = "${var.project}-${var.environment}-con-gw-api-cw" assume_role_policy = jsonencode({ Version = "2012-10-17" Statement = [ { Action = "sts:AssumeRole" Effect = "Allow" Principal = { Service = "apigateway.amazonaws.com" } }, ] }) inline_policy { name = "${var.project}-${var.environment}-logs" policy = jsonencode({ Version = "2012-10-17" Statement = [ { Action = [ "logs:CreateLogGroup", "logs:CreateLogStream", "logs:DescribeLogGroups", "logs:DescribeLogStreams", "logs:PutLogEvents", "logs:GetLogEvents", "logs:FilterLogEvents" ] Effect = "Allow" Resource = "*" }, ] }) } } resource "aws_api_gateway_account" "connection_gateway_api_account" { cloudwatch_role_arn = aws_iam_role.connection_gateway_api_cloudwatch.arn } resource "aws_api_gateway_rest_api" "connection_gateway_api" { name = "${var.project}-${var.environment}-connection-gateway-api" description = "Connection Gateway API" disable_execute_api_endpoint = false endpoint_configuration { vpc_endpoint_ids = [var.api_gateway_vpc_endpoint_id] types = ["PRIVATE"] } lifecycle { create_before_destroy = true } } resource "aws_api_gateway_rest_api_policy" "connection_gateway_api_resource_policy" { rest_api_id = aws_api_gateway_rest_api.connection_gateway_api.id policy = <