Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions plugins/source/aws/codegen/recipes/elasticache.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ func ElastiCacheResources() []*Resource {
Resolver: `schema.PathResolver("ARN")`,
Options: schema.ColumnCreationOptions{PrimaryKey: true},
},
{
Name: "tags",
Type: schema.TypeJSON,
Resolver: `resolveClusterTags`,
},
}...),
},
{
Expand Down
1 change: 1 addition & 0 deletions plugins/source/aws/docs/tables/aws_elasticache_clusters.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ The primary key for this table is **arn**.
|account_id|String|
|region|String|
|arn (PK)|String|
|tags|JSON|
|at_rest_encryption_enabled|Bool|
|auth_token_enabled|Bool|
|auth_token_last_modified_date|Timestamp|
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (

"github.com/aws/aws-sdk-go-v2/aws"
"github.com/aws/aws-sdk-go-v2/service/elasticache"
"github.com/aws/aws-sdk-go-v2/service/elasticache/types"
"github.com/cloudquery/cloudquery/plugins/source/aws/client"
"github.com/cloudquery/plugin-sdk/schema"
)
Expand All @@ -23,3 +24,16 @@ func fetchElasticacheClusters(ctx context.Context, meta schema.ClientMeta, paren
}
return nil
}

func resolveClusterTags(ctx context.Context, meta schema.ClientMeta, resource *schema.Resource, c schema.Column) error {
cluster := resource.Item.(types.CacheCluster)

svc := meta.(*client.Client).Services().Elasticache
response, err := svc.ListTagsForResource(ctx, &elasticache.ListTagsForResourceInput{
ResourceName: cluster.ARN,
})
if err != nil {
return err
}
return resource.Set(c.Name, client.TagsToMap(response.TagList))
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"testing"

"github.com/aws/aws-sdk-go-v2/service/elasticache"
"github.com/aws/aws-sdk-go-v2/service/elasticache/types"
"github.com/cloudquery/cloudquery/plugins/source/aws/client"
"github.com/cloudquery/cloudquery/plugins/source/aws/client/mocks"
"github.com/cloudquery/plugin-sdk/faker"
Expand All @@ -19,7 +20,13 @@ func buildElasticacheClusters(t *testing.T, ctrl *gomock.Controller) client.Serv
t.Fatal(err)
}

var ta types.Tag
if err = faker.FakeObject(&ta); err != nil {
t.Fatal(err)
}

mockElasticache.EXPECT().DescribeCacheClusters(gomock.Any(), gomock.Any(), gomock.Any()).Return(&output, nil)
mockElasticache.EXPECT().ListTagsForResource(gomock.Any(), &elasticache.ListTagsForResourceInput{ResourceName: output.CacheClusters[0].ARN}, gomock.Any()).Return(&elasticache.ListTagsForResourceOutput{TagList: []types.Tag{ta}}, nil)

return client.Services{
Elasticache: mockElasticache,
Expand Down