Skip to content

SPHTech-Platform/terraform-aws-apigw

Repository files navigation

API Gateway Version 1

API gateway module for REST API. There is no community module available for REST API.

Requirements

Name Version
terraform >= 1.0
aws >= 4.67.0

Providers

Name Version
aws 5.31.0

Modules

Name Source Version
apigw_cwl_role terraform-aws-modules/iam/aws//modules/iam-assumable-role ~> 5.9.2

Resources

Name Type
aws_api_gateway_account.api_gateway_account resource
aws_api_gateway_deployment.deployment resource
aws_api_gateway_method_settings.method_settings resource
aws_api_gateway_rest_api.api resource
aws_api_gateway_rest_api_policy.policy_attachment resource
aws_api_gateway_stage.stage resource
aws_api_gateway_vpc_link.vpc_link resource
aws_cloudwatch_log_group.log_group resource
aws_kms_key.cloudwatch resource
aws_caller_identity.current data source
aws_iam_policy_document.cloudwatch_logs_allow_apigw data source
aws_region.current data source

Inputs

Name Description Type Default Required
body_template OpenAPI specification template string "" no
cache_cluster_enabled Specifies whether a cache cluster is enabled for the stage. bool false no
cache_cluster_size The size of the cache cluster for the stage, if enabled string "0.5" no
cache_data_encrypted Specifies whether a cache data needs to be encrypted. bool true no
caching_enabled Specifies whether caching is enabled for the API gateway method bool false no
data_trace_enabled Specifies the logging level for this method. bool false no
enable_global_apigw_logging Enable global apigw logging bool false no
enable_resource_policy Enable resource policy to allow other resources to Invoke this API bool false no
log_format Cloudwatch log format map(string)
{
"caller": "$context.identity.caller",
"extendedRequestId": "$context.extendedRequestId",
"httpMethod": "$context.httpMethod",
"ip": "$context.identity.sourceIp",
"protocol": "$context.protocol",
"requestId": "$context.requestId",
"requestTime": "$context.requestTime",
"resourcePath": "$context.resourcePath",
"responseLength": "$context.responseLength",
"status": "$context.status",
"user": "$context.identity.user"
}
no
log_group_name Custom log group name. string "" no
log_kms_key_id The ARN of the KMS Key to use when encrypting log data string "" no
log_retention_in_days Cloudwatch log retention in days number 7 no
logging_level Specifies the logging level for this method. string "ERROR" no
metrics_enabled Specifies whether Amazon CloudWatch metrics are enabled for this method. bool false no
name Name of the API gateway string n/a yes
resource_policy_json Resource policy as JSON to attach string null no
stage Name of the API gateway stage string n/a yes
stage_variables Stage variables for the API gateway stage map(any) {} no
tags A map of tags to add to all resources map(string) {} no
throttling_burst_limit The API request burst limit, the maximum rate limit over a time ranging from one to a few seconds, depending upon whether the underlying token bucket is at its full capacity. number 1000 no
throttling_rate_limit The API request steady-state rate limit number 1000 no
types Name of the API gateway stage list(string)
[
"REGIONAL"
]
no
vpc_links List of VPC links for REST APIs. key in the map denotes the vpc link name
map(
object({
description = string
target_arns = list(string)
})
)
{} no

Outputs

Name Description
aws_api_gateway_execution_arn The execution ARN part to be used in lambda_permission source_arn when allowing API Gateway to invoke a Lambda function
aws_api_gateway_rest_api_id REST API id of the created api
aws_api_gateway_rest_api_root_resource_id Root resource ID of the API Gateway REST API
aws_api_gateway_stage_arn ARN (for management) of apigw stage, use this when attaching Web ACL
aws_api_gateway_stage_execution_arn The execution ARN part to be used in lambda_permission source_arn when allowing API Gateway to invoke a Lambda function
aws_api_gateway_stage_invoke_url The URL to invoke the API pointing to the stage
aws_api_gateway_stage_name Stage name of the deployed api gateway stage
aws_api_gateway_vpc_link_id VPC link id