Skip to content

Commit 29aef0c

Browse files
✨ Add the new exclude fields for serverless AWS integration. Mark old fields as deprecated. (#138)
* ✨ Add the new exclude fields. Mark old fields as deprecated. Signed-off-by: Preslav <preslav@mondoo.com> * Make ebs_scan_options optional. Signed-off-by: Preslav <preslav@mondoo.com> --------- Signed-off-by: Preslav <preslav@mondoo.com>
1 parent 89752a3 commit 29aef0c

2 files changed

Lines changed: 55 additions & 16 deletions

File tree

docs/resources/integration_aws_serverless.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -142,13 +142,13 @@ Optional:
142142
<a id="nestedatt--scan_configuration--ec2_scan_options"></a>
143143
### Nested Schema for `scan_configuration.ec2_scan_options`
144144

145-
Required:
146-
147-
- `ebs_scan_options` (Attributes) (see [below for nested schema](#nestedatt--scan_configuration--ec2_scan_options--ebs_scan_options))
148-
149145
Optional:
150146

147+
- `ebs_scan_options` (Attributes, Deprecated) (see [below for nested schema](#nestedatt--scan_configuration--ec2_scan_options--ebs_scan_options))
151148
- `ebs_volume_scan` (Boolean) Enable EBS volume scan.
149+
- `exclude_instance_ids_filter` (List of String) List of instance IDs to exclude.
150+
- `exclude_regions_filter` (List of String) List of regions to exclude.
151+
- `exclude_tags_filter` (Map of String) Excluded Tags filter.
152152
- `instance_connect` (Boolean) Enable instance connect.
153153
- `instance_ids_filter` (List of String) List of instance IDs filter.
154154
- `regions_filter` (List of String) List of regions filter.
@@ -160,8 +160,8 @@ Optional:
160160

161161
Optional:
162162

163-
- `max_asg_instances` (Number) Max ASG instances.
164-
- `target_instances_per_scanner` (Number) Target instances per scanner.
163+
- `max_asg_instances` (Number, Deprecated) Max ASG instances.
164+
- `target_instances_per_scanner` (Number, Deprecated) Target instances per scanner.
165165

166166

167167

internal/provider/integration_aws_serverless_resource.go

Lines changed: 49 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -82,12 +82,18 @@ type Ec2ScanOptionsInput struct {
8282
// (Optional.)
8383
Ssm types.Bool `tfsdk:"ssm"`
8484
// (Optional.)
85-
InstanceIDsFilter types.List `tfsdk:"instance_ids_filter"`
85+
InstanceIdsFilter types.List `tfsdk:"instance_ids_filter"`
8686
// (Optional.)
8787
RegionsFilter types.List `tfsdk:"regions_filter"`
8888
// (Optional.)
8989
TagsFilter types.Map `tfsdk:"tags_filter"`
9090
// (Optional.)
91+
ExcludeInstanceIdsFilter types.List `tfsdk:"exclude_instance_ids_filter"`
92+
// (Optional.)
93+
ExcludeRegionsFilter types.List `tfsdk:"exclude_regions_filter"`
94+
// (Optional.)
95+
ExcludeTagsFilter types.Map `tfsdk:"exclude_tags_filter"`
96+
// (Optional.)
9197
EbsVolumeScan types.Bool `tfsdk:"ebs_volume_scan"`
9298
// (Optional.)
9399
EbsScanOptions *EbsScanOptionsInput `tfsdk:"ebs_scan_options"`
@@ -132,17 +138,29 @@ func (m integrationAwsServerlessResourceModel) GetConfigurationOptions() *mondoo
132138
}
133139

134140
var instanceIdsFilter []mondoov1.String
135-
instanceIds, _ := m.ScanConfiguration.Ec2ScanOptions.InstanceIDsFilter.ToListValue(context.Background())
141+
instanceIds, _ := m.ScanConfiguration.Ec2ScanOptions.InstanceIdsFilter.ToListValue(context.Background())
136142
instanceIds.ElementsAs(context.Background(), &instanceIdsFilter, true)
137143

138-
var RegionsFilter []mondoov1.String
144+
var regionsFilter []mondoov1.String
139145
regions, _ := m.ScanConfiguration.Ec2ScanOptions.RegionsFilter.ToListValue(context.Background())
140-
regions.ElementsAs(context.Background(), &RegionsFilter, true)
146+
regions.ElementsAs(context.Background(), &regionsFilter, true)
141147

142148
var tagsFilter mondoov1.Map
143149
tags, _ := m.ScanConfiguration.Ec2ScanOptions.TagsFilter.ToMapValue(context.Background())
144150
tags.ElementsAs(context.Background(), &tagsFilter, true)
145151

152+
var excludeInstanceIdsFilter []mondoov1.String
153+
excludeInstanceIds, _ := m.ScanConfiguration.Ec2ScanOptions.ExcludeInstanceIdsFilter.ToListValue(context.Background())
154+
excludeInstanceIds.ElementsAs(context.Background(), &excludeInstanceIdsFilter, true)
155+
156+
var excludeRegionsFilter []mondoov1.String
157+
excludeRegions, _ := m.ScanConfiguration.Ec2ScanOptions.ExcludeRegionsFilter.ToListValue(context.Background())
158+
excludeRegions.ElementsAs(context.Background(), &excludeRegionsFilter, true)
159+
160+
var excludeTagsFilter mondoov1.Map
161+
excludeTags, _ := m.ScanConfiguration.Ec2ScanOptions.ExcludeTagsFilter.ToMapValue(context.Background())
162+
excludeTags.ElementsAs(context.Background(), &excludeTagsFilter, true)
163+
146164
var accountIDs []mondoov1.String
147165
accountIds, _ := m.AccountIDs.ToListValue(context.Background())
148166
accountIds.ElementsAs(context.Background(), &accountIDs, true)
@@ -157,11 +175,14 @@ func (m integrationAwsServerlessResourceModel) GetConfigurationOptions() *mondoo
157175
CronScaninHours: mondoov1.NewIntPtr(mondoov1.Int(m.ScanConfiguration.CronScaninHours.ValueInt64())),
158176
EventScanTriggers: &eventScanTriggers,
159177
Ec2ScanOptions: &mondoov1.Ec2ScanOptionsInput{
160-
Ssm: mondoov1.NewBooleanPtr(mondoov1.Boolean(m.ScanConfiguration.Ec2ScanOptions.Ssm.ValueBool())),
161-
InstanceIDsFilter: &instanceIdsFilter,
162-
RegionsFilter: &RegionsFilter,
163-
TagsFilter: &tagsFilter,
164-
EbsVolumeScan: mondoov1.NewBooleanPtr(mondoov1.Boolean(m.ScanConfiguration.Ec2ScanOptions.EbsVolumeScan.ValueBool())),
178+
Ssm: mondoov1.NewBooleanPtr(mondoov1.Boolean(m.ScanConfiguration.Ec2ScanOptions.Ssm.ValueBool())),
179+
InstanceIDsFilter: &instanceIdsFilter,
180+
RegionsFilter: &regionsFilter,
181+
TagsFilter: &tagsFilter,
182+
ExcludedInstanceIDsFilter: &excludeInstanceIdsFilter,
183+
ExcludedRegionsFilter: &excludeRegionsFilter,
184+
ExcludedTagsFilter: &excludeTagsFilter,
185+
EbsVolumeScan: mondoov1.NewBooleanPtr(mondoov1.Boolean(m.ScanConfiguration.Ec2ScanOptions.EbsVolumeScan.ValueBool())),
165186
EbsScanOptions: &mondoov1.EbsScanOptionsInput{
166187
TargetInstancesPerScanner: mondoov1.NewIntPtr(mondoov1.Int(m.ScanConfiguration.Ec2ScanOptions.EbsScanOptions.TargetInstancesPerScanner.ValueInt64())),
167188
MaxAsgInstances: mondoov1.NewIntPtr(mondoov1.Int(m.ScanConfiguration.Ec2ScanOptions.EbsScanOptions.MaxAsgInstances.ValueInt64())),
@@ -279,20 +300,38 @@ func (r *integrationAwsServerlessResource) Schema(ctx context.Context, req resou
279300
Optional: true,
280301
ElementType: types.StringType,
281302
},
303+
"exclude_instance_ids_filter": schema.ListAttribute{
304+
MarkdownDescription: "List of instance IDs to exclude.",
305+
Optional: true,
306+
ElementType: types.StringType,
307+
},
308+
"exclude_regions_filter": schema.ListAttribute{
309+
MarkdownDescription: "List of regions to exclude.",
310+
Optional: true,
311+
ElementType: types.StringType,
312+
},
313+
"exclude_tags_filter": schema.MapAttribute{
314+
MarkdownDescription: "Excluded Tags filter.",
315+
Optional: true,
316+
ElementType: types.StringType,
317+
},
282318
"ebs_volume_scan": schema.BoolAttribute{
283319
MarkdownDescription: "Enable EBS volume scan.",
284320
Optional: true,
285321
},
286322
"ebs_scan_options": schema.SingleNestedAttribute{
287-
Required: true,
323+
Optional: true,
324+
DeprecationMessage: "This field is deprecated and will be removed in the future.",
288325
Attributes: map[string]schema.Attribute{
289326
"target_instances_per_scanner": schema.Int64Attribute{
290327
MarkdownDescription: "Target instances per scanner.",
291328
Optional: true,
329+
DeprecationMessage: "This field is deprecated and will be removed in the future.",
292330
},
293331
"max_asg_instances": schema.Int64Attribute{
294332
MarkdownDescription: "Max ASG instances.",
295333
Optional: true,
334+
DeprecationMessage: "This field is deprecated and will be removed in the future.",
296335
},
297336
},
298337
},

0 commit comments

Comments
 (0)