-
Notifications
You must be signed in to change notification settings - Fork 433
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Cloudtrail, SecretsManger and DataSync (#1353)
* feat: cloudtrail trails support Signed-off-by: Azanul <azanulhaque@gmail.com> * feat: secretsmanager secret support Signed-off-by: Azanul <azanulhaque@gmail.com> * fix: secretsmanager secret support Signed-off-by: Azanul <azanulhaque@gmail.com> * feat: datasync agent support Signed-off-by: Azanul <azanulhaque@gmail.com> * fix: secretsmanager spelling Signed-off-by: Azanul <azanulhaque@gmail.com> * fix: secretsmanager spelling Signed-off-by: Azanul <azanulhaque@gmail.com> * feat: add to supported service list Signed-off-by: Azanul <azanulhaque@gmail.com> * feat: add service policy Signed-off-by: Azanul <azanulhaque@gmail.com> --------- Signed-off-by: Azanul <azanulhaque@gmail.com>
- Loading branch information
Showing
7 changed files
with
175 additions
and
5 deletions.
There are no files selected for viewing
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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package cloudtrail | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
"time" | ||
|
||
"github.com/aws/aws-sdk-go-v2/service/cloudtrail" | ||
log "github.com/sirupsen/logrus" | ||
"github.com/tailwarden/komiser/models" | ||
"github.com/tailwarden/komiser/providers" | ||
) | ||
|
||
func Trails(ctx context.Context, client providers.ProviderClient) ([]models.Resource, error) { | ||
var config cloudtrail.ListTrailsInput | ||
resources := make([]models.Resource, 0) | ||
neptuneClient := cloudtrail.NewFromConfig(*client.AWSClient) | ||
|
||
output, err := neptuneClient.ListTrails(ctx, &config) | ||
if err != nil { | ||
return resources, err | ||
} | ||
|
||
for _, trail := range output.Trails { | ||
trailName := "" | ||
if trail.Name != nil { | ||
trailName = *trail.Name | ||
} | ||
resources = append(resources, models.Resource{ | ||
Provider: "AWS", | ||
Account: client.Name, | ||
Service: "Cloudtrail Trail", | ||
Region: client.AWSClient.Region, | ||
ResourceId: *trail.TrailARN, | ||
Name: trailName, | ||
FetchedAt: time.Now(), | ||
Link: fmt.Sprintf("https://%s.console.aws.amazon.com/cloudtrailv2/home?region=%s#/trails/%s/%s", client.AWSClient.Region, client.AWSClient.Region, *trail.TrailARN, trailName), | ||
}) | ||
} | ||
log.WithFields(log.Fields{ | ||
"provider": "AWS", | ||
"account": client.Name, | ||
"region": client.AWSClient.Region, | ||
"service": "Cloudtrail Trail", | ||
"resources": len(resources), | ||
}).Info("Fetched resources") | ||
return resources, nil | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package datasync | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
"time" | ||
|
||
"github.com/aws/aws-sdk-go-v2/service/datasync" | ||
log "github.com/sirupsen/logrus" | ||
"github.com/tailwarden/komiser/models" | ||
"github.com/tailwarden/komiser/providers" | ||
) | ||
|
||
func Agents(ctx context.Context, client providers.ProviderClient) ([]models.Resource, error) { | ||
var config datasync.ListAgentsInput | ||
resources := make([]models.Resource, 0) | ||
neptuneClient := datasync.NewFromConfig(*client.AWSClient) | ||
|
||
output, err := neptuneClient.ListAgents(ctx, &config) | ||
if err != nil { | ||
return resources, err | ||
} | ||
|
||
for _, agent := range output.Agents { | ||
agentName := "" | ||
if agent.Name != nil { | ||
agentName = *agent.Name | ||
} | ||
resources = append(resources, models.Resource{ | ||
Provider: "AWS", | ||
Account: client.Name, | ||
Service: "DataSync Agent", | ||
Region: client.AWSClient.Region, | ||
ResourceId: *agent.AgentArn, | ||
Name: agentName, | ||
FetchedAt: time.Now(), | ||
Link: fmt.Sprintf("https://%s.console.aws.amazon.com/datasync/home?region=%s#/agents", client.AWSClient.Region, client.AWSClient.Region), | ||
}) | ||
} | ||
log.WithFields(log.Fields{ | ||
"provider": "AWS", | ||
"account": client.Name, | ||
"region": client.AWSClient.Region, | ||
"service": "DataSync Agent", | ||
"resources": len(resources), | ||
}).Info("Fetched resources") | ||
return resources, nil | ||
} |
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
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®ion=%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 | ||
} |