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 bigtable instance table. Closes #89 #90

Merged
merged 15 commits into from
Mar 25, 2021
Merged

Add bigtable instance table. Closes #89 #90

merged 15 commits into from
Mar 25, 2021

Conversation

Subhajit97
Copy link
Contributor

@Subhajit97 Subhajit97 commented Feb 8, 2021

Integration test logs

Logs
No env file present for the current environment:  staging 
 Falling back to .env config
No env file present for the current environment:  staging
customEnv TURBOT_TEST_EXPECTED_TIMEOUT 300

SETUP: tests/gcp_bigtable_instance []

PRETEST: tests/gcp_bigtable_instance

TEST: tests/gcp_bigtable_instance
Running terraform
data.google_client_config.current: Refreshing state...
google_service_account.named_test_resource: Creating...
google_bigtable_instance.named_test_resource: Creating...
google_service_account.named_test_resource: Creation complete after 7s [id=projects/pikachu-aaa/serviceAccounts/turbottest40695@pikachu-aaa.iam.gserviceaccount.com]
google_bigtable_instance.named_test_resource: Still creating... [10s elapsed]
google_bigtable_instance.named_test_resource: Creation complete after 11s [id=projects/pikachu-aaa/instances/turbottest40695]
google_bigtable_instance_iam_member.member: Creating...
google_bigtable_instance_iam_member.member: Still creating... [10s elapsed]
google_bigtable_instance_iam_member.member: Creation complete after 12s [id=projects/pikachu-aaa/instances/turbottest40695/roles/bigtable.user/serviceaccount:turbottest40695@pikachu-aaa.iam.gserviceaccount.com]

Warning: Deprecated Attribute

  on variables.tf line 46, in resource "google_bigtable_instance" "named_test_resource":
  46:   instance_type       = "DEVELOPMENT"

It is recommended to leave this field unspecified since the distinction
between "DEVELOPMENT" and "PRODUCTION" instances is going away, and all
instances will become "PRODUCTION" instances. This means that new and existing
"DEVELOPMENT" instances will be converted to "PRODUCTION" instances. It is
recommended for users to use "PRODUCTION" instances in any case, since a
1-node "PRODUCTION" instance is functionally identical to a "DEVELOPMENT"
instance, but without the accompanying restrictions.


Apply complete! Resources: 3 added, 0 changed, 0 destroyed.

Outputs:

email = turbottest40695@pikachu-aaa.iam.gserviceaccount.com
etag = BwW9Pq7a+GQ=
project_id = pikachu-aaa
resource_aka = gcp://bigtableadmin.googleapis.com/projects/pikachu-aaa/instances/turbottest40695
resource_id = projects/pikachu-aaa/instances/turbottest40695
resource_name = turbottest40695

Running SQL query: test-get-query.sql
[
  {
    "display_name": "turbottest40695",
    "instance_type": "DEVELOPMENT",
    "location": "global",
    "name": "turbottest40695",
    "project": "pikachu-aaa"
  }
]
✔ PASSED

Running SQL query: test-hydrate-query.sql
[
  {
    "iam_policy": {
      "bindings": [
        {
          "members": [
            "serviceAccount:turbottest40695@pikachu-aaa.iam.gserviceaccount.com"
          ],
          "role": "roles/bigtable.user"
        }
      ],
      "etag": "BwW9Pq7a+GQ=",
      "version": 1
    },
    "name": "turbottest40695"
  }
]
✔ PASSED

Running SQL query: test-invalid-name-query.sql
null
✔ PASSED

Running SQL query: test-list-query.sql
[
  {
    "display_name": "turbottest40695",
    "name": "turbottest40695"
  }
]
✔ PASSED

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

Running SQL query: test-turbot-query.sql
[
  {
    "akas": [
      "gcp://bigtableadmin.googleapis.com/projects/pikachu-aaa/instances/turbottest40695"
    ],
    "tags": {
      "name": "turbottest40695"
    },
    "title": "turbottest40695"
  }
]
✔ PASSED

POSTTEST: tests/gcp_bigtable_instance

TEARDOWN: tests/gcp_bigtable_instance

SUMMARY:

1/1 passed.

Example query results

Results

Basic info

select
  name,
  instance_type,
  state,
  location
from
  gcp_bigtable_instance;
+-----------------+---------------+-------+----------+
| name            | instance_type | state | location |
+-----------------+---------------+-------+----------+
| turbottest78783 | DEVELOPMENT   | READY | global   |
+-----------------+---------------+-------+----------+

List of members and their associated iam roles for the big table instance

select
  name,
  location,
  jsonb_array_elements_text(p -> 'members') as member,
  p ->> 'role' as role
from
  gcp_bigtable_instance,
  jsonb_array_elements(iam_policy -> 'bindings') as p;
+-----------------+----------+--------------------------------------------------------------------+---------------------+
| name            | location | member                                                             | role                |
+-----------------+----------+--------------------------------------------------------------------+---------------------+
| turbottest78783 | global   | serviceAccount:turbottest78783@pikachu-aaa.iam.gserviceaccount.com | roles/bigtable.user |
+-----------------+----------+--------------------------------------------------------------------+---------------------+

List of bigtable instances where members have bigtable admin access

select
  name,
  instance_type,
  jsonb_array_elements_text(i -> 'members') as members,
  i ->> 'role' as role
from
  gcp_bigtable_instance,
  jsonb_array_elements(iam_policy -> 'bindings') as i
where
  i ->> 'role' like '%bigtable.admin';
+-----------------+---------------+------------------------------+----------------------+
| name            | instance_type | members                      | role                 |
+-----------------+---------------+------------------------------+----------------------+
| turbottest78783 | DEVELOPMENT   | user:subhajit.das@turbot.com | roles/bigtable.admin |
+-----------------+---------------+------------------------------+----------------------+

Count of production instances

select
  instance_type,
  count(name)
from
  gcp_bigtable_instance
where
  instance_type = 'PRODUCTION'
group by
  instance_type;
+---------------+-------+
| instance_type | count |
+---------------+-------+
+---------------+-------+

@Subhajit97 Subhajit97 self-assigned this Feb 8, 2021
@Subhajit97 Subhajit97 marked this pull request as ready for review February 8, 2021 13:01
@Subhajit97 Subhajit97 linked an issue Feb 9, 2021 that may be closed by this pull request
@cbruno10 cbruno10 changed the base branch from main to v0.3.0 March 10, 2021 14:36
@cbruno10 cbruno10 changed the base branch from v0.3.0 to main March 24, 2021 15:21
Copy link
Contributor

@LalitLab LalitLab left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link

@rajlearner17 rajlearner17 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@cbruno10 cbruno10 merged commit 1bf2037 into main Mar 25, 2021
@cbruno10 cbruno10 deleted the issue-89 branch March 25, 2021 18:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add bigtable instance table
5 participants