/
table_aws_rds_db_instance.go
714 lines (665 loc) · 24 KB
/
table_aws_rds_db_instance.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
package aws
import (
"context"
"github.com/aws/aws-sdk-go-v2/aws"
"github.com/aws/aws-sdk-go-v2/service/rds"
"github.com/aws/aws-sdk-go-v2/service/rds/types"
rdsv1 "github.com/aws/aws-sdk-go/service/rds"
"github.com/turbot/go-kit/helpers"
"github.com/turbot/steampipe-plugin-sdk/v5/grpc/proto"
"github.com/turbot/steampipe-plugin-sdk/v5/plugin"
"github.com/turbot/steampipe-plugin-sdk/v5/plugin/transform"
)
//// TABLE DEFINITION
func tableAwsRDSDBInstance(_ context.Context) *plugin.Table {
return &plugin.Table{
Name: "aws_rds_db_instance",
Description: "AWS RDS DB Instance",
Get: &plugin.GetConfig{
KeyColumns: plugin.SingleColumn("db_instance_identifier"),
IgnoreConfig: &plugin.IgnoreConfig{
ShouldIgnoreErrorFunc: shouldIgnoreErrors([]string{"DBInstanceNotFound"}),
},
Hydrate: getRDSDBInstance,
Tags: map[string]string{"service": "rds", "action": "DescribeDBInstances"},
},
List: &plugin.ListConfig{
Hydrate: listRDSDBInstances,
Tags: map[string]string{"service": "rds", "action": "DescribeDBInstances"},
KeyColumns: []*plugin.KeyColumn{
{Name: "db_cluster_identifier", Require: plugin.Optional},
{Name: "resource_id", Require: plugin.Optional},
{Name: "engine", Require: plugin.Optional},
},
},
HydrateConfig: []plugin.HydrateConfig{
{
Func: getRDSDBInstancePendingMaintenanceAction,
Tags: map[string]string{"service": "rds", "action": "DescribePendingMaintenanceActions"},
},
{
Func: getRDSDBInstanceCertificate,
Tags: map[string]string{"service": "rds", "action": "DescribeCertificates"},
},
{
Func: getRDSDBInstanceProcessorFeatures,
Tags: map[string]string{"service": "rds", "action": "DescribeOrderableDBInstanceOptions"},
},
},
GetMatrixItemFunc: SupportedRegionMatrix(rdsv1.EndpointsID),
Columns: awsRegionalColumns([]*plugin.Column{
{
Name: "db_instance_identifier",
Description: "The friendly name to identify the DB Instance.",
Type: proto.ColumnType_STRING,
Transform: transform.FromField("DBInstanceIdentifier"),
},
{
Name: "arn",
Description: "The Amazon Resource Name (ARN) for the DB Instance.",
Type: proto.ColumnType_STRING,
Transform: transform.FromField("DBInstanceArn"),
},
{
Name: "db_cluster_identifier",
Description: "The friendly name to identify the DB cluster, that the DB instance is a member of.",
Type: proto.ColumnType_STRING,
Transform: transform.FromField("DBClusterIdentifier"),
},
{
Name: "status",
Description: "Specifies the current state of this database.",
Type: proto.ColumnType_STRING,
Transform: transform.FromField("DBInstanceStatus"),
},
{
Name: "class",
Description: "Contains the name of the compute and memory capacity class of the DB instance.",
Type: proto.ColumnType_STRING,
Transform: transform.FromField("DBInstanceClass"),
},
{
Name: "resource_id",
Description: "The AWS Region-unique, immutable identifier for the DB instance.",
Type: proto.ColumnType_STRING,
Transform: transform.FromField("DbiResourceId"),
},
{
Name: "allocated_storage",
Description: "Specifies the allocated storage size specified in gibibytes(GiB).",
Type: proto.ColumnType_INT,
},
{
Name: "auto_minor_version_upgrade",
Description: "Specifies whether minor version patches are applied automatically, or not.",
Type: proto.ColumnType_BOOL,
},
{
Name: "availability_zone",
Description: "Specifies the name of the Availability Zone the DB instance is located in.",
Type: proto.ColumnType_STRING,
},
{
Name: "backup_retention_period",
Description: "Specifies the number of days for which automatic DB snapshots are retained.",
Type: proto.ColumnType_INT,
},
{
Name: "ca_certificate_identifier",
Description: "The identifier of the CA certificate for this DB instance.",
Type: proto.ColumnType_STRING,
Transform: transform.FromField("CACertificateIdentifier"),
},
{
Name: "character_set_name",
Description: "Specifies the name of the character set that this instance is associated with.",
Type: proto.ColumnType_STRING,
},
{
Name: "copy_tags_to_snapshot",
Description: "Specifies whether tags are copied from the DB instance to snapshots of the DB instance, or not.",
Type: proto.ColumnType_BOOL,
},
{
Name: "customer_owned_ip_enabled",
Description: "Specifies whether a customer-owned IP address (CoIP) is enabled for an RDS on Outposts DB instance, or not.",
Type: proto.ColumnType_BOOL,
},
{
Name: "port",
Description: "Specifies the port that the DB instance listens on.",
Type: proto.ColumnType_INT,
Transform: transform.FromField("DbInstancePort"),
},
{
Name: "db_name",
Description: "Contains the name of the initial database of this instance that was provided at create time.",
Type: proto.ColumnType_STRING,
Transform: transform.FromField("DBName"),
},
{
Name: "db_subnet_group_arn",
Description: "The Amazon Resource Name (ARN) for the DB subnet group.",
Type: proto.ColumnType_STRING,
Transform: transform.FromField("DBSubnetGroup.DBSubnetGroupArn"),
},
{
Name: "db_subnet_group_description",
Description: "Provides the description of the DB subnet group.",
Type: proto.ColumnType_STRING,
Transform: transform.FromField("DBSubnetGroup.DBSubnetGroupDescription"),
},
{
Name: "db_subnet_group_name",
Description: "The name of the DB subnet group.",
Type: proto.ColumnType_STRING,
Transform: transform.FromField("DBSubnetGroup.DBSubnetGroupName"),
},
{
Name: "db_subnet_group_status",
Description: "Provides the status of the DB subnet group.",
Type: proto.ColumnType_STRING,
Transform: transform.FromField("DBSubnetGroup.SubnetGroupStatus"),
},
{
Name: "deletion_protection",
Description: "Specifies whether the DB instance has deletion protection enabled, or not.",
Type: proto.ColumnType_BOOL,
},
{
Name: "endpoint_address",
Description: "Specifies the DNS address of the DB instance.",
Type: proto.ColumnType_STRING,
Transform: transform.FromField("Endpoint.Address"),
},
{
Name: "endpoint_hosted_zone_id",
Description: "Specifies the ID that Amazon Route 53 assigns when you create a hosted zone.",
Type: proto.ColumnType_STRING,
Transform: transform.FromField("Endpoint.HostedZoneId"),
},
{
Name: "endpoint_port",
Description: "Specifies the port that the database engine is listening on.",
Type: proto.ColumnType_INT,
Transform: transform.FromField("Endpoint.Port"),
},
{
Name: "engine",
Description: "The name of the database engine to be used for this DB instance.",
Type: proto.ColumnType_STRING,
},
{
Name: "engine_version",
Description: "Indicates the database engine version.",
Type: proto.ColumnType_STRING,
},
{
Name: "enhanced_monitoring_resource_arn",
Description: "The ARN of the Amazon CloudWatch Logs log stream that receives the Enhanced Monitoring metrics data for the DB instance.",
Type: proto.ColumnType_STRING,
},
{
Name: "iam_database_authentication_enabled",
Description: "Specifies whether the the mapping of AWS IAM accounts to database accounts is enabled, or not.",
Type: proto.ColumnType_BOOL,
Transform: transform.FromField("IAMDatabaseAuthenticationEnabled"),
},
{
Name: "create_time",
Description: "Provides the date and time the DB instance was created.",
Type: proto.ColumnType_TIMESTAMP,
Transform: transform.FromField("InstanceCreateTime"),
},
{
Name: "iops",
Description: "Specifies the Provisioned IOPS (I/O operations per second) value.",
Type: proto.ColumnType_INT,
},
{
Name: "kms_key_id",
Description: "The AWS KMS key identifier for the encrypted DB instance.",
Type: proto.ColumnType_STRING,
},
{
Name: "latest_restorable_time",
Description: "Specifies the latest time to which a database can be restored with point-in-time restore.",
Type: proto.ColumnType_TIMESTAMP,
},
{
Name: "license_model",
Description: "License model information for this DB instance.",
Type: proto.ColumnType_STRING,
},
{
Name: "master_user_name",
Description: "Contains the master username for the DB instance.",
Type: proto.ColumnType_STRING,
Transform: transform.FromField("MasterUsername"),
},
{
Name: "max_allocated_storage",
Description: "The upper limit to which Amazon RDS can automatically scale the storage of the DB instance.",
Type: proto.ColumnType_INT,
},
{
Name: "monitoring_interval",
Description: "The interval, in seconds, between points when Enhanced Monitoring metrics are collected for the DB instance.",
Type: proto.ColumnType_INT,
},
{
Name: "monitoring_role_arn",
Description: "The ARN for the IAM role that permits RDS to send Enhanced Monitoring metrics to Amazon CloudWatch Logs.",
Type: proto.ColumnType_STRING,
},
{
Name: "multi_az",
Description: "Specifies if the DB instance is a Multi-AZ deployment.",
Type: proto.ColumnType_BOOL,
Transform: transform.FromField("MultiAZ"),
},
{
Name: "nchar_character_set_name",
Description: "The name of the NCHAR character set for the Oracle DB instance.",
Type: proto.ColumnType_STRING,
},
{
Name: "performance_insights_enabled",
Description: "Specifies whether Performance Insights is enabled for the DB instance, or not.",
Type: proto.ColumnType_BOOL,
Default: false,
},
{
Name: "performance_insights_kms_key_id",
Description: "The AWS KMS key identifier for encryption of Performance Insights data.",
Type: proto.ColumnType_STRING,
Transform: transform.FromField("PerformanceInsightsKMSKeyId"),
},
{
Name: "performance_insights_retention_period",
Description: "The amount of time, in days, to retain Performance Insights data.",
Type: proto.ColumnType_INT,
},
{
Name: "preferred_backup_window",
Description: "Specifies the daily time range during which automated backups are created.",
Type: proto.ColumnType_STRING,
},
{
Name: "preferred_maintenance_window",
Description: "Specifies the weekly time range during which system maintenance can occur.",
Type: proto.ColumnType_STRING,
},
{
Name: "promotion_tier",
Description: "Specifies the order in which an Aurora Replica is promoted to the primary instance after a failure of the existing primary instance.",
Type: proto.ColumnType_INT,
},
{
Name: "publicly_accessible",
Description: "Specifies the accessibility options for the DB instance.",
Type: proto.ColumnType_BOOL,
Default: false,
},
{
Name: "read_replica_source_db_instance_identifier",
Description: "Contains the identifier of the source DB instance if this DB instance is a read replica.",
Type: proto.ColumnType_STRING,
Transform: transform.FromField("ReadReplicaSourceDBInstanceIdentifier"),
},
{
Name: "replica_mode",
Description: "The mode of an Oracle read replica.",
Type: proto.ColumnType_STRING,
},
{
Name: "secondary_availability_zone",
Description: "Specifies the name of the secondary Availability Zone for a DB instance with multi-AZ support.",
Type: proto.ColumnType_STRING,
},
{
Name: "storage_encrypted",
Description: "Specifies whether the DB instance is encrypted, or not.",
Type: proto.ColumnType_BOOL,
Default: false,
},
{
Name: "storage_throughput",
Description: "Specifies the storage throughput for the DB instance. This setting applies only to the gp3 storage type.",
Type: proto.ColumnType_INT,
},
{
Name: "storage_type",
Description: "Specifies the storage type associated with DB instance.",
Type: proto.ColumnType_STRING,
},
{
Name: "tde_credential_arn",
Description: " The ARN from the key store with which the instance is associated for TDE encryption.",
Type: proto.ColumnType_STRING,
},
{
Name: "timezone",
Description: "The time zone of the DB instance.",
Type: proto.ColumnType_STRING,
},
{
Name: "vpc_id",
Description: "Provides the VpcId of the DB subnet group.",
Type: proto.ColumnType_STRING,
Transform: transform.FromField("DBSubnetGroup.VpcId"),
},
{
Name: "associated_roles",
Description: "A list of AWS IAM roles that are associated with the DB instance.",
Type: proto.ColumnType_JSON,
},
{
Name: "certificate",
Description: "The CA certificate associated with the DB instance.",
Type: proto.ColumnType_JSON,
Hydrate: getRDSDBInstanceCertificate,
Transform: transform.FromValue(),
},
{
Name: "db_parameter_groups",
Description: "A list of DB parameter groups applied to this DB instance.",
Type: proto.ColumnType_JSON,
Transform: transform.FromField("DBParameterGroups"),
},
{
Name: "db_security_groups",
Description: "A list of DB security group associated with the DB instance.",
Type: proto.ColumnType_JSON,
},
{
Name: "domain_memberships",
Description: "A list of Active Directory Domain membership records associated with the DB instance.",
Type: proto.ColumnType_JSON,
},
{
Name: "enabled_cloudwatch_logs_exports",
Description: "A list of log types that this DB instance is configured to export to CloudWatch Logs.",
Type: proto.ColumnType_JSON,
},
{
Name: "option_group_memberships",
Description: "A list of option group memberships for this DB instance",
Type: proto.ColumnType_JSON,
},
{
Name: "pending_maintenance_actions",
Description: "A list that provides details about the pending maintenance actions for the resource.",
Hydrate: getRDSDBInstancePendingMaintenanceAction,
Type: proto.ColumnType_JSON,
Transform: transform.FromValue(),
},
{
Name: "processor_features",
Description: "The number of CPU cores and the number of threads per core for the DB instance class of the DB instance.",
Type: proto.ColumnType_JSON,
Hydrate: getRDSDBInstanceProcessorFeatures,
Transform: transform.FromValue(),
},
{
Name: "read_replica_db_cluster_identifiers",
Description: "A list of identifiers of Aurora DB clusters to which the RDS DB instance is replicated as a read replica.",
Type: proto.ColumnType_JSON,
Transform: transform.FromField("ReadReplicaDBClusterIdentifiers"),
},
{
Name: "read_replica_db_instance_identifiers",
Description: "A list of identifiers of the read replicas associated with this DB instance.",
Type: proto.ColumnType_JSON,
},
{
Name: "status_infos",
Description: "The status of a read replica.",
Type: proto.ColumnType_JSON,
},
{
Name: "subnets",
Description: "A list of subnet elements.",
Type: proto.ColumnType_JSON,
Transform: transform.FromField("DBSubnetGroup.Subnets"),
},
{
Name: "vpc_security_groups",
Description: "A list of VPC security group elements that the DB instance belongs to.",
Type: proto.ColumnType_JSON,
},
{
Name: "tags_src",
Description: "A list of tags attached to the DB Instance.",
Type: proto.ColumnType_JSON,
Transform: transform.FromField("TagList"),
},
// Standard columns
{
Name: "tags",
Description: resourceInterfaceDescription("tags"),
Type: proto.ColumnType_JSON,
Transform: transform.From(getRDSDBInstanceTurbotTags),
},
{
Name: "title",
Description: resourceInterfaceDescription("title"),
Type: proto.ColumnType_STRING,
Transform: transform.FromField("DBInstanceIdentifier"),
},
{
Name: "akas",
Description: resourceInterfaceDescription("akas"),
Type: proto.ColumnType_JSON,
Transform: transform.FromField("DBInstanceArn").Transform(arnToAkas),
},
}),
}
}
//// LIST FUNCTION
func listRDSDBInstances(ctx context.Context, d *plugin.QueryData, _ *plugin.HydrateData) (interface{}, error) {
// Create Session
svc, err := RDSClient(ctx, d)
if err != nil {
plugin.Logger(ctx).Error("aws_rds_db_instance.listRDSDBInstances", "connection_error", err)
return nil, err
}
// Limiting the results
maxLimit := int32(100)
if d.QueryContext.Limit != nil {
limit := int32(*d.QueryContext.Limit)
if limit < maxLimit {
if limit < 20 {
maxLimit = 20
} else {
maxLimit = limit
}
}
}
input := &rds.DescribeDBInstancesInput{
MaxRecords: aws.Int32(maxLimit),
}
filters := buildRdsDbInstanceFilter(d.Quals)
if len(filters) > 0 {
input.Filters = filters
}
paginator := rds.NewDescribeDBInstancesPaginator(svc, input, func(o *rds.DescribeDBInstancesPaginatorOptions) {
o.Limit = maxLimit
o.StopOnDuplicateToken = true
})
// List call
for paginator.HasMorePages() {
// apply rate limiting
d.WaitForListRateLimit(ctx)
output, err := paginator.NextPage(ctx)
if err != nil {
plugin.Logger(ctx).Error("aws_rds_db_instance.listRDSDBInstances", "api_error", err)
return nil, err
}
for _, items := range output.DBInstances {
if isSuppportedRDSEngine(*items.Engine) {
d.StreamListItem(ctx, items)
}
// Context can be cancelled due to manual cancellation or the limit has been hit
if d.RowsRemaining(ctx) == 0 {
return nil, nil
}
}
}
return nil, err
}
//// HYDRATE FUNCTIONS
func getRDSDBInstance(ctx context.Context, d *plugin.QueryData, _ *plugin.HydrateData) (interface{}, error) {
dbInstanceIdentifier := d.EqualsQuals["db_instance_identifier"].GetStringValue()
// Create service
svc, err := RDSClient(ctx, d)
if err != nil {
plugin.Logger(ctx).Error("aws_rds_db_instance.getRDSDBInstance", "connection_error", err)
return nil, err
}
params := &rds.DescribeDBInstancesInput{
DBInstanceIdentifier: aws.String(dbInstanceIdentifier),
}
op, err := svc.DescribeDBInstances(ctx, params)
if err != nil {
plugin.Logger(ctx).Error("aws_rds_db_instance.getRDSDBInstance", "api_error", err)
return nil, err
}
if op.DBInstances != nil && len(op.DBInstances) > 0 {
instance := op.DBInstances[0]
if isSuppportedRDSEngine(*instance.Engine) {
return instance, nil
}
}
return nil, nil
}
func getRDSDBInstancePendingMaintenanceAction(ctx context.Context, d *plugin.QueryData, h *plugin.HydrateData) (interface{}, error) {
dbInstanceIdentifier := *h.Item.(types.DBInstance).DBInstanceIdentifier
// Create service
svc, err := RDSClient(ctx, d)
if err != nil {
plugin.Logger(ctx).Error("aws_rds_db_instance.getRDSDBInstancePendingMaintenanceAction", "connection_error", err)
return nil, err
}
filter := &types.Filter{
Name: aws.String("db-instance-id"),
Values: []string{dbInstanceIdentifier},
}
params := &rds.DescribePendingMaintenanceActionsInput{
Filters: []types.Filter{*filter},
}
op, err := svc.DescribePendingMaintenanceActions(ctx, params)
if err != nil {
plugin.Logger(ctx).Error("aws_rds_db_instance.getRDSDBInstancePendingMaintenanceAction", "api_error", err)
return nil, err
}
if len(op.PendingMaintenanceActions) > 0 {
return op.PendingMaintenanceActions, nil
}
return nil, nil
}
func getRDSDBInstanceCertificate(ctx context.Context, d *plugin.QueryData, h *plugin.HydrateData) (interface{}, error) {
caCertificateIdentifier := *h.Item.(types.DBInstance).CACertificateIdentifier
// Create service
svc, err := RDSClient(ctx, d)
if err != nil {
plugin.Logger(ctx).Error("aws_rds_db_instance.getRDSDBInstanceCertificate", "connection_error", err)
return nil, err
}
params := &rds.DescribeCertificatesInput{
CertificateIdentifier: aws.String(caCertificateIdentifier),
}
op, err := svc.DescribeCertificates(ctx, params)
if err != nil {
plugin.Logger(ctx).Error("aws_rds_db_instance.getRDSDBInstanceCertificate", "api_error", err)
return nil, err
}
if len(op.Certificates) > 0 {
return op.Certificates[0], nil
}
return nil, nil
}
// DescribeDBInstances API returns the non-default ProcessorFeature value.
// For populating the default ProcessorFeature value we need to make DescribeOrderableDBInstanceOptions API call.
func getRDSDBInstanceProcessorFeatures(ctx context.Context, d *plugin.QueryData, h *plugin.HydrateData) (interface{}, error) {
var processFeatures []types.ProcessorFeature
dbInstance := h.Item.(types.DBInstance)
// Return the ProcessFeature details if the
if dbInstance.ProcessorFeatures != nil {
return dbInstance.ProcessorFeatures, nil
}
// Create service
svc, err := RDSClient(ctx, d)
if err != nil {
plugin.Logger(ctx).Error("aws_rds_db_instance.getRDSDBInstanceProcessorFeatures", "connection_error", err)
return nil, err
}
// https://docs.aws.amazon.com/AmazonRDS/latest/APIReference/API_DescribeOrderableDBInstanceOptions.html
// Return nil if unsupported engine type
if !helpers.StringSliceContains([]string{"aurora-mysql", "aurora-postgresql", "custom-oracle-ee", "db2-ae", "db2-se", "mariadb", "mysql", "oracle-ee", "oracle-ee-cdb", "oracle-se2", "oracle-se2-cdb", "postgres", "sqlserver-ee", "sqlserver-se", "sqlserver-ex", "sqlserver-web"}, *dbInstance.Engine) {
return nil, nil
}
params := &rds.DescribeOrderableDBInstanceOptionsInput{
Engine: dbInstance.Engine,
DBInstanceClass: dbInstance.DBInstanceClass,
AvailabilityZoneGroup: aws.String(d.EqualsQualString(matrixKeyRegion)),
}
op, err := svc.DescribeOrderableDBInstanceOptions(ctx, params)
if err != nil {
plugin.Logger(ctx).Error("aws_rds_db_instance.getRDSDBInstanceProcessorFeatures", "api_error", err)
return nil, err
}
for _, p := range op.OrderableDBInstanceOptions {
if *p.StorageType == *dbInstance.StorageType && *p.EngineVersion == *dbInstance.EngineVersion {
// Match the RDS insance Availability Zone
for _, a := range p.AvailabilityZones {
if *a.Name == *dbInstance.AvailabilityZone {
for _, f := range p.AvailableProcessorFeatures {
processFeature := &types.ProcessorFeature{
Name: f.Name,
Value: f.DefaultValue,
}
processFeatures = append(processFeatures, *processFeature)
}
}
}
}
}
return processFeatures, nil
}
//// TRANSFORM FUNCTIONS
func getRDSDBInstanceTurbotTags(_ context.Context, d *transform.TransformData) (interface{}, error) {
dbInstance := d.HydrateItem.(types.DBInstance)
if dbInstance.TagList != nil {
turbotTagsMap := map[string]string{}
for _, i := range dbInstance.TagList {
turbotTagsMap[*i.Key] = *i.Value
}
return turbotTagsMap, nil
}
return nil, nil
}
//// UTILITY FUNCTIONS
// build rds db instance list call input filter
func buildRdsDbInstanceFilter(quals plugin.KeyColumnQualMap) []types.Filter {
filters := make([]types.Filter, 0)
filterQuals := map[string]string{
"db_cluster_identifier": "db-cluster-id",
"resource_id": "dbi-resource-id",
"engine": "engine",
}
for columnName, filterName := range filterQuals {
if quals[columnName] != nil {
filter := types.Filter{
Name: aws.String(filterName),
}
value := getQualsValueByColumn(quals, columnName, "string")
val, ok := value.(string)
if ok {
filter.Values = []string{val}
}
filters = append(filters, filter)
}
}
return filters
}