Skip to content

Commit

Permalink
Merge branch 'develop' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
Azanul committed Feb 28, 2024
2 parents 7f81ccb + 1db81b3 commit 0b2849f
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 1 deletion.
5 changes: 4 additions & 1 deletion policy.json
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,10 @@
"lambda:ListTags",
"es:ListDomainNames",
"es:DescribeDomains",
"s3:ListAllMyBuckets"
"s3:ListAllMyBuckets",
"secretsmanager:ListSecrets",
"datasync:ListAgents",
"cloudtrail:ListTrails"
],
"Resource": "*"
}
Expand Down
6 changes: 6 additions & 0 deletions providers/aws/aws.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,12 @@ import (
"github.com/tailwarden/komiser/providers"
"github.com/tailwarden/komiser/providers/aws/apigateway"
"github.com/tailwarden/komiser/providers/aws/cloudfront"
"github.com/tailwarden/komiser/providers/aws/cloudtrail"
"github.com/tailwarden/komiser/providers/aws/cloudwatch"
"github.com/tailwarden/komiser/providers/aws/codebuild"
"github.com/tailwarden/komiser/providers/aws/codecommit"
"github.com/tailwarden/komiser/providers/aws/codedeploy"
"github.com/tailwarden/komiser/providers/aws/datasync"
"github.com/tailwarden/komiser/providers/aws/dynamodb"
"github.com/tailwarden/komiser/providers/aws/ec2"
"github.com/tailwarden/komiser/providers/aws/ecr"
Expand All @@ -36,6 +38,7 @@ import (
"github.com/tailwarden/komiser/providers/aws/redshift"
"github.com/tailwarden/komiser/providers/aws/route53"
"github.com/tailwarden/komiser/providers/aws/s3"
"github.com/tailwarden/komiser/providers/aws/secretsmanager"
"github.com/tailwarden/komiser/providers/aws/servicecatalog"
"github.com/tailwarden/komiser/providers/aws/sns"
"github.com/tailwarden/komiser/providers/aws/sqs"
Expand Down Expand Up @@ -117,6 +120,9 @@ func listOfSupportedServices() []providers.FetchDataFunction {
lightsail.VPS,
neptune.Clusters,
route53.HostedZones,
cloudtrail.Trails,
datasync.Agents,
secretsmanager.Secrets,
}
}

Expand Down
48 changes: 48 additions & 0 deletions providers/aws/secretsmanager/secrets.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package secretsmanager

import (
"context"
"fmt"
"time"

"github.com/aws/aws-sdk-go-v2/service/secretsmanager"
log "github.com/sirupsen/logrus"
"github.com/tailwarden/komiser/models"
"github.com/tailwarden/komiser/providers"
)

func Secrets(ctx context.Context, client providers.ProviderClient) ([]models.Resource, error) {
var config secretsmanager.ListSecretsInput
resources := make([]models.Resource, 0)
neptuneClient := secretsmanager.NewFromConfig(*client.AWSClient)

output, err := neptuneClient.ListSecrets(ctx, &config)
if err != nil {
return resources, err
}

for _, secret := range output.SecretList {
secretName := ""
if secret.Name != nil {
secretName = *secret.Name
}
resources = append(resources, models.Resource{
Provider: "AWS",
Account: client.Name,
Service: "Secret",
Region: client.AWSClient.Region,
ResourceId: *secret.ARN,
Name: secretName,
FetchedAt: time.Now(),
Link: fmt.Sprintf("https://%s.console.aws.amazon.com/secretsmanager/secret?name=%s&region=%s", client.AWSClient.Region, secretName, client.AWSClient.Region),
})
}
log.WithFields(log.Fields{
"provider": "AWS",
"account": client.Name,
"region": client.AWSClient.Region,
"service": "Secret",
"resources": len(resources),
}).Info("Fetched resources")
return resources, nil
}

0 comments on commit 0b2849f

Please sign in to comment.