-
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.
Merge pull request #774 from tailwarden/develop
v3.0.15 release 🚀
- Loading branch information
Showing
10 changed files
with
196 additions
and
17 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
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
File renamed without changes.
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,73 @@ | ||
package ec2 | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
"time" | ||
|
||
log "github.com/sirupsen/logrus" | ||
|
||
"github.com/aws/aws-sdk-go-v2/aws" | ||
"github.com/aws/aws-sdk-go-v2/service/ec2" | ||
. "github.com/tailwarden/komiser/models" | ||
. "github.com/tailwarden/komiser/providers" | ||
) | ||
|
||
func VpcPeeringConnections(ctx context.Context, client ProviderClient) ([]Resource, error) { | ||
var config ec2.DescribeVpcPeeringConnectionsInput | ||
resources := make([]Resource, 0) | ||
ec2Client := ec2.NewFromConfig(*client.AWSClient) | ||
|
||
for { | ||
output, err := ec2Client.DescribeVpcPeeringConnections(ctx, &config) | ||
if err != nil { | ||
return resources, err | ||
} | ||
|
||
for _, vpcPeeringConnection := range output.VpcPeeringConnections { | ||
name := "" | ||
tags := make([]Tag, 0) | ||
for _, tag := range vpcPeeringConnection.Tags { | ||
if *tag.Key == "Name" { | ||
name = *tag.Value | ||
} | ||
tags = append(tags, Tag{ | ||
Key: *tag.Key, | ||
Value: *tag.Value, | ||
}) | ||
} | ||
|
||
resources = append(resources, Resource{ | ||
Provider: "AWS", | ||
Account: client.Name, | ||
Service: "VPC Peering Connection", | ||
Region: client.AWSClient.Region, | ||
Name: name, | ||
ResourceId: *vpcPeeringConnection.VpcPeeringConnectionId, | ||
FetchedAt: time.Now(), | ||
Cost: 0, | ||
Tags: tags, | ||
Link: fmt.Sprintf( | ||
"https:/%s.console.aws.amazon.com/vpc/home?region=%s#PeeringConnectionDetails:VpcPeeringConnectionId=%s", | ||
client.AWSClient.Region, | ||
client.AWSClient.Region, | ||
*vpcPeeringConnection.VpcPeeringConnectionId, | ||
), | ||
}) | ||
} | ||
|
||
if aws.ToString(output.NextToken) == "" { | ||
break | ||
} | ||
|
||
config.NextToken = output.NextToken | ||
} | ||
log.WithFields(log.Fields{ | ||
"provider": "AWS", | ||
"account": client.Name, | ||
"region": client.AWSClient.Region, | ||
"service": "VPC Peering Connection", | ||
"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
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,65 @@ | ||
package rds | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
"time" | ||
|
||
"github.com/aws/aws-sdk-go-v2/aws" | ||
"github.com/aws/aws-sdk-go-v2/service/rds" | ||
log "github.com/sirupsen/logrus" | ||
"github.com/tailwarden/komiser/models" | ||
"github.com/tailwarden/komiser/providers" | ||
) | ||
|
||
func Snapshots(ctx context.Context, client providers.ProviderClient) ([]models.Resource, error) { | ||
var config rds.DescribeDBSnapshotsInput | ||
resources := make([]models.Resource, 0) | ||
rdsClient := rds.NewFromConfig(*client.AWSClient) | ||
|
||
for { | ||
output, err := rdsClient.DescribeDBSnapshots(ctx, &config) | ||
if err != nil { | ||
return resources, err | ||
} | ||
|
||
for _, snapshot := range output.DBSnapshots { | ||
tags := make([]models.Tag, 0) | ||
for _, tag := range snapshot.TagList { | ||
tags = append(tags, models.Tag{ | ||
Key: *tag.Key, | ||
Value: *tag.Value, | ||
}) | ||
} | ||
|
||
_snapshotName := *snapshot.DBSnapshotIdentifier | ||
|
||
resources = append(resources, models.Resource{ | ||
Provider: "AWS", | ||
Account: client.Name, | ||
Service: "RDS Snapshot", | ||
Region: client.AWSClient.Region, | ||
ResourceId: *snapshot.DBSnapshotArn, | ||
Name: _snapshotName, | ||
FetchedAt: time.Now(), | ||
Tags: tags, | ||
Link: fmt.Sprintf("https://%s.console.aws.amazon.com/rds/home?region=%s#snapshot:id=%s", client.AWSClient.Region, client.AWSClient.Region, *snapshot.DBSnapshotIdentifier), | ||
}) | ||
} | ||
|
||
if aws.ToString(output.Marker) == "" { | ||
break | ||
} | ||
|
||
config.Marker = output.Marker | ||
} | ||
|
||
log.WithFields(log.Fields{ | ||
"provider": "AWS", | ||
"account": client.Name, | ||
"region": client.AWSClient.Region, | ||
"service": "RDS Snapshot", | ||
"resources": len(resources), | ||
}).Info("Fetched resources") | ||
return resources, nil | ||
} |