I've been splitting up my environment from everything in one account (the root/billing account) to individual
accounts for each of my environments.
Thanx to people here, I've been using "terraform_remote_state" to "export and import" the values between
the different parts. Works marvellously!
I've successfully created my "base/core" environment. That's the one with my authentication/authorization,
my Lambda functions, RDS instances, ElastiCache, SNS, SQS and all my Route53 zones.
But now I'm creating my test environment in another account. It needs to create a zone of it's own. And I
need to associate that zone with the VPCs in the other environments. It's this environments reverse
zone, so all instances in all VPCs need to be able to reverse lookup it's instances.
I'm seeing two solutions to this:
1. I create the zone in this account.
2. I create it in the "base/core" account.
It seems that TF is creating the zone in this account (point one). I'd prefer to create it in the "base/core" account,
that way I have all of the zones in one place, but I'm not at all "married" to the idea.
But either way, the problem I'm having is to associate VPCs in another ("remote" or "foreign" ?) account with this
zone.
* aws_route53_zone_association.test2core-jenkins: NotAuthorizedException: The VPC: vpc-aabbccdd has not authorized to associate with your hosted zone.
* aws_route53_record.test-fc2: AccessDenied: User: arn:aws:iam::ACCOUNT_ID_TEST_ENV:user/turbo is not authorized to access this resource
That is, the 'provider' I'm using in this directory/environment don't have access to associate a foreign VPC
with the zone created in this account nor updating the "main" (forward) zone in the "base/core" account.
For S3 I "simply" added a policy on the bucket(s) to allow access from a foreign account. But it seems you
can't do that for Route53.
Resource-Based Policies
Other services, such as Amazon S3, also support attaching permissions policies to resources. For example,
you can attach a policy to an S3 bucket to manage access permissions to that bucket. Amazon Route 53
doesn't support attaching policies to resources.
They talk about creating an IAM role for this, but I can I select an IAM role to use just for "one" job (or for some
resources), not all of it in TF?
There is a "assume_role" for the AWS provider and I thought about that before I started - have an account in
the "root/billing" account and a role with appropriate access to the "sub accounts" but couldn't get that to work
properly.
But I'm guessing that would be use for ALL resources anyway, not just for the Route53 ones, right?
Am I possibly overthinking this? Any suggestions on how to solve this?
PS. I seem to have the exact same problem with VPC peering connections, but that might be a discussion for
another day.