Question regarding the data Source aws_rds_clusters.
Let say I have a global rds cluster, with 2 regions, 2 instances per region :
- Primary cluster in ca-central-1 → 1 writer and 1 reader instance
- Secondary cluster in eu-west-1 → 2 reader instances
Let say I failover the global database, now the eu-west-1 becomes the primary cluster and the ca-central-1 becomes the secondary cluster. The writer instance is now in eu-west-1.
From aws cli, I can run something like this :
aws rds describe-global-clusters --query 'GlobalClusters.GlobalClusterMembers[?IsWriter==true
Is there a way to query, using the data source, which is the primary cluster ?
It seems that the
hashicorp/aws provider does not currently have any data sources that wrap
rds:DescribeGlobalClusters, so I don’t think it will be possible to reproduce the query you showed using current capabilities of the provider.
I see a feature request here that seems related:
However, the documentation for the underlying API says that filtering “isn’t currently supported”, so this API only allows either fetching a single global cluster or fetching all global clusters defined in your account. I assume the AWS CLI command you showed must be applying that “query” argument client-side after fetching all of the clusters, which is not a capability the AWS provider typically exposes because it is potentially very expensive to enumerate all objects of a particular type just to return one of them.
It’s probably still worth mentioning your use-case in the linked issue to help the AWS provider team with prioritization, but I expect this is more likely to get implemented if the RDS team at AWS could be persuaded to add server-side filtering to this API so that it can work in a similar way to other data sources wrapping
Describe-prefixed operations in the EC2 and RDS APIs. If you have a way to send feature requests to AWS then it may help to do that too.
You are right, the --query returned everything and I filtered it with
I am new to TF and trying to understand what’s TF behavior / usage in case of DR.
Looks like I will check with our AWS team if they can submit an enhancement request for that API.
Thanks a lot!