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

fix KeyError when billing permission requirements are unsatisfied #175

Conversation

sosimon
Copy link
Contributor

@sosimon sosimon commented Mar 29, 2019

Instead of throwing a KeyError like this:

* module.project-factory.module.project-factory.null_resource.preconditions: Error running command '/cft/workdir/test/fixtures/minimal/.terraform/modules/76c2ddba7cd279abe2254470a2c70bac/scripts/prec
onditions.sh \
           --credentials_path '' \
           --billing_account '<redacted>' \
           --org_id '<redacted>' \
           --folder_id '<redacted>' \
           --shared_vpc ''
       ': exit status 1. Output: Traceback (most recent call last):
         File "/cft/workdir/test/fixtures/minimal/.terraform/modules/76c2ddba7cd279abe2254470a2c70bac/scripts/preconditions/preconditions.py", line 455, in <module>
           retcode = main(sys.argv)
         File "/cft/workdir/test/fixtures/minimal/.terraform/modules/76c2ddba7cd279abe2254470a2c70bac/scripts/preconditions/preconditions.py", line 437, in main
           results.append(validator.validate(credentials))
         File "/cft/workdir/test/fixtures/minimal/.terraform/modules/76c2ddba7cd279abe2254470a2c70bac/scripts/preconditions/preconditions.py", line 298, in validate
           response["permissions"],
       KeyError: 'permissions'

The precondition script will output a proper error like this:

* module.project-factory.module.project-factory.null_resource.preconditions: Error running command '/cft/workdir/test/fixtures/minimal/.terraform/modules/76c2ddba7cd279abe2254470a2c70bac/scripts/prec
onditions.sh \
           --credentials_path '' \
           --billing_account '<redacted>' \
           --org_id '<redacted>' \
           --folder_id '<redacted>' \
           --shared_vpc ''
       ': exit status 1. Output: [
           {
        "type": "Required APIs on service account project",
        "name": "projects/cft-seed",
        "satisfied": [
            "appengine.googleapis.com",
            "iam.googleapis.com",
            "cloudresourcemanager.googleapis.com",
            "admin.googleapis.com",
            "cloudbilling.googleapis.com"
        ],
        "unsatisfied": []
           },
           {
        "type": "Service account permissions on billing account",
        "name": "billingAccounts/<redacted>",
        "satisfied": [],
        "unsatisfied": [
            "billing.resourceAssociations.create"
        ]
           },
           {
        "type": "Service account permissions on parent folder",
        "name": "folders/<redacted>",
        "satisfied": [],
        "unsatisfied": [
            "resourcemanager.projects.create"
        ]
           },
           {
        "type": "Service account permissions on organization",
        "name": "organizations/<redacted>",
        "satisfied": [],
        "unsatisfied": [
            "resourcemanager.organizations.get"
        ]
           }
       ]

InSpec's support for semantic versioning of git dependencies is
currently broken.
@aaron-lane aaron-lane merged commit 8949175 into terraform-google-modules:master Apr 1, 2019
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.

2 participants