Skip to content

Commit

Permalink
feat: add enrichment rule from ec2 to host
Browse files Browse the repository at this point in the history
  • Loading branch information
ansgarschulte committed Jul 8, 2024
1 parent b82a069 commit d79988e
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 0 deletions.
1 change: 1 addition & 0 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ type Specification struct {
// Simulate Enrichments
EnrichmentHostToContainerEnabled bool `json:"enrichmentHostToContainerEnabled" split_words:"true" required:"false" default:"false"`
EnrichmentContainerToHostEnabled bool `json:"enrichmentContainerToHostEnabled" split_words:"true" required:"false" default:"false"`
EnrichmentEC2ToHostEnabled bool `json:"enrichmentEC2ToHostEnabled" split_words:"true" required:"false" default:"false"`

// discovery delay in ms
DiscoveryDelayInMs int `json:"discoveryDelayInMs" split_words:"true" required:"false" default:"0"`
Expand Down
50 changes: 50 additions & 0 deletions extloadtest/enrichment_rule.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ func (d *ltEnrichmentRuleProvider) DescribeEnrichmentRules() []discovery_kit_api
if config.Config.EnrichmentContainerToHostEnabled {
result = append(result, getContainerToHostEnrichmentRule())
}
if config.Config.EnrichmentEC2ToHostEnabled {
result = append(result, getEC2ToHostEnrichmentRule())
}
return result
}

Expand Down Expand Up @@ -78,3 +81,50 @@ func getContainerToHostEnrichmentRule() discovery_kit_api.TargetEnrichmentRule {
},
}
}
func getEC2ToHostEnrichmentRule() discovery_kit_api.TargetEnrichmentRule {
return discovery_kit_api.TargetEnrichmentRule{
Id: "com.steadybit.extension_loadtest.ec2-to-host",
Version: extbuild.GetSemverVersionStringOrUnknown(),
Src: discovery_kit_api.SourceOrDestination{
Type: "com.steadybit.extension_aws.ec2-instance",
Selector: map[string]string{
"aws-ec2.hostname.internal": "${dest.host.hostname}",
},
},
Dest: discovery_kit_api.SourceOrDestination{
Type: "com.steadybit.extension_host.host",
Selector: map[string]string{
"host.hostname": "${src.aws-ec2.hostname.internal}",
},
},
Attributes: []discovery_kit_api.Attribute{
{
Matcher: discovery_kit_api.Equals,
Name: "aws.account",
}, {
Matcher: discovery_kit_api.Equals,
Name: "aws.region",
},
{
Matcher: discovery_kit_api.Equals,
Name: "aws.zone",
},
{
Matcher: discovery_kit_api.Equals,
Name: "aws-ec2.arn",
},
{
Matcher: discovery_kit_api.Equals,
Name: "aws-ec2.instance.id",
},
{
Matcher: discovery_kit_api.Equals,
Name: "aws-ec2.instance.name",
},
{
Matcher: discovery_kit_api.StartsWith,
Name: "aws-ec2.label.",
},
},
}
}

0 comments on commit d79988e

Please sign in to comment.