Code Monkey home page Code Monkey logo

terraform-aws-vpc-endpoints's Introduction

terraform-aws-vpc-endpoints

This module provides an unified way to deploy vpc endpoints (interface & gateway).

Refer to the examples directory for more details.

VPC Endpoint - type Interface

You could find a complete list of AWS Services that integrate Interface VPC Endpoint here.

Each VPC Endpoint for a particular AWS Service have an unique identifier. Check the column Service name in the following link.

This identifier corresponds to the input variable id for the module.

The Interface VPC Endpoint is a VPC Endpoint implemented by the creation of ENI (Elastic Network Interface) inside the subnets where the VPC endpoint is associated with. Because there is ENI, it could be possible to restrict the flows by using security group. you can decide to let the module create the security group for you, or pass it as input to the module. Use create_security_group to true if you let the module generate the security group for you, or use security_group_ids to pass existent security groups. The inbound port should be opened for the https protocol.

locals {
    vpc_id                        = "vpc-0123456789"
    private_backend_subnets_ids   = ["subnet-0bd166bcc6917cc16","subnet-01b413241f1f69186","subnet-0159d8a30ce664786"] 
    private_backend_subnets_cidrs = ["172.31.16.0/20","172.31.0.0/20","172.31.32.0/20"] 
}

module "vpc-endpoints" {
  source  = "jparnaudeau/vpc-endpoints/aws"
  version = "1.0.0"

  # set the environment
  region         = var.region
  naming_pattern = "acme-dev-%s-%s"

  vpcendpoints_interfaces = [
    {
      id                    = "s3"
      vpc_id                = local.vpc_id
      subnet_ids            = local.private_backend_subnets_ids
      create_security_group = true
      security_group_ids    = []
      private_dns_enabled   = false
      allowed_cidr_blocks   = local.private_backend_subnets_cidrs
      inbound_ports         = ["443"]
      tags = {
        Component = "myapp"
      }
    },
    {
      id                    = "kms"
      vpc_id                = local.vpc_id
      subnet_ids            = local.private_backend_subnets_ids
      create_security_group = true
      security_group_ids    = []
      private_dns_enabled   = false
      allowed_cidr_blocks   = local.private_backend_subnets_cidrs
      inbound_ports         = ["443"]
      tags = {
        Component = "myapp"
      }
    },
  ]

VPC Endpoint - type Gateway

The Gateway VPC Endpoint is described in this link.

Gateway endpoints provide reliable connectivity to Amazon S3 and DynamoDB without requiring an internet gateway or a NAT device for your VPC. Gateway endpoints do not enable AWS PrivateLink.

It is implemented by the creation of an AWS Prefix List, directly used inside the route table of the subnets in which the VPC endpoint is attached with.

locals {
    vpc_id                         = "vpc-0123456789"
    private_backend_subnets_rt_ids = ["rtb-0e15c810631e634d6"]
}

module "vpc-endpoints" {
  source  = "jparnaudeau/vpc-endpoints/aws"
  version = "1.0.0"

  # set the environment
  region         = var.region
  naming_pattern = "acme-dev-%s-%s"

  vpcendpoints_gateways = [
    {
      id                  = "s3"
      vpc_id              = local.vpc_id
      private_dns_enabled = false
      route_table_ids     = local.private_backend_subnets_rt_ids
      tags = {
        Component = "myapp"
      }
    },
    {
      id                  = "dynamodb"
      vpc_id              = local.vpc_id
      private_dns_enabled = false
      route_table_ids     = local.private_backend_subnets_rt_ids
      tags = {
        Component = "myapp"
      }
    },
  ]

Requirements

Name Version
terraform >= 1.0.4
aws >= 4.0

Providers

Name Version
aws >= 4.0

Modules

No modules.

Resources

Name Type
aws_security_group.sg resource
aws_vpc_endpoint.vpce resource
aws_vpc_endpoint.vpce_gtw resource
aws_vpc_endpoint_route_table_association.rt_assoc resource
aws_vpc_endpoint_service.vpce_service data source
aws_vpc_endpoint_service.vpce_service_gtw data source

Inputs

Name Description Type Default Required
naming_pattern The naming pattern to apply for the name of the resource vpc_endpoint and security_group. Must contains 2 %s string "project-environment-%s-%s" no
region The AWS Region Id string "eu-west-3" no
tags a map of string containing the tags map(string) {} no
vpcendpoints_gateways a map of object for creating vpcendpoints type gatewy (s3,dynamodb,...)
list(object({
id = string
vpc_id = string
route_table_ids = list(string)
tags = map(string)
}))
[] no
vpcendpoints_interfaces a map of object for creating vpcendpoints type interface (s3,kms,sns,...)
list(object({
id = string
vpc_id = string
subnet_ids = list(string)
create_security_group = bool
security_group_ids = list(string)
private_dns_enabled = bool
allowed_cidr_blocks = list(string)
inbound_ports = list(string)
tags = map(string)
}))
[] no

Outputs

Name Description
vpc_endpoints_gateway_infos Informations regarding vpc endpoints type gateway
vpc_endpoints_interface_infos Informations regarding vpc endpoints type interface

terraform-aws-vpc-endpoints's People

Contributors

jparnaudeau avatar

Stargazers

Eduardo Rabelo avatar Alex avatar Mason Bivens avatar lfariasrj avatar Adam Shero avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.