Add a data source for AWS DynamoDB table items. In combination with resource. aws_kms_external_key or resource.aws_kms_key and data.aws_kms_secrets, this new data source would offer a nice approach to using secret data in Terraform.
data "aws_dynamodb_table" "example" {
name = "example-name"
}
data "aws_dynamodb_table_item" "example" {
table_name = "${aws_dynamodb_table.example.name}"
hash_key = "${aws_dynamodb_table.example.hash_key}"
item_key = "item-primary-key"
}
I'm interested in working on this over the next few days, at least enough to get it going in a draft PR.
I've been looking into this a bit and I think I need a bit of help on how to proceed.
The problem I see is that all the existing data sources I've seen are defining a static schema containing more or less the fields of that type of resource which would be used in the output of the data source.
By definition a DynamoDB table item doesn't have a fixed schema, so we'll need to make this schema dynamic by querying the DynamoDB table resource that the item belongs to.
I haven't tried to code this yet but I'm struggling a bit with the idea of defining a schema by querying the item's DynamoDB table.
Any thoughts/suggestions would be more than welcome.
Hey @cristim, I'm happy to see someone looking at this! I've put together notes for the design of the aws_dynamodb_query and aws_dynamodb_table_item data sources.
As far as the schema goes, it seems you are thinking of DynamoDB schemas, but the schemas that are referenced in the Terraform are helpers that define the arguments, outputs, and types for the resource (or data source). You'll see these schemas referenced in pretty much every resource.
For these data sources, we'll want to mirror DynamoDB's GetItem and Query APIs. I've put all my notes in a Gist: https://gist.github.com/timoguin/e7dd5f495fcd5ba0537c0a6105c4fdba
I'm happy to collaborate and bounce some ideas/code around. I've wanted this feature for quite a while.
Is there any update on this? Any plans on it being worked on?
Most helpful comment
Is there any update on this? Any plans on it being worked on?