cloudquery / cq-provider-aws

CloudQuery Provider for AWS
https://cloudquery.io
Mozilla Public License 2.0
29 stars 40 forks source link

SNS Topics don't get their tags #803

Closed andrewthetechie closed 2 years ago

andrewthetechie commented 2 years ago

Describe the bug

aws_sns_topics table is not storing tags from the AWS SNS Topics

Expected Behavior

Tags for SNS Topics would be stored in the cloudquery database

Steps to Reproduce

Setup a SNS topic with a tag Fetch SNS topic resources using cloudquery Inspect the table schema + resources fetched and see the tag is not reflected

Possible Solution

https://github.com/aws/aws-sdk-go-v2/blob/a1ee023a21f3cfd5c85ddae881264dbedcd1dffc/service/sns/api_op_ListTagsForResource.go The go sdk supports the ListTagsForResource api call needed to pull tags

This would be similar to how SQS handles getting tags https://github.com/cloudquery/cq-provider-aws/blob/0173988c12a0ce54ec9865e9d8fea8ad354b3db9/resources/services/sqs/queues.go#L230

Provider and CloudQuery version

Version: 0.22.7 Commit: fb5a1447e0851d96af0fb7d522585bf78566ff3f Date: 2022-04-19T08:55:30Z provider "aws" { version = "v0.10.19" }

Additional Context

It seems like this might just be an omission as most other AWS resources store their tags

erezrokah commented 2 years ago

Hi @andrewthetechie, thanks for opening the issue and a great catch!

Would you like to submit a PR for the fix?

It will require:

  1. Adding the tags field here similar to here, as you mentioned
  2. Add the relevant migration here and here to add the tags column. The names for the migration files should be 28_v0.11.2.up.sql and 28_v0.11.2.down.sql. You can see an example on how to add a column here. The tags column type should probably be jsonb as here.
  3. Add the code to fetch the data based on the AWS SDK link you shared
  4. Run everything in debugging mode so see that it's working.

Bonus - add tags to our terraform files here so it is added to our testing environment.

andrewthetechie commented 2 years ago

@erezrokah I'll take a shot at it, but I don't write golang frequently so I may run into issues.

erezrokah commented 2 years ago

Thanks @andrewthetechie! I appreciate you looking into it. If you run into any problems let us know by commenting in the issue 🚀

bbernays commented 2 years ago

Closing as this issue was fixed and released