Skip to content

Instantly share code, notes, and snippets.

@wolfeidau
Created March 1, 2023 21:23
Show Gist options
  • Save wolfeidau/8df35611924d6f04a009618141e5f959 to your computer and use it in GitHub Desktop.
Save wolfeidau/8df35611924d6f04a009618141e5f959 to your computer and use it in GitHub Desktop.
Tags lister
package main
import (
"context"
"encoding/json"
"fmt"
"log"
"github.com/aws/aws-sdk-go-v2/config"
"github.com/aws/aws-sdk-go-v2/service/resourcegroupstaggingapi"
)
func main() {
ctx := context.Background()
cfg, err := config.LoadDefaultConfig(ctx)
if err != nil {
log.Fatalf("unable to load SDK config, %v", err)
}
// Using the Config value, create the DynamoDB client
svc := resourcegroupstaggingapi.NewFromConfig(cfg)
res, err := svc.GetResources(ctx, &resourcegroupstaggingapi.GetResourcesInput{})
if err != nil {
log.Fatalf("unable to search resources, %v", err)
}
for _, res := range res.ResourceTagMappingList {
data, err := json.Marshal(res)
if err != nil {
log.Fatalf("unable to marshal json, %v", err)
}
fmt.Println(string(data))
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment