Skip to content

verygood-ops/terraform-aws-global-accelerator

ย 
ย 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

21 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

AWS Global Accelerator Terraform module

This is a Terraform opinionated module that creates AWS Global Accelerator resources. The motivation for updating this module was the open issue terraform-aws-modules#3.

We have added the necessary changes to create any number of endpoint groups per listener, and on top of that, we have refactored the module to satisfy the input structure we want to follow as part of the CRDR project.

Usage

terraform {
  source = "github.com/verygood-ops/terraform-aws-global-accelerator?ref=INFRA-9844"
}

# Include all settings from the root terragrunt.hcl file
include {
  path = find_in_parent_folders()
}

generate "backend" {
  path      = "_terragrunt_generated_backend.tf"
  if_exists = "overwrite_terragrunt"
  contents  = <<-EOF
    terraform {
      backend "s3" {}
    }
  EOF
}

# ---------------------------------------------------------------------------------------------------------------------
# MODULE PARAMETERS
# These are the variables we have to pass in to use the module specified in the terragrunt configuration above
# ---------------------------------------------------------------------------------------------------------------------

locals {
  account_vars = read_terragrunt_config(find_in_parent_folders("account.hcl"))
}

inputs = {
  name = "hello-world-secrets-and-values"
  endpoint_groups = {
    "us-west-2" = {
      endpoints = [
        {
          endpoint_id = "arn:aws:elasticloadbalancing:us-west-2:883127560329:loadbalancer/net/hello-world-secrets-and-values/087e6c08cdd9ebf2"
          weight      = 60
        },
        {
          endpoint_id = "arn:aws:elasticloadbalancing:us-west-2:883127560329:loadbalancer/net/hello-world-secrets-and-values-0/1f4051e54f007844"
          weight      = 40
        },
      ]
      traffic_dial_percentage        = 100
      health_check_port              = 5555
      health_check_protocol          = "HTTP"
      health_check_path              = "/health"
      health_check_interval_seconds  = 10
      threshold_count                = 3
    },
    "us-east-2" = {
      endpoints               = []
      traffic_dial_percentage = 0
    }
  }

  listener_ports = {
    80 = 8080,
  }


  infra_environment      = local.account_vars.locals.infra_environment
  data_environment       = local.account_vars.locals.data_environment
  deployment_environment = "vault"

  product = "internal"
  service = "demo"
  tenant  = "NONE"
  team    = "team-infrastructure"
}

Examples

Examples codified under the examples are intended to give users references for how to use the module(s) as well as testing/validating changes to the source code of the module. If contributing to the project, please be sure to make any appropriate updates to the relevant examples to allow maintainers to test your changes and to keep the examples up to date for users. Thank you!

Requirements

Name Version
terraform >= 1.0
aws >= 4.61

Providers

Name Version
aws >= 4.61

Modules

No modules.

Resources

Name Type
aws_globalaccelerator_accelerator.this resource
aws_globalaccelerator_endpoint_group.this resource
aws_globalaccelerator_listener.this resource

Inputs

Name Description Type Default Required
create Controls if resources should be created (affects nearly all resources) bool true no
create_listeners Controls if listeners should be created (affects only listeners) bool true no
data_environment VGS data environment: sandbox|live etc string n/a yes
deployment_environment VGS deployment environment: vault|genpop string n/a yes
enabled Indicates whether the accelerator is enabled. Defaults to true. Valid values: true, false bool true no
endpoint_groups Map of endpoint groups configurations
map(object({
endpoints = list(object({
endpoint_id = string
weight = number
client_ip_preservation_enabled = optional(bool, true)
health_check_port = optional(number)
health_check_protocol = optional(string)
health_check_path = optional(string)
health_check_interval_seconds = optional(number)
threshold_count = optional(number)
}))
traffic_dial_percentage = number
health_check_port = optional(number)
health_check_protocol = optional(string)
health_check_path = optional(string)
health_check_interval_seconds = optional(number)
threshold_count = optional(number)
}))
n/a yes
endpoint_groups_timeouts Create, update, and delete timeout configurations for the endpoint groups map(string) {} no
flow_logs_enabled Indicates whether flow logs are enabled. Defaults to false bool false no
flow_logs_s3_bucket The name of the Amazon S3 bucket for the flow logs. Required if flow_logs_enabled is true string null no
flow_logs_s3_prefix The prefix for the location in the Amazon S3 bucket for the flow logs. Required if flow_logs_enabled is true string null no
infra_environment VGS infra environment: dev|prod etc string n/a yes
ip_address_type The value for the address type. Defaults to IPV4. Valid values: IPV4, DUAL_STACK string "IPV4" no
ip_addresses The IP addresses to use for BYOIP accelerators. If not specified, the service assigns IP addresses. Valid values: 1 or 2 IPv4 addresses list(string) [] no
listener_ports Map of listener ports (from_port to to_port) map(number) n/a yes
listeners_timeouts Create, update, and delete timeout configurations for the listeners map(string) {} no
name The name of the accelerator string "" no
product n/a string n/a yes
service n/a string n/a yes
tags A map of tags to add to all resources map(string) {} no
team n/a string n/a yes
tenant n/a string n/a yes

Outputs

Name Description
dns_name The DNS name of the accelerator
dual_stack_dns_name The DNS name that Global Accelerator creates that points to a dual-stack accelerator's four static IP addresses: two IPv4 addresses and two IPv6 addresses
endpoint_groups Map of endpoints created and their associated attributes
hosted_zone_id The Global Accelerator Route 53 zone ID that can be used to route an Alias Resource Record Set to the Global Accelerator
id The Amazon Resource Name (ARN) of the accelerator
ip_sets IP address set associated with the accelerator
listeners Map of listeners created and their associated attributes