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

gcp.service does not support disable action #6302

Closed
rfoltak opened this issue Nov 19, 2020 · 3 comments · Fixed by #6320
Closed

gcp.service does not support disable action #6302

rfoltak opened this issue Nov 19, 2020 · 3 comments · Fixed by #6320

Comments

@rfoltak
Copy link

rfoltak commented Nov 19, 2020

Describe the bug
disable action not working for gcp.service resource type

To Reproduce
run the example code found in https://cloudcustodian.io/docs/gcp/resources/service.html

Expected behavior
expected an enabled service to be explicitly disabled... Instead, got a error in the code.

Background (please complete the following information):

  • OS: Debian (default GCP OS)
  • Python Version: [e.g. python 3.8.1]
  • Custodian Version: 0.9.8
  • Tool Version: c7n_gcp-0.4.7.dist-info
  • Cloud Provider: gcp
  • Policy: example policy from https://cloudcustodian.io/docs/gcp/resources/service.html
  • Traceback:
    2020-11-18 19:38:59,551: custodian.output:ERROR Error while executing policy
    Traceback (most recent call last):
    File "/usr/local/lib/python3.7/dist-packages/c7n/policy.py", line 316, in run
    results = a.process(resources)
    File "/usr/local/lib/python3.7/dist-packages/c7n_gcp/actions/core.py", line 65, in process
    self.process_resource_set(client, model, resource_set)
    File "/usr/local/lib/python3.7/dist-packages/c7n_gcp/actions/core.py", line 73, in process_resource_set
    result = self.invoke_api(client, op_name, params)
    File "/usr/local/lib/python3.7/dist-packages/c7n_gcp/actions/core.py", line 79, in invoke_api
    return client.execute_command(op_name, params)
    File "/usr/local/lib/python3.7/dist-packages/c7n_gcp/client.py", line 398, in execute_command
    request = self._build_request(verb, verb_arguments)
    File "/usr/local/lib/python3.7/dist-packages/c7n_gcp/client.py", line 345, in _build_request
    method = getattr(self._component, verb)
    AttributeError: 'Resource' object has no attribute 'disable'
  • custodian version --debug output

Additional context
Add any other context about the problem here.

@Ripza
Copy link

Ripza commented Dec 2, 2020

Hi,
I recently review the documentation, the method is deprecated: https://cloud.google.com/service-infrastructure/docs/service-management/reference/rest/v1/services/disable

This is the new API to disable services: https://cloud.google.com/service-usage/docs/reference/rest/v1/services/disable

I don't known how to create a new resource by myself yet in cloud custodian, so maybe another person could create the new resource

@kapilt
Copy link
Collaborator

kapilt commented Dec 2, 2020

@Ripza thanks for the info, it seems like the right thing would be to just switch out from the 'deprecated'/broken servicemanagement api to service-usage.. i've added a pull request to that effect.

@Ripza
Copy link

Ripza commented Dec 2, 2020

@kapilt Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants