Skip to content

Instantly share code, notes, and snippets.

@brandocorp
Created July 10, 2023 20:51
Show Gist options
  • Save brandocorp/a3944c9d239aa29e616d4c861a5ae19c to your computer and use it in GitHub Desktop.
Save brandocorp/a3944c9d239aa29e616d4c861a5ae19c to your computer and use it in GitHub Desktop.
terraform {
backend "local" {}
required_providers {
aws = {
source = "hashicorp/aws"
}
}
}
data "terraform_remote_state" "arc" {
backend = "local"
config = {
path = "../arc/terraform.tfstate"
}
}
data "aws_route53_zone" "environment" {
name = "brandon-raabe.sbx.hashidemos.io"
}
resource "aws_route53_record" "iad" {
name = "demo-iad.${data.aws_route53_zone.environment.name}"
type = "A"
ttl = 30
zone_id = data.aws_route53_zone.environment.zone_id
records = [
"10.9.8.7",
]
}
resource "aws_route53_record" "pdx" {
name = "demo-pdx.${data.aws_route53_zone.environment.name}"
type = "A"
ttl = 30
zone_id = data.aws_route53_zone.environment.zone_id
records = [
"192.168.144.120",
]
}
resource "aws_route53_record" "global_iad" {
name = "demo.${data.aws_route53_zone.environment.name}"
type = "CNAME"
ttl = 20
zone_id = data.aws_route53_zone.environment.zone_id
records = [
aws_route53_record.iad.name,
]
set_identifier = "iad"
health_check_id = data.terraform_remote_state.arc.outputs.demo_health_check_iad
failover_routing_policy {
type = "PRIMARY"
}
}
resource "aws_route53_record" "global_pdx" {
name = "demo.${data.aws_route53_zone.environment.name}"
type = "CNAME"
ttl = 20
zone_id = data.aws_route53_zone.environment.zone_id
records = [
aws_route53_record.pdx.name,
]
set_identifier = "pdx"
health_check_id = data.terraform_remote_state.arc.outputs.demo_health_check_pdx
failover_routing_policy {
type = "SECONDARY"
}
}
terraform {
backend "local" {}
required_providers {
aws = {
source = "hashicorp/aws"
}
}
}
resource "aws_route53recoverycontrolconfig_cluster" "demo" {
name = "brandonraabe"
}
resource "aws_route53recoverycontrolconfig_control_panel" "demo" {
name = "DemoControlPanel"
cluster_arn = aws_route53recoverycontrolconfig_cluster.demo.arn
}
resource "aws_route53recoverycontrolconfig_routing_control" "demo_iad" {
name = "DemoServiceIAD"
cluster_arn = aws_route53recoverycontrolconfig_cluster.demo.arn
control_panel_arn = aws_route53recoverycontrolconfig_control_panel.demo.arn
}
resource "aws_route53recoverycontrolconfig_routing_control" "demo_pdx" {
name = "DemoServicePDX"
cluster_arn = aws_route53recoverycontrolconfig_cluster.demo.arn
control_panel_arn = aws_route53recoverycontrolconfig_control_panel.demo.arn
}
resource "aws_route53_health_check" "demo_iad" {
type = "RECOVERY_CONTROL"
routing_control_arn = aws_route53recoverycontrolconfig_routing_control.demo_iad.arn
tags = {
Name = "demo-hc-iad"
}
}
resource "aws_route53_health_check" "demo_pdx" {
type = "RECOVERY_CONTROL"
routing_control_arn = aws_route53recoverycontrolconfig_routing_control.demo_pdx.arn
tags = {
Name = "demo-hc-pdx"
}
}
output "demo_health_check_iad" {
value = aws_route53_health_check.demo_iad.id
}
output "demo_health_check_pdx" {
value = aws_route53_health_check.demo_pdx.id
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment