fix: aws_rds_cluster deep mode
parent
7c653d0500
commit
6718cfb3e4
|
@ -32,6 +32,12 @@ func (e *RDSClusterEnumerator) Enumerate() ([]*resource.Resource, error) {
|
|||
results := make([]*resource.Resource, len(clusters))
|
||||
|
||||
for _, cluster := range clusters {
|
||||
var databaseName string
|
||||
|
||||
if v := cluster.DatabaseName; v != nil {
|
||||
databaseName = *cluster.DatabaseName
|
||||
}
|
||||
|
||||
results = append(
|
||||
results,
|
||||
e.factory.CreateAbstractResource(
|
||||
|
@ -39,6 +45,7 @@ func (e *RDSClusterEnumerator) Enumerate() ([]*resource.Resource, error) {
|
|||
*cluster.DBClusterIdentifier,
|
||||
map[string]interface{}{
|
||||
"cluster_identifier": *cluster.DBClusterIdentifier,
|
||||
"database_name": databaseName,
|
||||
},
|
||||
),
|
||||
)
|
||||
|
|
|
@ -249,7 +249,13 @@ func TestRDSCluster(t *testing.T) {
|
|||
dirName: "aws_rds_clusters_results",
|
||||
mocks: func(repository *repository.MockRDSRepository, alerter *mocks.AlerterInterface) {
|
||||
repository.On("ListAllDBClusters").Return([]*rds.DBCluster{
|
||||
{DBClusterIdentifier: awssdk.String("aurora-cluster-demo")},
|
||||
{
|
||||
DBClusterIdentifier: awssdk.String("aurora-cluster-demo"),
|
||||
DatabaseName: awssdk.String("mydb"),
|
||||
},
|
||||
{
|
||||
DBClusterIdentifier: awssdk.String("aurora-cluster-demo-2"),
|
||||
},
|
||||
}, nil)
|
||||
},
|
||||
},
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
{
|
||||
"Typ": "WyJvYmplY3QiLHsiYWxsb3dfbWFqb3JfdmVyc2lvbl91cGdyYWRlIjoiYm9vbCIsImFwcGx5X2ltbWVkaWF0ZWx5IjoiYm9vbCIsImFybiI6InN0cmluZyIsImF2YWlsYWJpbGl0eV96b25lcyI6WyJzZXQiLCJzdHJpbmciXSwiYmFja3RyYWNrX3dpbmRvdyI6Im51bWJlciIsImJhY2t1cF9yZXRlbnRpb25fcGVyaW9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eV9ncm91cF9pZHMiOlsic2ctNDllMzg2NDYiXX0=",
|
||||
"Err": null
|
||||
}
|
|
@ -1,57 +1,112 @@
|
|||
[
|
||||
{
|
||||
"allow_major_version_upgrade": null,
|
||||
"apply_immediately": null,
|
||||
"arn": "arn:aws:rds:us-east-1:533948124879:cluster:aurora-cluster-demo",
|
||||
"availability_zones": [
|
||||
"us-east-1a",
|
||||
"us-east-1b",
|
||||
"us-east-1d"
|
||||
],
|
||||
"backtrack_window": 0,
|
||||
"backup_retention_period": 5,
|
||||
"cluster_identifier": "aurora-cluster-demo",
|
||||
"cluster_identifier_prefix": null,
|
||||
"cluster_members": [
|
||||
"aurora-cluster-demo-0"
|
||||
],
|
||||
"cluster_resource_id": "cluster-TISYDSSX4J5R6ZGUTV6LLJW73E",
|
||||
"copy_tags_to_snapshot": false,
|
||||
"database_name": "mydb",
|
||||
"db_cluster_parameter_group_name": "default.aurora-postgresql11",
|
||||
"db_subnet_group_name": "default",
|
||||
"deletion_protection": false,
|
||||
"enable_http_endpoint": false,
|
||||
"enabled_cloudwatch_logs_exports": null,
|
||||
"endpoint": "aurora-cluster-demo.cluster-cd539r6quiux.us-east-1.rds.amazonaws.com",
|
||||
"engine": "aurora-postgresql",
|
||||
"engine_mode": "provisioned",
|
||||
"engine_version": "11.9",
|
||||
"final_snapshot_identifier": null,
|
||||
"global_cluster_identifier": "",
|
||||
"hosted_zone_id": "Z2R2ITUGPM61AM",
|
||||
"iam_database_authentication_enabled": false,
|
||||
"iam_roles": null,
|
||||
"id": "aurora-cluster-demo",
|
||||
"kms_key_id": "",
|
||||
"master_password": null,
|
||||
"master_username": "foo",
|
||||
"port": 5432,
|
||||
"preferred_backup_window": "07:00-09:00",
|
||||
"preferred_maintenance_window": "fri:03:03-fri:03:33",
|
||||
"reader_endpoint": "aurora-cluster-demo.cluster-ro-cd539r6quiux.us-east-1.rds.amazonaws.com",
|
||||
"replication_source_identifier": "",
|
||||
"restore_to_point_in_time": null,
|
||||
"s3_import": null,
|
||||
"scaling_configuration": null,
|
||||
"skip_final_snapshot": false,
|
||||
"snapshot_identifier": null,
|
||||
"source_region": null,
|
||||
"storage_encrypted": false,
|
||||
"tags": null,
|
||||
"timeouts": null,
|
||||
"vpc_security_group_ids": [
|
||||
"sg-49e38646"
|
||||
]
|
||||
}
|
||||
{
|
||||
"allow_major_version_upgrade": null,
|
||||
"apply_immediately": null,
|
||||
"arn": "arn:aws:rds:us-east-1:533948124879:cluster:aurora-cluster-demo",
|
||||
"availability_zones": [
|
||||
"us-east-1a",
|
||||
"us-east-1b",
|
||||
"us-east-1d"
|
||||
],
|
||||
"backtrack_window": 0,
|
||||
"backup_retention_period": 5,
|
||||
"cluster_identifier": "aurora-cluster-demo",
|
||||
"cluster_identifier_prefix": null,
|
||||
"cluster_members": [
|
||||
"aurora-cluster-demo-0"
|
||||
],
|
||||
"cluster_resource_id": "cluster-TISYDSSX4J5R6ZGUTV6LLJW73E",
|
||||
"copy_tags_to_snapshot": false,
|
||||
"database_name": "mydb",
|
||||
"db_cluster_parameter_group_name": "default.aurora-postgresql11",
|
||||
"db_subnet_group_name": "default",
|
||||
"deletion_protection": false,
|
||||
"enable_http_endpoint": false,
|
||||
"enabled_cloudwatch_logs_exports": null,
|
||||
"endpoint": "aurora-cluster-demo.cluster-cd539r6quiux.us-east-1.rds.amazonaws.com",
|
||||
"engine": "aurora-postgresql",
|
||||
"engine_mode": "provisioned",
|
||||
"engine_version": "11.9",
|
||||
"final_snapshot_identifier": null,
|
||||
"global_cluster_identifier": "",
|
||||
"hosted_zone_id": "Z2R2ITUGPM61AM",
|
||||
"iam_database_authentication_enabled": false,
|
||||
"iam_roles": null,
|
||||
"id": "aurora-cluster-demo",
|
||||
"kms_key_id": "",
|
||||
"master_password": null,
|
||||
"master_username": "foo",
|
||||
"port": 5432,
|
||||
"preferred_backup_window": "07:00-09:00",
|
||||
"preferred_maintenance_window": "fri:03:03-fri:03:33",
|
||||
"reader_endpoint": "aurora-cluster-demo.cluster-ro-cd539r6quiux.us-east-1.rds.amazonaws.com",
|
||||
"replication_source_identifier": "",
|
||||
"restore_to_point_in_time": null,
|
||||
"s3_import": null,
|
||||
"scaling_configuration": null,
|
||||
"skip_final_snapshot": false,
|
||||
"snapshot_identifier": null,
|
||||
"source_region": null,
|
||||
"storage_encrypted": false,
|
||||
"tags": null,
|
||||
"timeouts": null,
|
||||
"vpc_security_group_ids": [
|
||||
"sg-49e38646"
|
||||
]
|
||||
},
|
||||
{
|
||||
"allow_major_version_upgrade": null,
|
||||
"apply_immediately": null,
|
||||
"arn": "arn:aws:rds:us-east-1:533948124879:cluster:aurora-cluster-demo",
|
||||
"availability_zones": [
|
||||
"us-east-1a",
|
||||
"us-east-1b",
|
||||
"us-east-1d"
|
||||
],
|
||||
"backtrack_window": 0,
|
||||
"backup_retention_period": 5,
|
||||
"cluster_identifier": "aurora-cluster-demo-2",
|
||||
"cluster_identifier_prefix": null,
|
||||
"cluster_members": [
|
||||
"aurora-cluster-demo-0"
|
||||
],
|
||||
"cluster_resource_id": "cluster-TISYDSSX4J5R6ZGUTV6LLJW73E",
|
||||
"copy_tags_to_snapshot": false,
|
||||
"database_name": "",
|
||||
"db_cluster_parameter_group_name": "default.aurora-postgresql11",
|
||||
"db_subnet_group_name": "default",
|
||||
"deletion_protection": false,
|
||||
"enable_http_endpoint": false,
|
||||
"enabled_cloudwatch_logs_exports": null,
|
||||
"endpoint": "aurora-cluster-demo.cluster-cd539r6quiux.us-east-1.rds.amazonaws.com",
|
||||
"engine": "aurora-postgresql",
|
||||
"engine_mode": "provisioned",
|
||||
"engine_version": "11.9",
|
||||
"final_snapshot_identifier": null,
|
||||
"global_cluster_identifier": "",
|
||||
"hosted_zone_id": "Z2R2ITUGPM61AM",
|
||||
"iam_database_authentication_enabled": false,
|
||||
"iam_roles": null,
|
||||
"id": "aurora-cluster-demo",
|
||||
"kms_key_id": "",
|
||||
"master_password": null,
|
||||
"master_username": "foo",
|
||||
"port": 5432,
|
||||
"preferred_backup_window": "07:00-09:00",
|
||||
"preferred_maintenance_window": "fri:03:03-fri:03:33",
|
||||
"reader_endpoint": "aurora-cluster-demo.cluster-ro-cd539r6quiux.us-east-1.rds.amazonaws.com",
|
||||
"replication_source_identifier": "",
|
||||
"restore_to_point_in_time": null,
|
||||
"s3_import": null,
|
||||
"scaling_configuration": null,
|
||||
"skip_final_snapshot": false,
|
||||
"snapshot_identifier": null,
|
||||
"source_region": null,
|
||||
"storage_encrypted": false,
|
||||
"tags": null,
|
||||
"timeouts": null,
|
||||
"vpc_security_group_ids": [
|
||||
"sg-49e38646"
|
||||
]
|
||||
}
|
||||
]
|
|
@ -10,6 +10,7 @@ func initAwsRDSClusterMetaData(resourceSchemaRepository resource.SchemaRepositor
|
|||
resourceSchemaRepository.SetResolveReadAttributesFunc(AwsRDSClusterResourceType, func(res *resource.Resource) map[string]string {
|
||||
return map[string]string{
|
||||
"cluster_identifier": *res.Attributes().GetString("cluster_identifier"),
|
||||
"database_name": *res.Attributes().GetString("database_name"),
|
||||
}
|
||||
})
|
||||
resourceSchemaRepository.SetNormalizeFunc(AwsRDSClusterResourceType, func(res *resource.Resource) {
|
||||
|
@ -18,6 +19,10 @@ func initAwsRDSClusterMetaData(resourceSchemaRepository resource.SchemaRepositor
|
|||
val.SafeDelete([]string{"master_password"})
|
||||
val.SafeDelete([]string{"cluster_members"})
|
||||
val.SafeDelete([]string{"skip_final_snapshot"})
|
||||
val.SafeDelete([]string{"allow_major_version_upgrade"})
|
||||
val.SafeDelete([]string{"apply_immediately"})
|
||||
val.SafeDelete([]string{"final_snapshot_identifier"})
|
||||
val.SafeDelete([]string{"source_region"})
|
||||
})
|
||||
resourceSchemaRepository.SetFlags(AwsRDSClusterResourceType, resource.FlagDeepMode)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue