-
Hi, Thanks for putting this example repo together! What's here makes a lot of sense for deploying environment specific resources to each environment. However, the question I have is how would you suggest we handle global specific resources? For example, in AWS I have say a Dev account, and a Prod account. Dev and Staging resources are applied to the Dev account, and Prod resources are deployed to the Prod account. Each driven off of chaneges to the respective git branches. That all makes sense. However, I also have a 'Global Resources' account which manages things like Route53, ECR, etc - all things which don't naturally belong to any given environment, but are rather shared amongst them all. How do you suggest I manage this account/resources? Maybe a separate repo for these? Thanks for your help/suggestions! Simon |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
@sjbarnett Excellent question :) We have The great thing about terraform is that even though you'll create a separate environment for "Global Resources", you'll still be able to make references to outputs of the glb stack, see terraform_remote_state datasource. Please note that it's not possible to use direct references to Resources and Modules, only to dedicated outputs (as shown below). So go ahead and create another branch for In the resource "aws_route53_record" "www" {
zone_id = aws_route53_zone.primary.zone_id
name = "www.example.com"
type = "A"
ttl = "300"
records = [aws_eip.lb.public_ip]
}
output "route53_www_name" {
value = aws_route53_record.www.name
}
output "route53_www_fqdn" {
value = aws_route53_record.www.fqdn
} In standard environments (dev, stg, prd) data "terraform_remote_state" "global" {
backend = "s3"
config {
bucket = "tfmultienv-state-glb"
key = "terraform.tfstate"
region = "eu-west-1"
}
}
locals {
route53_www_name = data.terraform_remote_state.global.route53_www_name
route53_www_fqdn = data.terraform_remote_state.global.route53_www_fqdn
} |
Beta Was this translation helpful? Give feedback.
@sjbarnett Excellent question :)
We have
dev
,stg
andprd
which means "resources per environment" as you said. Creating "Global Resources" as you mentioned is something that requires a separate environment, such asglb
(or something like that).The great thing about terraform is that even though you'll create a separate environment for "Global Resources", you'll still be able to make references to outputs of the glb stack, see terraform_remote_state datasource. Please note that it's not possible to use direct references to Resources and Modules, only to dedicated outputs (as shown below).
So go ahead and create another branch for
glb
with Route53 records, and then import these records to …