Skip to content

Commit

Permalink
chore: add vpc id/name to all resources in a vpc
Browse files Browse the repository at this point in the history
  • Loading branch information
ReuDa committed Jan 13, 2025
1 parent f35c524 commit 17e6265
Show file tree
Hide file tree
Showing 23 changed files with 314 additions and 183 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
- ignore ecs services and tasks with a tag `steadybit.com/discovery-disabled` set to `true`
- don't cache zones forever (for example removed permissions should lead to removed targets in the platform)
- include tags in the discovery of Lambda functions (requires new permission `tag:GetResources`)
- add vpc name to targets (requires new permission `ec2:DescribeVpcs`, can be disabled by `STEADYBIT_EXTENSION_DISCOVERY_DISABLED_VPC`)

## v2.3.6

Expand Down
20 changes: 11 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,24 +15,25 @@ our [Reliability Hub](https://hub.steadybit.com/extension/com.steadybit.extensio
| `STEADYBIT_EXTENSION_WORKER_THREADS` | | How many parallel workers should call aws apis (only used if `STEADYBIT_EXTENSION_ASSUME_ROLES` is used) | no | 1 |
| `STEADYBIT_EXTENSION_ASSUME_ROLES` | `aws.assumeRoles` | See detailed description below | no | |
| `STEADYBIT_EXTENSION_REGIONS` | `aws.regions` | See detailed description below | no | |
| `STEADYBIT_EXTENSION_DISCOVERY_DISABLED_EC2` | `aws.discovery.disabled.ec2` | Disable EC2-Discovery and all EC2 related definitions | no | false |
| `STEADYBIT_EXTENSION_DISCOVERY_DISABLED_EC2` | `aws.discovery.disabled.ec2` | Disable EC2-Discovery and all related definitions | no | false |
| `STEADYBIT_EXTENSION_DISCOVERY_INTERVAL_EC2` | | Discovery-Interval in seconds | no | 30 |
| `STEADYBIT_EXTENSION_DISCOVERY_DISABLED_ECS` | `aws.discovery.disabled.ecs` | Disable ECS-Discovery and all ECS related definitions | no | false |
| `STEADYBIT_EXTENSION_DISCOVERY_DISABLED_ECS` | `aws.discovery.disabled.ecs` | Disable ECS-Discovery and all related definitions | no | false |
| `STEADYBIT_EXTENSION_DISCOVERY_INTERVAL_ECS_TASK` | | Discovery-Interval in seconds | no | 30 |
| `STEADYBIT_EXTENSION_DISCOVERY_INTERVAL_ECS_SERVICE` | | Discovery-Interval in seconds | no | 30 |
| `STEADYBIT_EXTENSION_DISCOVERY_DISABLED_ELASTICACHE` | `aws.discovery.disabled.elasticache` | Disable Elasticache-Discovery and all Elasticache related definitions | no | true |
| `STEADYBIT_EXTENSION_DISCOVERY_DISABLED_ELASTICACHE` | `aws.discovery.disabled.elasticache` | Disable Elasticache-Discovery and all related definitions | no | true |
| `STEADYBIT_EXTENSION_DISCOVERY_INTERVAL_ELASTICACHE` | | Discovery-Interval in seconds | no | 30 |
| `STEADYBIT_EXTENSION_DISCOVERY_DISABLED_ELB` | `aws.discovery.disabled.elb` | Disable ELB-Discovery and all ECS related definitions | no | false |
| `STEADYBIT_EXTENSION_DISCOVERY_DISABLED_ELB` | `aws.discovery.disabled.elb` | Disable ELB-Discovery and all related definitions | no | false |
| `STEADYBIT_EXTENSION_DISCOVERY_INTERVAL_ELB_ALB` | | Discovery-Interval in seconds | no | 30 |
| `STEADYBIT_EXTENSION_DISCOVERY_DISABLED_FIS` | `aws.discovery.disabled.fis` | Disable FIS-Discovery and all FIS related definitions | no | false |
| `STEADYBIT_EXTENSION_DISCOVERY_DISABLED_FIS` | `aws.discovery.disabled.fis` | Disable FIS-Discovery and all related definitions | no | false |
| `STEADYBIT_EXTENSION_DISCOVERY_INTERVAL_FIS` | | Discovery-Interval in seconds | no | 300 |
| `STEADYBIT_EXTENSION_DISCOVERY_DISABLED_MSK` | `aws.discovery.disabled.msk` | Disable MSK-Discovery and all MSK related definitions | no | false |
| `STEADYBIT_EXTENSION_DISCOVERY_DISABLED_MSK` | `aws.discovery.disabled.msk` | Disable MSK-Discovery and all related definitions | no | false |
| `STEADYBIT_EXTENSION_DISCOVERY_INTERVAL_MSK` | | Discovery-Interval in seconds | no | 30 |
| `STEADYBIT_EXTENSION_DISCOVERY_DISABLED_LAMBDA` | `aws.discovery.disabled.lambda` | Disable Lambda-Discovery and all Lambda related definitions | no | false |
| `STEADYBIT_EXTENSION_DISCOVERY_DISABLED_LAMBDA` | `aws.discovery.disabled.lambda` | Disable Lambda-Discovery and all related definitions | no | false |
| `STEADYBIT_EXTENSION_DISCOVERY_INTERVAL_LAMBDA` | | Discovery-Interval in seconds | no | 60 |
| `STEADYBIT_EXTENSION_DISCOVERY_DISABLED_RDS` | `aws.discovery.disabled.rds` | Disable RDS-Discovery and all RDS related definitions | no | false |
| `STEADYBIT_EXTENSION_DISCOVERY_DISABLED_RDS` | `aws.discovery.disabled.rds` | Disable RDS-Discovery and all related definitions | no | false |
| `STEADYBIT_EXTENSION_DISCOVERY_INTERVAL_RDS` | | Discovery-Interval in seconds | no | 30 |
| `STEADYBIT_EXTENSION_DISCOVERY_DISABLED_ZONE` | `aws.discovery.disabled.zone` | Disable Zone-Discovery and all Zone related definitions | no | false |
| `STEADYBIT_EXTENSION_DISCOVERY_DISABLED_VPC` | `aws.discovery.disabled.vpc` | Disable VPC-Discovery and all related definitions | no | false |
| `STEADYBIT_EXTENSION_DISCOVERY_DISABLED_ZONE` | `aws.discovery.disabled.zone` | Disable Zone-Discovery and all related definitions | no | false |
| `STEADYBIT_EXTENSION_DISCOVERY_INTERVAL_ZONE` | | Discovery-Interval in seconds | no | 300 |
| `STEADYBIT_EXTENSION_ENRICH_EC2_DATA_FOR_TARGET_TYPES` | | These target types will be enriched with EC2 data. They must have the attribute specified by 'STEADYBIT_EXTENSION_ENRICH_EC2_DATA_MATCHER_ATTRIBUTE' for this | no | com.steadybit.extension_jvm.jvm-instance,com.steadybit.extension_container.container,com.steadybit.extension_kubernetes.kubernetes-deployment |
| `STEADYBIT_EXTENSION_ENRICH_EC2_DATA_MATCHER_ATTRIBUTE` | | Targets for EC2 Data enrichment will be matched by this attribute. | no | host.hostname |
Expand Down Expand Up @@ -73,6 +74,7 @@ by tweaking the `Resource` clause.
"ec2:DescribeAvailabilityZones",
"ec2:DescribeSubnets",
"ec2:DescribeNetworkAcls",
"ec2:DescribeVpcs",
"ec2:CreateNetworkAcl",
"ec2:CreateNetworkAclEntry",
"ec2:ReplaceNetworkAclAssociation",
Expand Down
2 changes: 1 addition & 1 deletion charts/steadybit-extension-aws/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
apiVersion: v2
name: steadybit-extension-aws
description: Steadybit AWS extension Helm chart for Kubernetes.
version: 2.1.23
version: 2.1.24
appVersion: v2.3.6
home: https://www.steadybit.com/
icon: https://steadybit-website-assets.s3.amazonaws.com/logo-symbol-transparent.png
Expand Down
2 changes: 2 additions & 0 deletions charts/steadybit-extension-aws/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ aws:
lambda: false
# aws.discovery.disabled.rds -- Disables RDS discovery and the related actions.
rds: false
# aws.discovery.disabled.vpc -- Disables VPC discovery and the related actions.
vpc: false
# aws.discovery.disabled.zone -- Disables AZ discovery and the related actions.
zone: false
attributes:
Expand Down
1 change: 1 addition & 0 deletions config/specification.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ type Specification struct {
DiscoveryDisabledRds bool `json:"discoveryDisabledRds" split_words:"true" required:"false" default:"false"`
DiscoveryDisabledZone bool `json:"discoveryDisabledZone" split_words:"true" required:"false" default:"false"`
DiscoveryIntervalEc2 int `json:"discoveryIntervalEc2" split_words:"true" required:"false" default:"30"`
DiscoveryDisabledVpc bool `json:"discoveryDisabledVpc" split_words:"true" required:"false" default:"false"`
DiscoveryIntervalEcsService int `json:"discoveryIntervalEcsService" split_words:"true" required:"false" default:"30"`
DiscoveryIntervalEcsTask int `json:"discoveryIntervalEcsTask" split_words:"true" required:"false" default:"30"`
DiscoveryIntervalElasticacheReplicationGroup int `json:"discoveryIntervalElasticacheReplicationGroup" split_words:"true" required:"false" default:"30"`
Expand Down
9 changes: 5 additions & 4 deletions extec2/availablity_zone_discovery.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ func (a *azDiscovery) Describe() discovery_kit_api.DiscoveryDescription {
func (a *azDiscovery) DescribeTarget() discovery_kit_api.TargetDescription {
return discovery_kit_api.TargetDescription{
Id: azTargetType,
Label: discovery_kit_api.PluralLabel{One: "Availability Zone", Other: "Availability Zones"},
Label: discovery_kit_api.PluralLabel{One: "Availability Zone", Other: "Availability Util"},
Category: extutil.Ptr("cloud"),
Version: extbuild.GetSemverVersionStringOrUnknown(),
Icon: extutil.Ptr(azIcon),
Expand All @@ -70,12 +70,13 @@ func (a *azDiscovery) DiscoverTargets(ctx context.Context) ([]discovery_kit_api.
}

func getAllAvailabilityZonesForAccount(account *utils.AwsAccess, ctx context.Context) ([]discovery_kit_api.Target, error) {
return getAllAvailabilityZones(utils.Zones, account, ctx), nil
_, _ = InitEc2UtilForAccount(account, ctx)
return getAllAvailabilityZonesFromCache(Util, account), nil
}

func getAllAvailabilityZones(zones utils.GetZonesUtil, account *utils.AwsAccess, ctx context.Context) []discovery_kit_api.Target {
func getAllAvailabilityZonesFromCache(getZonesUtil GetZonesUtil, account *utils.AwsAccess) []discovery_kit_api.Target {
result := make([]discovery_kit_api.Target, 0, 20)
for _, availabilityZone := range zones.GetZones(account, ctx, true) {
for _, availabilityZone := range getZonesUtil.GetZones(account) {
result = append(result, toAvailabilityZoneTarget(availabilityZone, account.AccountNumber))
}
return discovery_kit_commons.ApplyAttributeExcludes(result, config.Config.DiscoveryAttributesExcludesZone)
Expand Down
9 changes: 4 additions & 5 deletions extec2/availablity_zone_discovery_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
package extec2

import (
"context"
"github.com/aws/aws-sdk-go-v2/service/ec2/types"
"github.com/steadybit/discovery-kit/go/discovery_kit_api"
"github.com/steadybit/extension-aws/utils"
Expand All @@ -16,20 +15,20 @@ import (

func TestGetAllAvailabilityZones(t *testing.T) {
// Given
mockedApi := new(zoneMock)
mockedApi := new(ec2UtilMock)
mockedReturnValue := []types.AvailabilityZone{
{
ZoneName: discovery_kit_api.Ptr("eu-central-1b"),
RegionName: discovery_kit_api.Ptr("eu-central-1"),
ZoneId: discovery_kit_api.Ptr("euc1-az3"),
},
}
mockedApi.On("GetZones", mock.Anything, mock.Anything, mock.Anything).Return(mockedReturnValue)
mockedApi.On("GetZones", mock.Anything).Return(mockedReturnValue)

// When
targets := getAllAvailabilityZones(mockedApi, &utils.AwsAccess{
targets := getAllAvailabilityZonesFromCache(mockedApi, &utils.AwsAccess{
AccountNumber: "42",
}, context.Background())
})

// Then
assert.Equal(t, 1, len(targets))
Expand Down
Loading

0 comments on commit 17e6265

Please sign in to comment.