Skip to content

Commit

Permalink
Merge pull request #685 from tailwarden/develop
Browse files Browse the repository at this point in the history
Update Release v3.0.9
  • Loading branch information
eneskaya authored Mar 31, 2023
2 parents 2731527 + 1d49704 commit 84062bb
Show file tree
Hide file tree
Showing 7 changed files with 299 additions and 153 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
Geography,
Marker
} from 'react-simple-maps';
import Link from 'next/link';
import { DashboardCloudMapRegions } from './hooks/useCloudMap';
import { DashboardCloudMapTooltipProps } from './hooks/useCloudMapTooltip';

Expand Down Expand Up @@ -54,12 +55,7 @@ function DashboardCloudMapChart({
</Geographies>
{regionsAscendingByNumberOfResources &&
regionsAscendingByNumberOfResources.map((region, idx) => (
<a
key={idx}
href={`/inventory?region:IS:${region.label}`}
target="_blank"
rel="noreferrer"
>
<Link key={idx} href={`/inventory?region:IS:${region.label}`}>
<Marker
coordinates={[Number(region.longitude), Number(region.latitude)]}
onMouseEnter={e =>
Expand Down Expand Up @@ -87,7 +83,7 @@ function DashboardCloudMapChart({
strokeWidth={1.5}
/>
</Marker>
</a>
</Link>
))}
</ComposableMap>
);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { ChartData, ChartOptions } from 'chart.js';
import { Dispatch, SetStateAction, useState } from 'react';
import { useRouter } from 'next/router';
import formatNumber from '../../../../../utils/formatNumber';
import {
ResourcesManagerData,
Expand All @@ -23,6 +24,7 @@ function useResourcesManagerChart({
setQuery,
initialQuery
}: useResourcesManagerChartProps) {
const router = useRouter();
const colors = ['#FF9A87', '#6DB7FF', '#B6D3B4', '#FFB459', '#59ACAC'];

/* To be un-commented when 'view' is supported
Expand Down Expand Up @@ -78,10 +80,7 @@ function useResourcesManagerChart({
const clickedIndex = legendItem[0].index || 0;
const labels = legend.config.data.labels ?? [];

window.open(
`./inventory?${currentQuery}:IS:${labels[clickedIndex]}`,
'_blank'
);
router.push(`/inventory?${currentQuery}:IS:${labels[clickedIndex]}`);
},
aspectRatio: 2,
layout: {
Expand Down
2 changes: 1 addition & 1 deletion dashboard/components/navbar/Navbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ function Navbar() {
<div className="flex items-center gap-8 text-sm font-semibold text-black-400">
<Link href="/dashboard">
<Image
src="./assets/img/komiser.svg"
src="/assets/img/komiser.svg"
width={40}
height={40}
alt="Komiser logo"
Expand Down
3 changes: 2 additions & 1 deletion dashboard/next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ const nextConfig = {
swcMinify: true,
images: {
unoptimized: true
}
},
trailingSlash: true
};

module.exports = nextConfig;
355 changes: 215 additions & 140 deletions internal/api/v1/template.go

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions providers/aws/aws.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ func listOfSupportedServices() []providers.FetchDataFunction {
apigateway.Apis,
elasticache.Clusters,
cloudwatch.Alarms,
ec2.NetworkInterfaces,
cloudwatch.Dashboards,
ec2.ElasticIps,
}
Expand Down
74 changes: 74 additions & 0 deletions providers/aws/ec2/network_interfaces.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
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/aws/aws-sdk-go-v2/service/sts"
. "github.com/tailwarden/komiser/models"
. "github.com/tailwarden/komiser/providers"
)

func NetworkInterfaces(ctx context.Context, client ProviderClient) ([]Resource, error) {
var config ec2.DescribeNetworkInterfacesInput
resources := make([]Resource, 0)
ec2Client := ec2.NewFromConfig(*client.AWSClient)

stsClient := sts.NewFromConfig(*client.AWSClient)
stsOutput, err := stsClient.GetCallerIdentity(ctx, &sts.GetCallerIdentityInput{})
if err != nil {
return resources, err
}

accountId := stsOutput.Account

for {
output, err := ec2Client.DescribeNetworkInterfaces(ctx, &config)
if err != nil {
return resources, err
}

for _, iface := range output.NetworkInterfaces {
tags := make([]Tag, 0)
for _, tag := range iface.TagSet {
tags = append(tags, Tag{
Key: *tag.Key,
Value: *tag.Value,
})
}

resourceArn := fmt.Sprintf("arn:aws:ec2:%s:%s:network-interface/%s", client.AWSClient.Region, *accountId, *iface.NetworkInterfaceId)

resources = append(resources, Resource{
Provider: "AWS",
Account: client.Name,
Service: "Network Interface",
Region: client.AWSClient.Region,
ResourceId: resourceArn,
Cost: 0,
Name: *iface.NetworkInterfaceId,
FetchedAt: time.Now(),
Tags: tags,
Link: fmt.Sprintf("https:/%s.console.aws.amazon.com/ec2/home?region=%s#NetworkInterface:networkInterfaceId=%s", client.AWSClient.Region, client.AWSClient.Region, *iface.NetworkInterfaceId),
})
}
if aws.ToString(output.NextToken) == "" {
break
}

config.NextToken = output.NextToken
}
log.WithFields(log.Fields{
"provider": "AWS",
"account": client.Name,
"region": client.AWSClient.Region,
"service": "Network Interface",
"resources": len(resources),
}).Info("Fetched resources")
return resources, nil
}

0 comments on commit 84062bb

Please sign in to comment.