Skip to content

Leveraging internal ips of an AWS external application load balancer

Notifications You must be signed in to change notification settings

maxfortun/ec2_alb_private_hostname

Repository files navigation

ec2_alb_private_hostname

Associates a route53 hostname with private ips of an external load balancer.
Keeps private IPs in sync by monitoring CloudTrail for ENI changes and running a lambda on every change.

Usage

data "aws_vpc" "default" {
}

module "ec2_alb_private_hostname" {
    source = "git::https://github.com/maxfortun/ec2_alb_private_hostname.git"

    name                    = "external-load-balancer-name"
    log_retention_in_days   = "1"
    tags                    = {
        tag = "here"
    }

    region                  = "us-east-1"

    listener_arns           = aws_lb_listener.listener.*.arn

    zone_id                 = data.aws_route53_zone.svc.zone_id
    hostname_prefix         = "vir-lb-name-private"

	source_ips              = [ data.aws_vpc.default.cidr_block ]
}

Can be triggered manually by calling https://<load balancer hostname>/private-hostname/update.

Requirements

Name Version
terraform >= 0.12, < 2.0
aws >= 2.70

Providers

Name Version
archive n/a
aws >= 2.70
external n/a

Inputs

Name Description Type Default
hostname If only one hostname is needed specify hostname, otherwise use hostname_prefix. string ""
hostname_prefix If more than one hostname is needed specify hostname_prefix, otherwise use hostname. string ""
listener_arns List of application load balancer listeners arns to attach private hostnames to. list(string) n/a
log_retention_in_days Number of days to retain lambda logs. any n/a
name Load balancer name. any n/a
region AWS region. any n/a
source_ips List of source ips in cidr format that are allowed to access /private-hostname/update. list(string) n/a
tags Tags to assign to created resources. map(string) n/a
zone_id AWS Route53 Hosted Zone Id for private hostnames. any n/a

Outputs

Name Description
arn ARN of the Lambda function.
hostnames n/a

Modules

No modules.

Resources

Name Type
aws_cloudwatch_event_rule.ec2_alb_private_hostname resource
aws_cloudwatch_event_target.ec2_alb_private_hostname resource
aws_cloudwatch_log_group.ec2_alb_private_hostname resource
aws_iam_role.ec2_alb_private_hostname resource
aws_iam_role_policy.ec2_alb_private_hostname resource
aws_lambda_function.ec2_alb_private_hostname resource
aws_lambda_permission.ec2_alb_private_hostname-alb resource
aws_lambda_permission.ec2_alb_private_hostname-cloudwatch resource
aws_lb_listener_rule.ec2_alb_private_hostname resource
aws_lb_target_group.ec2_alb_private_hostname resource
aws_lb_target_group_attachment.ec2_alb_private_hostname resource
aws_route53_record.hostname resource
archive_file.ec2_alb_private_hostname data source
aws_iam_policy_document.ec2_alb_private_hostname-access data source
aws_iam_policy_document.ec2_alb_private_hostname-role data source
aws_route53_zone.svc data source
external_external.privateIPs data source

About

Leveraging internal ips of an AWS external application load balancer

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published