forked from inspec/inspec-gcp
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request inspec#155 from modular-magician/codegen-pr-1758
Add pubsub subscription and topic iam policies, update example docs
- Loading branch information
Showing
5 changed files
with
207 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,8 +12,11 @@ describe google_compute_subnetwork_iam_policy(project: "project", region: "regio | |
it { should exist } | ||
end | ||
describe google_compute_subnetwork_iam_policy(project: "project", region: "region", name: "name").bindings do |binding| | ||
its('role') { should_not eq 'roles/owner' } | ||
google_compute_subnetwork_iam_policy(project: "project", region: "region", name: "name").bindings.each do |binding| | ||
describe binding do | ||
its('role') { should eq 'roles/editor'} | ||
its('members') { should include 'user:[email protected]'} | ||
end | ||
end | ||
``` | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
--- | ||
title: About the google_pubsub_subscription_iam_policy resource | ||
platform: gcp | ||
--- | ||
|
||
## Syntax | ||
A `google_pubsub_subscription_iam_policy` is used to test a Google Subscription Iam Policy resource | ||
|
||
## Examples | ||
``` | ||
describe google_pubsub_subscription_iam_policy(project: "project", name: "name") do | ||
it { should exist } | ||
end | ||
google_pubsub_subscription_iam_policy(project: "project", name: "name").bindings.each do |binding| | ||
describe binding do | ||
its('role') { should eq 'roles/editor'} | ||
its('members') { should include 'user:[email protected]'} | ||
end | ||
end | ||
``` | ||
|
||
## Properties | ||
Properties that can be accessed from the `google_pubsub_subscription_iam_policy` resource: | ||
|
||
* `bindings`: Associates a list of members to a role. | ||
|
||
* `role`: Role that is assigned to members. For example, roles/viewer, roles/editor, or roles/owner. | ||
|
||
* `members`: Specifies the identities requesting access for a Cloud Platform resource. | ||
|
||
* `audit_configs`: Specifies cloud audit logging configuration for this policy. | ||
|
||
* `service`: Specifies a service that will be enabled for audit logging. For example, `storage.googleapis.com`, `cloudsql.googleapis.com`. `allServices` is a special value that covers all services. | ||
|
||
* `audit_log_configs`: The configuration for logging of each type of permission. | ||
|
||
|
||
|
||
## GCP Permissions | ||
|
||
Ensure the [Cloud Pub/Sub API](https://console.cloud.google.com/apis/library/pubsub.googleapis.com/) is enabled for the current project. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
--- | ||
title: About the google_pubsub_topic_iam_policy resource | ||
platform: gcp | ||
--- | ||
|
||
## Syntax | ||
A `google_pubsub_topic_iam_policy` is used to test a Google Topic Iam Policy resource | ||
|
||
## Examples | ||
``` | ||
describe google_pubsub_topic_iam_policy(project: "project", name: "name") do | ||
it { should exist } | ||
end | ||
google_pubsub_topic_iam_policy(project: "project", name: "name").bindings.each do |binding| | ||
describe binding do | ||
its('role') { should eq 'roles/editor'} | ||
its('members') { should include 'user:[email protected]'} | ||
end | ||
end | ||
``` | ||
|
||
## Properties | ||
Properties that can be accessed from the `google_pubsub_topic_iam_policy` resource: | ||
|
||
* `bindings`: Associates a list of members to a role. | ||
|
||
* `role`: Role that is assigned to members. For example, roles/viewer, roles/editor, or roles/owner. | ||
|
||
* `members`: Specifies the identities requesting access for a Cloud Platform resource. | ||
|
||
* `audit_configs`: Specifies cloud audit logging configuration for this policy. | ||
|
||
* `service`: Specifies a service that will be enabled for audit logging. For example, `storage.googleapis.com`, `cloudsql.googleapis.com`. `allServices` is a special value that covers all services. | ||
|
||
* `audit_log_configs`: The configuration for logging of each type of permission. | ||
|
||
|
||
|
||
## GCP Permissions | ||
|
||
Ensure the [Cloud Pub/Sub API](https://console.cloud.google.com/apis/library/pubsub.googleapis.com/) is enabled for the current project. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
# frozen_string_literal: false | ||
|
||
# ---------------------------------------------------------------------------- | ||
# | ||
# *** AUTO GENERATED CODE *** AUTO GENERATED CODE *** | ||
# | ||
# ---------------------------------------------------------------------------- | ||
# | ||
# This file is automatically generated by Magic Modules and manual | ||
# changes will be clobbered when the file is regenerated. | ||
# | ||
# Please read more about how to change this file in README.md and | ||
# CONTRIBUTING.md located at the root of this package. | ||
# | ||
# ---------------------------------------------------------------------------- | ||
require 'gcp_backend' | ||
require 'google/iam/property/iam_policy_audit_configs' | ||
require 'google/iam/property/iam_policy_bindings' | ||
|
||
# A provider to manage Cloud Pub/Sub IAM Policy resources. | ||
class SubscriptionIamPolicy < GcpResourceBase | ||
name 'google_pubsub_subscription_iam_policy' | ||
desc 'Subscription Iam Policy' | ||
supports platform: 'gcp' | ||
|
||
attr_reader :params | ||
attr_reader :bindings | ||
attr_reader :audit_configs | ||
|
||
def initialize(params) | ||
super(params.merge({ use_http_transport: true })) | ||
@params = params | ||
@fetched = @connection.fetch(product_url, resource_base_url, params) | ||
parse unless @fetched.nil? | ||
end | ||
|
||
def parse | ||
@bindings = GoogleInSpec::Iam::Property::IamPolicyBindingsArray.parse(@fetched['bindings'], to_s) | ||
@audit_configs = GoogleInSpec::Iam::Property::IamPolicyAuditConfigsArray.parse(@fetched['auditConfigs'], to_s) | ||
end | ||
|
||
def exists? | ||
!@fetched.nil? | ||
end | ||
|
||
def to_s | ||
"Subscription IamPolicy #{@params[:name]}" | ||
end | ||
|
||
private | ||
|
||
def product_url | ||
'https://pubsub.googleapis.com/v1/' | ||
end | ||
|
||
def resource_base_url | ||
'projects/{{project}}/subscriptions/{{name}}:getIamPolicy' | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
# frozen_string_literal: false | ||
|
||
# ---------------------------------------------------------------------------- | ||
# | ||
# *** AUTO GENERATED CODE *** AUTO GENERATED CODE *** | ||
# | ||
# ---------------------------------------------------------------------------- | ||
# | ||
# This file is automatically generated by Magic Modules and manual | ||
# changes will be clobbered when the file is regenerated. | ||
# | ||
# Please read more about how to change this file in README.md and | ||
# CONTRIBUTING.md located at the root of this package. | ||
# | ||
# ---------------------------------------------------------------------------- | ||
require 'gcp_backend' | ||
require 'google/iam/property/iam_policy_audit_configs' | ||
require 'google/iam/property/iam_policy_bindings' | ||
|
||
# A provider to manage Cloud Pub/Sub IAM Policy resources. | ||
class TopicIamPolicy < GcpResourceBase | ||
name 'google_pubsub_topic_iam_policy' | ||
desc 'Topic Iam Policy' | ||
supports platform: 'gcp' | ||
|
||
attr_reader :params | ||
attr_reader :bindings | ||
attr_reader :audit_configs | ||
|
||
def initialize(params) | ||
super(params.merge({ use_http_transport: true })) | ||
@params = params | ||
@fetched = @connection.fetch(product_url, resource_base_url, params) | ||
parse unless @fetched.nil? | ||
end | ||
|
||
def parse | ||
@bindings = GoogleInSpec::Iam::Property::IamPolicyBindingsArray.parse(@fetched['bindings'], to_s) | ||
@audit_configs = GoogleInSpec::Iam::Property::IamPolicyAuditConfigsArray.parse(@fetched['auditConfigs'], to_s) | ||
end | ||
|
||
def exists? | ||
!@fetched.nil? | ||
end | ||
|
||
def to_s | ||
"Topic IamPolicy #{@params[:name]}" | ||
end | ||
|
||
private | ||
|
||
def product_url | ||
'https://pubsub.googleapis.com/v1/' | ||
end | ||
|
||
def resource_base_url | ||
'projects/{{project}}/topics/{{name}}:getIamPolicy' | ||
end | ||
end |