Skip to content

Commit

Permalink
Track log groups (#390)
Browse files Browse the repository at this point in the history
* add fields to instance structs for tracking log groups

* update go-broker-tags version

* update aws-broker version

* update code to use shared tag helpers

* remove size constraint on openesarch log group ARNs
  • Loading branch information
markdboyd authored Dec 18, 2024
1 parent 41549a5 commit c4a6175
Show file tree
Hide file tree
Showing 10 changed files with 113 additions and 172 deletions.
15 changes: 1 addition & 14 deletions cmd/tasks/elasticache.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,19 +46,6 @@ func getElasticacheResourceTags(elasticacheClient elasticacheiface.ElastiCacheAP
return response.TagList, nil
}

func convertTagsToElasticacheTags(tags map[string]string) []*elasticache.Tag {
var elasticacheTags []*elasticache.Tag
for k, v := range tags {
tag := elasticache.Tag{
Key: aws.String(k),
Value: aws.String(v),
}

elasticacheTags = append(elasticacheTags, &tag)
}
return elasticacheTags
}

func doElasticacheResourceTagsContainGeneratedTags(rdsTags []*elasticache.Tag, generatedTags []*elasticache.Tag) bool {
for _, v := range generatedTags {
if slices.Contains([]string{"Created at", "Updated at"}, *v.Key) {
Expand Down Expand Up @@ -135,7 +122,7 @@ func reconcileElasticacheResourceTags(catalog *catalog.Catalog, db *gorm.DB, ela
return fmt.Errorf("error generating new tags for cluster %s: %s", redisInstance.ClusterID, err)
}

generatedElasticacheTags := convertTagsToElasticacheTags(generatedTags)
generatedElasticacheTags := redis.ConvertTagsToElasticacheTags(generatedTags)

err = processElasticacheResource(elasticacheClient, instanceArn, generatedElasticacheTags)
if err != nil {
Expand Down
15 changes: 1 addition & 14 deletions cmd/tasks/elasticsearch.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,19 +46,6 @@ func getOpensearchResourceTags(opensearchClient opensearchserviceiface.OpenSearc
return response.TagList, nil
}

func convertTagsToOpensearchTags(tags map[string]string) []*opensearchservice.Tag {
var opensearchTags []*opensearchservice.Tag
for k, v := range tags {
tag := opensearchservice.Tag{
Key: aws.String(k),
Value: aws.String(v),
}

opensearchTags = append(opensearchTags, &tag)
}
return opensearchTags
}

func doOpensearchResourceTagsContainGeneratedTags(rdsTags []*opensearchservice.Tag, generatedTags []*opensearchservice.Tag) bool {
for _, v := range generatedTags {
if slices.Contains([]string{"Created at", "Updated at"}, *v.Key) {
Expand Down Expand Up @@ -135,7 +122,7 @@ func reconcileOpensearchResourceTags(catalog *catalog.Catalog, db *gorm.DB, open
return fmt.Errorf("error generating new tags for domain %s: %s", elasticsearchInstance.Domain, err)
}

generatedOpensearchTags := convertTagsToOpensearchTags(generatedTags)
generatedOpensearchTags := elasticsearch.ConvertTagsToOpensearchTags(generatedTags)
err = processOpensearchResource(opensearchClient, instanceArn, generatedOpensearchTags)
if err != nil {
return err
Expand Down
28 changes: 13 additions & 15 deletions cmd/tasks/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,38 +3,36 @@ module github.com/cloud-gov/aws-broker/cmd/tasks
go 1.23.4

require (
github.com/18F/aws-broker v0.0.0-20241218165110-c3f2f35696e3
github.com/aws/aws-sdk-go v1.44.10
github.com/cloud-gov/go-broker-tags v0.0.0-20240112192542-8f1bb5859679
github.com/18F/aws-broker v0.0.0-20241218185015-41549a5e6c73
github.com/aws/aws-sdk-go v1.55.5
github.com/cloud-gov/go-broker-tags v0.0.0-20241218195254-24284a5c54ae
github.com/go-test/deep v1.1.0
github.com/jinzhu/gorm v1.9.16
golang.org/x/exp v0.0.0-20241215155358-4a5509556b9e
)

require (
code.cloudfoundry.org/lager v2.0.0+incompatible // indirect
filippo.io/edwards25519 v1.1.0 // indirect
github.com/cloudfoundry-community/go-cfclient/v3 v3.0.0-alpha.6 // indirect
github.com/codegangsta/inject v0.0.0-20150114235600-33e0aa1cb7c0 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/go-co-op/gocron v1.13.0 // indirect
github.com/go-co-op/gocron v1.37.0 // indirect
github.com/go-martini/martini v0.0.0-20170121215854-22fa46961aab // indirect
github.com/go-sql-driver/mysql v1.6.0 // indirect
github.com/golang/protobuf v1.5.3 // indirect
github.com/go-sql-driver/mysql v1.8.1 // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/jinzhu/inflection v1.0.0 // indirect
github.com/jmespath/go-jmespath v0.4.0 // indirect
github.com/kr/text v0.2.0 // indirect
github.com/lib/pq v1.10.5 // indirect
github.com/lib/pq v1.10.9 // indirect
github.com/martini-contrib/render v0.0.0-20150707142108-ec18f8345a11 // indirect
github.com/mattn/go-sqlite3 v1.14.12 // indirect
github.com/mattn/go-sqlite3 v1.14.24 // indirect
github.com/oxtoacart/bpool v0.0.0-20190530202638-03653db5a59c // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/robfig/cron/v3 v3.0.1 // indirect
github.com/stretchr/testify v1.8.4 // indirect
golang.org/x/net v0.23.0 // indirect
golang.org/x/oauth2 v0.16.0 // indirect
golang.org/x/sync v0.10.0 // indirect
google.golang.org/appengine v1.6.8 // indirect
google.golang.org/protobuf v1.33.0 // indirect
github.com/stretchr/testify v1.10.0 // indirect
go.uber.org/atomic v1.11.0 // indirect
golang.org/x/net v0.33.0 // indirect
golang.org/x/oauth2 v0.24.0 // indirect
gopkg.in/go-playground/validator.v8 v8.18.2 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
Expand Down
Loading

0 comments on commit c4a6175

Please sign in to comment.