steampipe-plugin-aws icon indicating copy to clipboard operation
steampipe-plugin-aws copied to clipboard

Add table aws_docdb_cluster Closes #1006

Open karanpopat opened this issue 2 years ago • 4 comments

Integration test logs

Logs
Outputs:

account_id = "533793682495"
aws_partition = "aws"
endpoint = "turbottest64532.cluster-c0e80t0lbvg7.us-east-1.docdb.amazonaws.com"
region_name = "us-east-1"
resource_aka = "arn:aws:rds:us-east-1:533793682495:cluster:turbottest64532"
resource_id = "cluster-LHNWP323HC35LOZWRN7V7JXXS4"
resource_name = "turbottest64532"

Running SQL query: test-get-query.sql
[
  {
    "arn": "arn:aws:rds:us-east-1:533793682495:cluster:turbottest64532",
    "db_cluster_identifier": "turbottest64532",
    "deletion_protection": false,
    "endpoint": "turbottest64532.cluster-c0e80t0lbvg7.us-east-1.docdb.amazonaws.com",
    "engine": "docdb",
    "master_user_name": "turbottest",
    "multi_az": false,
    "storage_encrypted": false,
    "tags_src": [
      {
        "Key": "name",
        "Value": "turbottest64532"
      }
    ]
  }
]
✔ PASSED

Running SQL query: test-hydrate-query.sql
[
  {
    "arn": "arn:aws:rds:us-east-1:533793682495:cluster:turbottest64532",
    "db_cluster_identifier": "turbottest64532",
    "deletion_protection": false,
    "endpoint": "turbottest64532.cluster-c0e80t0lbvg7.us-east-1.docdb.amazonaws.com",
    "engine": "docdb",
    "master_user_name": "turbottest",
    "multi_az": false,
    "storage_encrypted": false,
    "tags_src": [
      {
        "Key": "name",
        "Value": "turbottest64532"
      }
    ]
  }
]
✔ PASSED

Running SQL query: test-list-query.sql
[
  {
    "arn": "arn:aws:rds:us-east-1:533793682495:cluster:turbottest64532",
    "db_cluster_identifier": "turbottest64532"
  }
]
✔ PASSED

Running SQL query: test-not-found-query.sql
null
✔ PASSED

Running SQL query: test-turbot-query.sql
[
  {
    "akas": [
      "arn:aws:rds:us-east-1:533793682495:cluster:turbottest64532"
    ],
    "db_cluster_identifier": "turbottest64532",
    "tags": {
      "name": "turbottest64532"
    },
    "title": "turbottest64532"
  }
]
✔ PASSED

POSTTEST: tests/aws_docdb_cluster

TEARDOWN: tests/aws_docdb_cluster

SUMMARY:

1/1 passed.

Example query results

Results
> select
  db_cluster_identifier,
  status,
  create_time,
  kms_key_id,
  storage_encrypted
from
  aws_docdb_cluster
where
  not storage_encrypted;
+---------------------------+-----------+---------------------------+------------+-------------------+
| db_cluster_identifier     | status    | create_time               | kms_key_id | storage_encrypted |
+---------------------------+-----------+---------------------------+------------+-------------------+
| docdb-2022-05-16-13-57-40 | available | 2022-05-16T19:29:37+05:30 | <null>     | false             |
+---------------------------+-----------+---------------------------+------------+-------------------+

> select
  db_cluster_identifier,
  member ->> 'DBClusterParameterGroupStatus' as db_cluster_parameter_group_status,
  member ->> 'DBInstanceIdentifier' as db_instance_identifier,
  member ->> 'IsClusterWriter' as is_cluster_writer,
  member ->> 'PromotionTier' as promotion_tier
from
  aws_docdb_cluster
  cross join jsonb_array_elements(members) as member;

+---------------------------+-----------------------------------+---------------------------+-------------------+----------------+
| db_cluster_identifier     | db_cluster_parameter_group_status | db_instance_identifier    | is_cluster_writer | promotion_tier |
+---------------------------+-----------------------------------+---------------------------+-------------------+----------------+
| docdb-2022-05-16-13-57-40 | in-sync                           | docdb-2022-05-16-13-57-40 | true              | 1              |
+---------------------------+-----------------------------------+---------------------------+-------------------+----------------+

karanpopat avatar May 17 '22 06:05 karanpopat

Already addressed part of aws_rds_db_cluster

rajlearner17 avatar May 24 '22 05:05 rajlearner17

I don't think docDB can be inquired in aws_rds_cluster table. So why don't we open this PR again? @karanpopat @rajlearner17

wesky93 avatar Aug 31 '22 15:08 wesky93

@wesky93 I agree, aws_docdb_cluster should be a separate table (similar to how TF has a separate resource, aws_docdb_cluster for it).

We'll re-open this PR and look to merge it in when ready.

cbruno10 avatar Aug 31 '22 15:08 cbruno10

@karanpopat Can you please resolve merge conflicts?

Also, please see the changes we did to the aws_neptune_db_cluster and aws_rds_db_cluster tables around engine filtering + table doc updates, to ensure that we're only getting DocDB clusters in this table:

  • https://github.com/turbot/steampipe-plugin-aws/commit/8f82fee1fa738e3e96cdf0efbbaad326270505e9
  • https://github.com/turbot/steampipe-plugin-aws/commit/bdf88ee47d8440f77a10464086a1eae6bcf0dc8b

cbruno10 avatar Aug 31 '22 15:08 cbruno10