Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add new fields to aws.autoscaling.group #3681

Merged
merged 2 commits into from
Apr 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion providers/aws/resources/aws.lr
Original file line number Diff line number Diff line change
Expand Up @@ -1031,7 +1031,7 @@ aws.autoscaling @defaults("groups") {
}

// AWS Auto Scaling group
private aws.autoscaling.group @defaults("name region") {
private aws.autoscaling.group @defaults("name region minSize maxSize") {
// ARN for the autoscaling group
arn string
// Name of the group
Expand Down Expand Up @@ -1060,6 +1060,14 @@ private aws.autoscaling.group @defaults("name region") {
maxInstanceLifetime int
// The desired size of the group
desiredCapacity int
// List of availability zones associated with the group
availabilityZones []string
// Indicates whether Capacity Rebalancing is enabled
capacityRebalance bool
// The duration of the default instance warmup, in seconds
defaultInstanceWarmup int
// The EC2 instances associated with the group
instances []aws.ec2.instance
}

// AWS Elastic Load Balancing
Expand Down
50 changes: 49 additions & 1 deletion providers/aws/resources/aws.lr.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions providers/aws/resources/aws.lr.manifest.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -303,15 +303,23 @@ resources:
The `aws.autoscaling.group` resource provides fields representing an individual AWS auto scaling group within the account. For usage, read the `aws.autoscaling` resource documentation.
fields:
arn: {}
availabilityZones:
min_mondoo_version: 9.0.0
capacityRebalance:
min_mondoo_version: 9.0.0
createdAt:
min_mondoo_version: 9.0.0
defaultCooldown:
min_mondoo_version: 9.0.0
defaultInstanceWarmup:
min_mondoo_version: 9.0.0
desiredCapacity:
min_mondoo_version: 9.0.0
healthCheckGracePeriod:
min_mondoo_version: 9.0.0
healthCheckType: {}
instances:
min_mondoo_version: 9.0.0
launchConfigurationName:
min_mondoo_version: 9.0.0
loadBalancerNames: {}
Expand Down
21 changes: 21 additions & 0 deletions providers/aws/resources/aws_autoscaling.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ package resources

import (
"context"
"fmt"

"github.com/aws/aws-sdk-go-v2/service/autoscaling"
ec2types "github.com/aws/aws-sdk-go-v2/service/autoscaling/types"
Expand Down Expand Up @@ -74,14 +75,34 @@ func (a *mqlAwsAutoscaling) getGroups(conn *connection.AwsConnection) []*jobpool
for _, name := range group.LoadBalancerNames {
lbNames = append(lbNames, name)
}
availabilityZones := []interface{}{}
for _, zone := range group.AvailabilityZones {
availabilityZones = append(availabilityZones, zone)
}
groupInstances := []interface{}{}
for _, instance := range group.Instances {
mqlInstance, err := NewResource(a.MqlRuntime, "aws.ec2.instance",
map[string]*llx.RawData{
"arn": llx.StringData(fmt.Sprintf(ec2InstanceArnPattern, regionVal, conn.AccountId(), convert.ToString(instance.InstanceId))),
})
if err != nil {
return nil, err
}
groupInstances = append(groupInstances, mqlInstance)
}

mqlGroup, err := CreateResource(a.MqlRuntime, "aws.autoscaling.group",
map[string]*llx.RawData{
"arn": llx.StringDataPtr(group.AutoScalingGroupARN),
"availabilityZones": llx.ArrayData(availabilityZones, types.String),
"capacityRebalance": llx.BoolDataPtr(group.CapacityRebalance),
"createdAt": llx.TimeDataPtr(group.CreatedTime),
"defaultCooldown": llx.IntDataDefault(group.DefaultCooldown, 0),
"defaultInstanceWarmup": llx.IntDataDefault(group.DefaultInstanceWarmup, 0),
"desiredCapacity": llx.IntDataDefault(group.DesiredCapacity, 0),
"healthCheckGracePeriod": llx.IntDataDefault(group.HealthCheckGracePeriod, 0),
"healthCheckType": llx.StringDataPtr(group.HealthCheckType),
"instances": llx.ArrayData(groupInstances, types.Resource("aws.ec2.instance")),
"launchConfigurationName": llx.StringDataPtr(group.LaunchConfigurationName),
"loadBalancerNames": llx.ArrayData(lbNames, types.String),
"maxInstanceLifetime": llx.IntDataDefault(group.MaxInstanceLifetime, 0),
Expand Down
Loading