Skip to content
This repository was archived by the owner on Oct 15, 2024. It is now read-only.
Merged
Changes from 1 commit
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
62 changes: 62 additions & 0 deletions resources/elasticache-cacheparametergroups.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
package resources

import (
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/session"
"github.com/aws/aws-sdk-go/service/elasticache"
)

type ElasticacheCacheParameterGroup struct {
svc *elasticache.ElastiCache
groupName *string
}

func init() {
register("ElasticacheCacheParameterGroup", ListElasticacheCacheParameterGroups)
}

func ListElasticacheCacheParameterGroups(sess *session.Session) ([]Resource, error) {
svc := elasticache.New(sess)
var resources []Resource

params := &elasticache.DescribeCacheParameterGroupsInput{MaxRecords: aws.Int64(100)}

for {
resp, err := svc.DescribeCacheParameterGroups(params)
if err != nil {
return nil, err
}

for _, cacheParameterGroup := range resp.CacheParameterGroups {
resources = append(resources, &ElasticacheCacheParameterGroup{
svc: svc,
groupName: cacheParameterGroup.CacheParameterGroupName,
})
}

if resp.Marker == nil {
break
}

params.Marker = resp.Marker
}

return resources, nil
}

func (i *ElasticacheCacheParameterGroup) Remove() error {
params := &elasticache.DeleteCacheParameterGroupInput{
CacheParameterGroupName: i.groupName,
}

_, err := i.svc.DeleteCacheParameterGroup(params)
if err != nil {
return err
}

return nil
}

func (i *ElasticacheCacheParameterGroup) String() string {
return *i.groupName
}