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 table gcp_compute_resource_policy. Closes #236 #237

Merged
merged 5 commits into from
Jun 24, 2021
Merged

Conversation

Subhajit97
Copy link
Contributor

@Subhajit97 Subhajit97 commented Jun 22, 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 undefined

SETUP: tests/gcp_compute_resource_policy []

PRETEST: tests/gcp_compute_resource_policy

TEST: tests/gcp_compute_resource_policy
Running terraform
data.google_client_config.current: Refreshing state...
data.null_data_source.resource: Refreshing state...
google_compute_resource_policy.named_test_resource: Creating...
google_compute_resource_policy.named_test_resource: Still creating... [10s elapsed]
google_compute_resource_policy.named_test_resource: Creation complete after 13s [id=projects/parker-aaa/regions/us-east1/resourcePolicies/turbottest56825]

Warning: Deprecated Resource

The null_data_source was historically used to construct intermediate values to
re-use elsewhere in configuration, the same can now be achieved using locals


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

Outputs:

project_id = parker-aaa
resource_aka = gcp://compute.googleapis.com/projects/parker-aaa/regions/us-east1/resourcePolicies/turbottest56825
resource_name = turbottest56825
self_link = https://www.googleapis.com/compute/v1/projects/parker-aaa/regions/us-east1/resourcePolicies/turbottest56825

Running SQL query: test-get-query.sql
[
  {
    "description": "Start and stop instances",
    "instance_schedule_policy": {
      "timeZone": "US/Central",
      "vmStartSchedule": {
        "schedule": "0 * * * *"
      },
      "vmStopSchedule": {
        "schedule": "15 * * * *"
      }
    },
    "kind": "compute#resourcePolicy",
    "name": "turbottest56825",
    "self_link": "https://www.googleapis.com/compute/v1/projects/parker-aaa/regions/us-east1/resourcePolicies/turbottest56825",
    "status": "READY"
  }
]
✔ PASSED

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

Running SQL query: test-list-query.sql
[
  {
    "description": "Start and stop instances",
    "name": "turbottest56825"
  }
]
✔ PASSED

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

Running SQL query: test-turbot-query.sql
[
  {
    "akas": [
      "gcp://compute.googleapis.com/projects/parker-aaa/regions/us-east1/resourcePolicies/turbottest56825"
    ],
    "title": "turbottest56825"
  }
]
✔ PASSED

POSTTEST: tests/gcp_compute_resource_policy

TEARDOWN: tests/gcp_compute_resource_policy

SUMMARY:

1/1 passed.

Example query results

Results

Basic info

select
  name,
  status,
  self_link
from
  gcp_compute_resource_policy;
+-----------------+--------+-------------------------------------------------------------------------------------------------------------+
| name            | status | self_link                                                                                                   |
+-----------------+--------+-------------------------------------------------------------------------------------------------------------+
| turbottest24695 | READY  | https://www.googleapis.com/compute/v1/projects/parker-aaa/regions/us-east1/resourcePolicies/turbottest24695 |
+-----------------+--------+-------------------------------------------------------------------------------------------------------------+

List of policy used to schedule an instance

select
  p.name as policy_name,
  i.name,
  p.instance_schedule_policy
from
  gcp_compute_resource_policy as p
  join gcp_compute_instance as i on i.resource_policies ?| array[p.self_link]
where
  p.instance_schedule_policy is not null;
+-------------------+---------------------+---------------------------------------------------------------------------------------------------------------------------------------+
| policy_name       | name                | instance_schedule_policy                                                                                                              |
+-------------------+---------------------+---------------------------------------------------------------------------------------------------------------------------------------+
| businesshours     | instance-1-test003  | {"timeZone":"America/Indiana/Knox","vmStartSchedule":{"schedule":"0 8 * * Mon,Fri"},"vmStopSchedule":{"schedule":"0 20 * * Mon,Fri"}} |
| schedule-test-002 | instance-1-test-002 | {"timeZone":"America/Phoenix","vmStartSchedule":{"schedule":"1 7 * * *"},"vmStopSchedule":{"schedule":"6 23 * * *"}}                  |
+-------------------+---------------------+---------------------------------------------------------------------------------------------------------------------------------------+

@Subhajit97 Subhajit97 requested a review from LalitLab June 22, 2021 15:08
@Subhajit97 Subhajit97 self-assigned this Jun 22, 2021
@Subhajit97 Subhajit97 linked an issue Jun 22, 2021 that may be closed by this pull request
@Subhajit97 Subhajit97 linked an issue Jun 24, 2021 that may be closed by this pull request
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

@Subhajit97 Subhajit97 requested a review from cbruno10 June 24, 2021 08:04
@cbruno10 cbruno10 merged commit dfc968e into main Jun 24, 2021
@cbruno10 cbruno10 deleted the issue-236 branch June 24, 2021 13:59
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.

Update google golang sdk to v0.48.0 Add table gcp_compute_resource_policy
5 participants