Skip to content

Instantly share code, notes, and snippets.

@ben-x
ben-x / multi-region-with-single-workload.load-balancer.tf
Last active September 1, 2024 02:07
Load balancer. Part of multi-region-with-single-workload project
resource "aws_lb_target_group" "central_app_tg" {
name = "central-app-tg"
port = var.app_port
protocol = "HTTP"
target_type = "ip"
ip_address_type = "ipv4"
tags = var.tags
vpc_id = aws_vpc.main.id
health_check {
@ben-x
ben-x / multi-region-with-single-workload.vpc.tf
Created August 25, 2024 19:45
vpc in secondary region. Part of multi-region-with-single-workload project
resource "aws_vpc" "main" {
cidr_block = var.cidr_blocks.vpc
enable_dns_support = true
enable_dns_hostnames = true
tags = merge(
var.tags,
{
"Name" = "vpc-eu-central-1"
}
@ben-x
ben-x / multi-region-with-single-workload.vpc-peering.tf
Created August 25, 2024 19:37
vpc-peering connection of two regions. Part of multi-region-with-single-workload project
module "vpc_peering_ca_west_1_eu_central_1" {
source = "../../../common-modules/aws-vpc-peering-connection"
allow_dns_resolution = true
name = "ca-west-1-eu-central-1-vpc-peering"
tags = var.tags
providers = {
aws.requester = aws.eu-central-1
aws.accepter = aws.ca-west-1
@ben-x
ben-x / multi-region-with-single-workload.app-fleet.tf
Last active August 25, 2024 19:38
Fleet of ec2 instance with lifecycle hooks. A part of multi-region-with-single-workload project
module "app_fleet" {
source = "../../../common-modules/aws-ec2-fleet"
name = "app-fleet"
tags = var.tags
ingress_rules = {
allow_app_port = {
cidr_blocks = [aws_vpc.main.cidr_block]
source_port = var.app_port