We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Hello,
Assuming I have the following resource:
resource "google_service_account" "sa" { account_id = "sa" display_name = "sa" lifecycle { prevent_destroy = true } }
What would the rule look like that could assert that prevent_destroy is present and true? I assumed:
--- version: 1 description: Google-specific Terraform Rules type: Terraform files: - "*.tf" rules: - id: PREVENT_DESTROY_IN_SERVICE_ACCOUNT message: "Service Account definitions must have prevent_destroy set" category: resource resources: - google_service_account assertions: - key: lifecycle.prevent_destroy op: eq value: true
would work, but it fails:
{ "AssertionMessage": "lifecycle.prevent_destroy(null) should be equal to true", "Category": "resource", "CreatedAt": "2020-10-16T14:59:05Z", "Filename": "test/sa.tf", "LineNumber": 1, "ResourceID": "sa", "ResourceType": "google_service_account", "RuleID": "PREVENT_DESTROY_IN_SERVICE_ACCOUNT", "RuleMessage": "Service Account definitions must have prevent_destroy set", "Status": "FAILURE" }
The text was updated successfully, but these errors were encountered:
Figured it out. lifecycle is an array (though I don't understand why).
lifecycle
--- version: 1 description: Google-specific Terraform Rules type: Terraform files: - "*.tf" rules: - id: PREVENT_DESTROY_IN_SERVICE_ACCOUNT message: "Service Account definitions must have prevent_destroy set" category: resource resources: - google_service_account assertions: - exactly-one: key: "lifecycle[]" expressions: - key: prevent_destroy op: is-true
Sorry, something went wrong.
No branches or pull requests
Hello,
Assuming I have the following resource:
What would the rule look like that could assert that prevent_destroy is present and true? I assumed:
would work, but it fails:
The text was updated successfully, but these errors were encountered: