Created
March 1, 2023 21:23
-
-
Save wolfeidau/8df35611924d6f04a009618141e5f959 to your computer and use it in GitHub Desktop.
Tags lister
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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