0

Is there a way to get around the fact that there is not no data object defined for an aws_route53_record?

I am using the AWS Parameters Manager to store the object ID's of the resources that I want to share across different projects. In a static Terraform project, I create the shared resources, and then I save the magic ID's of the shared resources to the AWS Parameters Manager.

Then, in each of the sharing projects, I use data objects to retrieve the AWS parameter values, and then I pull in the shared AWS resources.

Essentially, using just Terraform, I am trying to do the equivalent of the following:

terraform import module.networking.aws_route53_zone.example_dom EXAMPLEZONEID
terraform import module.networking.aws_route53_record.myproject_example_dom EXAMPLEZONEID_myproject.example.dom_A

Ideally, I would like to do the following

data "aws_ssm_parameter" "route53_zone_example" { name = local.route53_zone_example_ssm_lookup }
data "aws_ssm_parameter" "route53_zone_record_myproject" { name = local.route53_zone_record_myproject_ssm_lookup }

data "aws_route53_zone" "example_dom" { zone_id = data.aws_ssm_parameter.route53_zone_example.value }
data "aws_route53_record" "myproject_example_dom" { id = data.route53_zone_record_myproject.value }

Unfortunately, that produces the expected response

The provider hashicorp/aws does not support data source "aws_route53_record".

Again, what I am looking for a pure Terraform solution, one that does not require that I copy the resource definitions to each of the sharing projects.

A. Rick
  • 649
  • 5
  • 11
  • Instead of querying the AWS route53 API, could you just do a DNS lookup instead? https://registry.terraform.io/providers/hashicorp/dns/latest/docs/data-sources/dns_a_record_set – jordanm Sep 09 '22 at 14:29
  • 1
    What *specifically* do you need to access on the `aws_route53_record`? If you just need the DNS address to pass into some other resource, why not just store it as a string? – Mark B Sep 09 '22 at 14:30
  • The suggestion from Mark B to just store the DNS address as a string works well. It got me past the most obvious need, which is the DNS address that the DNS zone record points to. Other than that, there really isn't much else that the DNS record has of interest. @MarkB, if you add that as an answer, I will be glad to 'accept' it. – A. Rick Sep 16 '22 at 15:06

1 Answers1

1

If you just need the DNS address to pass into some other resource, I suggest storing that as a string.

Mark B
  • 183,023
  • 24
  • 297
  • 295