All Projects → clouddrove → terraform-aws-api-gateway

clouddrove / terraform-aws-api-gateway

Licence: Apache-2.0 license
Terraform module to create Route53 resource on AWS for create api gateway with it's basic elements.

Programming Languages

HCL
1544 projects
go
31211 projects - #10 most used programming language
Makefile
30231 projects

Projects that are alternatives of or similar to terraform-aws-api-gateway

terraform-aws-efs-backup
Terraform module designed to easily backup EFS filesystems to S3 using DataPipeline
Stars: ✭ 40 (-6.98%)
Mutual labels:  terraform-modules
terraform-oci-vcn
A reusable and extensible Terraform module that provisions a VCN on Oracle Cloud Infrastructure
Stars: ✭ 22 (-48.84%)
Mutual labels:  terraform-modules
microservice-style-guide
There are several articles on ‘internet’ including large companies, showing their microservices using REST, this guide has how to show some good practices and standards so that you have a microservice architecture that is the best possible, totally decoupled and scalable.
Stars: ✭ 93 (+116.28%)
Mutual labels:  api-gateway
aws-lambda-r
Using R on AWS Lambda
Stars: ✭ 51 (+18.6%)
Mutual labels:  api-gateway
tencent-apigateway
Easily provision Tencent API Gateway using Serverless Components
Stars: ✭ 33 (-23.26%)
Mutual labels:  api-gateway
resource-x
Resource and domain modeling for quick APIs, CMSs, and applications.
Stars: ✭ 26 (-39.53%)
Mutual labels:  aws-api-gateway
terraform-aws-cloudtrail
Creates and configures AWS CloudTrail
Stars: ✭ 40 (-6.98%)
Mutual labels:  terraform-modules
lura
Ultra performant API Gateway with middlewares. A project hosted at The Linux Foundation
Stars: ✭ 5,159 (+11897.67%)
Mutual labels:  api-gateway
safe-client-gateway
Gateway service for Safe apps that serves transaction data conforming with the UI of our mobile apps
Stars: ✭ 33 (-23.26%)
Mutual labels:  api-gateway
serverless-api-gateway-throttling
A plugin for the Serverless framework which configures throttling for API Gateway endpoints.
Stars: ✭ 54 (+25.58%)
Mutual labels:  api-gateway
yap
Open source API Gateway on GraphQL for serverless. Less code, safer API. 💪
Stars: ✭ 105 (+144.19%)
Mutual labels:  api-gateway
terraform-azurerm-compute
Terraform Azure RM Compute Module
Stars: ✭ 133 (+209.3%)
Mutual labels:  terraform-modules
terranetes
Terraform boilerplate for production-grade Kubernetes clusters on AWS (optionally includes kube-system components, OpenVPN, an ingress controller, monitoring services...)
Stars: ✭ 15 (-65.12%)
Mutual labels:  terraform-modules
terraform-codedeploy
Terraform module to add codedeploy
Stars: ✭ 29 (-32.56%)
Mutual labels:  terraform-modules
serverless-cloud-vision
Serverless API around Google Cloud Vision
Stars: ✭ 31 (-27.91%)
Mutual labels:  api-gateway
gotway
☸️ Cloud native API Gateway powered with in-redis cache
Stars: ✭ 71 (+65.12%)
Mutual labels:  api-gateway
terraform-azurerm-kubernetes
Install a Kubernetes cluster the CoreOS Tectonic Way: HA, self-hosted, RBAC, etcd Operator, and more
Stars: ✭ 22 (-48.84%)
Mutual labels:  terraform-modules
govway
API Gateway per la Pubblica Amministrazione italiana
Stars: ✭ 38 (-11.63%)
Mutual labels:  api-gateway
terraform-aws-backup
Terraform module to provision AWS Backup, a fully managed backup service that makes it easy to centralize and automate the back up of data across AWS services such as EBS volumes, RDS databases, DynamoDB tables, EFS file systems, and AWS Storage Gateway volumes.
Stars: ✭ 62 (+44.19%)
Mutual labels:  terraform-modules
express-sls-app
How to deploy a Node.js application to AWS Lambda using Serverless, a quick start.
Stars: ✭ 20 (-53.49%)
Mutual labels:  aws-api-gateway

Terraform AWS Api Gateway

Terraform module to create Route53 resource on AWS for create api gateway with it's basic elements.

Terraform Licence tfsec static-checks


We eat, drink, sleep and most importantly love DevOps. We are working towards strategies for standardizing architecture while ensuring security for the infrastructure. We are strong believer of the philosophy Bigger problems are always solved by breaking them into smaller manageable problems. Resonating with microservices architecture, it is considered best-practice to run database, cluster, storage in smaller connected yet manageable pieces within the infrastructure.

This module is basically combination of Terraform open source and includes automatation tests and examples. It also helps to create and improve your infrastructure with minimalistic code instead of maintaining the whole infrastructure code yourself.

We have fifty plus terraform modules. A few of them are comepleted and are available for open source usage while a few others are in progress.

Prerequisites

This module has a few dependencies:

Examples

IMPORTANT: Since the master branch used in source varies based on new modifications, we suggest that you use the release versions here.

Here are examples of how you can use this module in your inventory structure:

Basic Example

  module "api-gateway" {
    source        = "clouddrove/api-gateway/aws"
    version       = "1.0.1"
    name          = "api-gateway"
    environment   = "test"
    label_order   = ["name", "environment"]
    enabled       = true

  # Api Gateway Resource
    path_parts = ["mytestresource", "mytestresource1"]

  # Api Gateway Method
    method_enabled = true
    http_methods   = ["GET", "GET"]

  # Api Gateway Integration
    integration_types        = ["MOCK", "AWS_PROXY"]
    integration_http_methods = ["POST", "POST"]
    uri                      = ["", "arn:aws:apigateway:eu-west-1:lambda:path/2015-03-31/functions/arn:aws:lambda:eu-west-1:xxxxxxxxxx:function:test/invocations"]
    integration_request_parameters = [{
      "integration.request.header.X-Authorization" = "'static'"
    }, {}]
    request_templates = [{
      "application/xml" = <<EOF
  {
     "body" : $input.json('$')
  }
  EOF
    }, {}]

  # Api Gateway Method Response
    status_codes = [200, 200]
    response_models = [{ "application/json" = "Empty" }, {}]
    response_parameters = [{ "method.response.header.X-Some-Header" = true }, {}]

  # Api Gateway Integration Response
    integration_response_parameters = [{ "method.response.header.X-Some-Header" = "integration.response.header.X-Some-Other-Header" }, {}]
    response_templates = [{
      "application/xml" = <<EOF
  #set($inputRoot = $input.path('$'))
  <?xml version="1.0" encoding="UTF-8"?>
  <message>
      $inputRoot.body
  </message>
  EOF
    }, {}]

  # Api Gateway Deployment
    deployment_enabled = true
    stage_name         = "deploy"

  # Api Gateway Stage
    stage_enabled = true
    stage_names   = ["qa", "dev"]
  }

Complete Example

  module "api-gateway" {
    source        = "clouddrove/api-gateway/aws"
    version       = "1.0.1"

    name        = "api-gateway"
    environment = "test"
    label_order = ["name", "environment"]
    enabled     = true

  # Api Gateway Resource
    path_parts = ["mytestresource", "mytestresource1"]

  # Api Gateway Method
    method_enabled = true
    http_methods   = ["GET", "GET"]

  # Api Gateway Integration
    integration_types        = ["MOCK", "AWS_PROXY"]
    integration_http_methods = ["POST", "POST"]
    uri                      = ["", "arn:aws:apigateway:eu-west-1:lambda:path/2015-03-31/functions/arn:aws:lambda:eu-west-1:xxxxxxxxxx:function:test/invocations"]
    integration_request_parameters = [{
      "integration.request.header.X-Authorization" = "'static'"
    }, {}]
    request_templates = [{
      "application/xml" = <<EOF
  {
     "body" : $input.json('$')
  }
  EOF
    }, {}]

  # Api Gateway Method Response
    status_codes = [200, 200]
    response_models = [{ "application/json" = "Empty" }, {}]
    response_parameters = [{ "method.response.header.X-Some-Header" = true }, {}]

  # Api Gateway Integration Response
    integration_response_parameters = [{ "method.response.header.X-Some-Header" = "integration.response.header.X-Some-Other-Header" }, {}]
    response_templates = [{
      "application/xml" = <<EOF
  #set($inputRoot = $input.path('$'))
  <?xml version="1.0" encoding="UTF-8"?>
  <message>
      $inputRoot.body
  </message>
  EOF
    }, {}]

  # Api Gateway Deployment
    deployment_enabled = true
    stage_name         = "deploy"

  # Api Gateway Stage
    stage_enabled = true
    stage_names   = ["qa", "dev"]

  # Api Gateway Client Certificate
    cert_enabled     = true
    cert_description = "clouddrove"

  # Api Gateway Authorizer
    authorizer_count                = 2
    authorizer_names                = ["test", "test1"]
    authorizer_uri                  = ["arn:aws:apigateway:eu-west-1:lambda:path/2015-03-31/functions/arn:aws:lambda:eu-west-1:xxxxxxxxxx:function:test/invocations", "arn:aws:apigateway:eu-west-1:lambda:path/2015-03-31/functions/arn:aws:lambda:eu-west-1:xxxxxxxxxx:function:test/invocations"]
    authorizer_credentials          = ["arn:aws:iam::xxxxxxxxxx:role/lambda-role", "arn:aws:iam::xxxxxxxxxx:role/lambda-role"]
    identity_sources                = ["method.request.header.Authorization", "method.request.header.Authorization"]
    identity_validation_expressions = ["sfdgfhghrfdsdas", ""]
    authorizer_types                = ["TOKEN", "REQUEST"]

  # Api Gateway Gateway Response
    gateway_response_count = 2
    response_types         = ["UNAUTHORIZED", "RESOURCE_NOT_FOUND"]
    gateway_status_codes   = ["401", "404"]

  # Api Gateway Model
    model_count   = 2
    model_names   = ["test", "test1"]
    content_types = ["application/json", "application/json"]

  # Api Gateway Api Key
    key_count = 2
    key_names = ["test", "test1"]
  }

Inputs

Name Description Type Default Required
api_key_requireds Specify if the method requires an API key. list(any) [] no
api_key_source The source of the API key for requests. Valid values are HEADER (default) and AUTHORIZER. string "HEADER" no
api_log_enabled Whether to enable log for rest api. bool false no
api_policy The policy document. any null no
attributes Additional attributes (e.g. 1). list(any) [] no
authorization_scopes The authorization scopes used when the authorization is COGNITO_USER_POOLS. list(any) [] no
authorizations The type of authorization used for the method (NONE, CUSTOM, AWS_IAM, COGNITO_USER_POOLS). list(any) [] no
authorizer_count Number of count to create Authorizers for api. number 0 no
authorizer_credentials The credentials required for the authorizer. To specify an IAM Role for API Gateway to assume, use the IAM Role ARN. list(any) [] no
authorizer_ids The authorizer id to be used when the authorization is CUSTOM or COGNITO_USER_POOLS. list(any) [] no
authorizer_names The name of the authorizer. list(any) [] no
authorizer_result_ttl_in_seconds The TTL of cached authorizer results in seconds. Defaults to 300. list(any) [] no
authorizer_types The type of the authorizer. Possible values are TOKEN for a Lambda function using a single authorization token submitted in a custom header, REQUEST for a Lambda function using incoming request parameters, or COGNITO_USER_POOLS for using an Amazon Cognito user pool. Defaults to TOKEN. list(any) [] no
authorizer_uri The authorizer's Uniform Resource Identifier (URI). This must be a well-formed Lambda function URI in the form of arn:aws:apigateway:{region}:lambda:path/{service_api}, e.g. arn:aws:apigateway:us-west-2:lambda:path/2015-03-31/functions/arn:aws:lambda:us-west-2:012345678912:function:my-function/invocations. list(any) [] no
binary_media_types The list of binary media types supported by the RestApi. By default, the RestApi supports only UTF-8-encoded text payloads. list(any)
[
"UTF-8-encoded"
]
no
cache_cluster_enableds Specifies whether a cache cluster is enabled for the stage. list(any) [] no
cache_cluster_sizes The size of the cache cluster for the stage, if enabled. Allowed values include 0.5, 1.6, 6.1, 13.5, 28.4, 58.2, 118 and 237. list(any) [] no
cache_key_parameters A list of cache key parameters for the integration. list(any) [] no
cache_namespaces The integration's cache namespace. list(any) [] no
cert_description The description of the client certificate. string "" no
cert_enabled Whether to create client certificate. bool false no
client_certificate_ids The identifier of a client certificate for the stage list(any) [] no
connection_ids The id of the VpcLink used for the integration. Required if connection_type is VPC_LINK. list(any) [] no
connection_types The integration input's connectionType. Valid values are INTERNET (default for connections through the public routable internet), and VPC_LINK (for private connections between API Gateway and a network load balancer in a VPC). list(any) [] no
content_handlings Specifies how to handle request payload content type conversions. Supported values are CONVERT_TO_BINARY and CONVERT_TO_TEXT. If this property is not defined, the request payload will be passed through from the method request to integration request without modification, provided that the passthroughBehaviors is configured to support payload pass-through. list(any) [] no
content_types The content type of the model. list(any) [] no
credentials The credentials required for the integration. For AWS integrations, 2 options are available. To specify an IAM Role for Amazon API Gateway to assume, use the role's ARN. To require that the caller's identity be passed through from the request, specify the string arn:aws:iam::*:user/*. list(any) [] no
deploy_description The description of the deployment. string "" no
deployment_enabled Whether to deploy rest api. bool false no
description The description of the REST API string "" no
descriptions The description of the stage. list(any) [] no
destination_arns ARN of the log group to send the logs to. Automatically removes trailing :* if present. list(any) [] no
documentation_versions The version of the associated API documentation. list(any) [] no
enabled Whether to create rest api. bool false no
enableds Specifies whether the API key can be used by callers. Defaults to true. list(any) [] no
environment Environment (e.g. prod, dev, staging). string "https://registry.terraform.io/modules/clouddrove/api-gateway/aws" no
formats The formatting and values recorded in the logs. list(any) [] no
gateway_response_count Number of count to create Gateway Response for api. number 0 no
gateway_response_parameters A map specifying the templates used to transform the response body. list(any) [] no
gateway_response_templates A map specifying the parameters (paths, query strings and headers) of the Gateway Response. list(any) [] no
gateway_status_codes The HTTP status code of the Gateway Response. list(any) [] no
http_methods The HTTP Method (GET, POST, PUT, DELETE, HEAD, OPTIONS, ANY). list(any) [] no
identity_sources The source of the identity in an incoming request. Defaults to method.request.header.Authorization. For REQUEST type, this may be a comma-separated list of values, including headers, query string parameters and stage variables - e.g. "method.request.header.SomeHeaderName,method.request.querystring.SomeQueryStringName". list(any) [] no
identity_validation_expressions A validation expression for the incoming identity. For TOKEN type, this value should be a regular expression. The incoming token from the client is matched against this expression, and will proceed if the token matches. If the token doesn't match, the client receives a 401 Unauthorized response. list(any) [] no
integration_http_methods The integration HTTP method (GET, POST, PUT, DELETE, HEAD, OPTIONs, ANY, PATCH) specifying how API Gateway will interact with the back end. Required if type is AWS, AWS_PROXY, HTTP or HTTP_PROXY. Not all methods are compatible with all AWS integrations. e.g. Lambda function can only be invoked via POST. list(any) [] no
integration_request_parameters A map of request query string parameters and headers that should be passed to the backend responder. For example: request_parameters = { "integration.request.header.X-Some-Other-Header" = "method.request.header.X-Some-Header" }. list(any) [] no
integration_response_parameters A map of response parameters that can be read from the backend response. For example: response_parameters = { "method.response.header.X-Some-Header" = "integration.response.header.X-Some-Other-Header" }. list(any) [] no
integration_types The integration input's type. Valid values are HTTP (for HTTP backends), MOCK (not calling any real backend), AWS (for AWS services), AWS_PROXY (for Lambda proxy integration) and HTTP_PROXY (for HTTP proxy integration). An HTTP or HTTP_PROXY integration with a connection_type of VPC_LINK is referred to as a private integration and uses a VpcLink to connect API Gateway to a network load balancer of a VPC. list(any) [] no
key_count Number of count to create key for api gateway. number 0 no
key_descriptions The API key description. Defaults to "Managed by Terraform". list(any) [] no
key_names The name of the API key. list(any) [] no
label_order Label order, e.g. name,application. list(any) [] no
managedby ManagedBy, eg 'CloudDrove'. string "[email protected]" no
method_enabled Whether to create stage for rest api. bool false no
minimum_compression_size Minimum response size to compress for the REST API. Integer between -1 and 10485760 (10MB). Setting a value greater than -1 will enable compression, -1 disables compression (default). number -1 no
model_count Number of count to create Model for api. number 0 no
model_descriptions The description of the model. list(any) [] no
model_names The name of the model. list(any) [] no
model_schemas The schema of the model in a JSON form. list [] no
name Name (e.g. app or cluster). string "" no
passthrough_behaviors The integration passthrough behavior (WHEN_NO_MATCH, WHEN_NO_TEMPLATES, NEVER). Required if request_templates is used. list(any) [] no
path_parts The last path segment of this API resource. list(any) [] no
provider_arns required for type COGNITO_USER_POOLS) A list of the Amazon Cognito user pool ARNs. Each element is of this format: arn:aws:cognito-idp:{region}:{account_id}:userpool/{user_pool_id}. list(any) [] no
repository Terraform current module repo string "https://github.com/clouddrove/terraform-aws-api-gateway" no
request_models A map of the API models used for the request's content type where key is the content type (e.g. application/json) and value is either Error, Empty (built-in models) or aws_api_gateway_model's name. list(any) [] no
request_parameters A map of request query string parameters and headers that should be passed to the integration. For example: request_parameters = {"method.request.header.X-Some-Header" = true "method.request.querystring.some-query-param" = true} would define that the header X-Some-Header and the query string some-query-param must be provided in the request. list(any) [] no
request_templates A map of the integration's request templates. list(any) [] no
request_validator_ids The ID of a aws_api_gateway_request_validator. list(any) [] no
response_content_handlings Specifies how to handle request payload content type conversions. Supported values are CONVERT_TO_BINARY and CONVERT_TO_TEXT. If this property is not defined, the response payload will be passed through from the integration response to the method response without modification. list(any) [] no
response_models A map of the API models used for the response's content type. list(any) [] no
response_parameters A map of response parameters that can be sent to the caller. For example: response_parameters = { "method.response.header.X-Some-Header" = true } would define that the header X-Some-Header can be provided on the response. list(any) [] no
response_templates A map specifying the templates used to transform the integration response body. list(any) [] no
response_types The response type of the associated GatewayResponse. list(any) [] no
schemas The schema of the model in a JSON form. list(any) [] no
stage_description The description of the stage. string "" no
stage_enabled Whether to create stage for rest api. bool false no
stage_name The name of the stage. If the specified stage already exists, it will be updated to point to the new deployment. If the stage does not exist, a new one will be created and point to this deployment. string "" no
stage_names The name of the stage. list(any) [] no
stage_variables A map that defines the stage variables. list(any) [] no
status_codes The HTTP status code. list(any) [] no
tags Additional tags (e.g. map(BusinessUnit,XYZ). map(any) {} no
target_arns The list of network load balancer arns in the VPC targeted by the VPC link. Currently AWS only supports 1 target. list(any) [] no
timeout_milliseconds Custom timeout between 50 and 29,000 milliseconds. The default value is 29,000 milliseconds. list(any) [] no
types Whether to create rest api. list(any)
[
"EDGE"
]
no
uri The input's URI. Required if type is AWS, AWS_PROXY, HTTP or HTTP_PROXY. For HTTP integrations, the URI must be a fully formed, encoded HTTP(S) URL according to the RFC-3986 specification . For AWS integrations, the URI should be of the form arn:aws:apigateway:{region}:{subdomain.service|service}:{path|action}/{service_api}. region, subdomain and service are used to determine the right endpoint. e.g. arn:aws:apigateway:eu-west-1:lambda:path/2015-03-31/functions/arn:aws:lambda:eu-west-1:012345678901:function:my-func/invocations. list(any) [] no
values The value of the API key. If not specified, it will be automatically generated by AWS on creation. list(any) [] no
variables A map that defines variables for the stage. map(any) {} no
vpc_endpoint_ids Set of VPC Endpoint identifiers. It is only supported for PRIVATE endpoint type. list(string)
[
""
]
no
vpc_link_count Number of count to create VPC Link for api. number 0 no
vpc_link_descriptions The description of the VPC link. list(any) [] no
vpc_link_names The name used to label and identify the VPC link. list(any) [] no
xray_tracing_enabled A mapping of tags to assign to the resource. list(any) [] no

Outputs

Name Description
execution_arn The Execution ARN of the REST API.
id The ID of the REST API.
tags A mapping of tags to assign to the resource.

Testing

In this module testing is performed with terratest and it creates a small piece of infrastructure, matches the output like ARN, ID and Tags name etc and destroy infrastructure in your AWS account. This testing is written in GO, so you need a GO environment in your system.

You need to run the following command in the testing folder:

  go test -run Test

Feedback

If you come accross a bug or have any feedback, please log it in our issue tracker, or feel free to drop us an email at [email protected].

If you have found it worth your time, go ahead and give us a ★ on our GitHub!

About us

At CloudDrove, we offer expert guidance, implementation support and services to help organisations accelerate their journey to the cloud. Our services include docker and container orchestration, cloud migration and adoption, infrastructure automation, application modernisation and remediation, and performance engineering.

We are The Cloud Experts!


We ❤️ Open Source and you can check out our other modules to get help with your new Cloud ideas.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].