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

Iap iam rework #2178

Merged
merged 37 commits into from
Sep 5, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
9705265
WIP
slevenick Aug 8, 2019
ae80def
Generating iap_web_type iam resources
slevenick Aug 9, 2019
fe2c9c1
Whitespace in comment
slevenick Aug 9, 2019
0307395
Redoing from good point
slevenick Aug 13, 2019
245c2ee
Extract context generation
slevenick Aug 13, 2019
0381c67
Passing tests, needs cleanup
slevenick Aug 14, 2019
ff03694
Fix member test, set long name as name field in create
slevenick Aug 14, 2019
0aa2bd6
Remove change to iam api.yaml
slevenick Aug 14, 2019
9843348
Rename variables
slevenick Aug 14, 2019
f3e740c
Rework to split resources based on required fields
slevenick Aug 15, 2019
693707b
Fixing docs
slevenick Aug 15, 2019
8102570
Rubocop
slevenick Aug 15, 2019
7a1003a
Remove old handwritten test
slevenick Aug 15, 2019
fad345d
Set state during read
slevenick Aug 15, 2019
2f0adf7
Correct primary resource name for appengine test generation
slevenick Aug 15, 2019
d303cd4
Add backendServiceName description to iap web backend
slevenick Aug 15, 2019
224027b
Add IAP iam to website
slevenick Aug 15, 2019
9df937a
Extra erb end
slevenick Aug 15, 2019
96d8bc7
Reorder website
slevenick Aug 15, 2019
04eec3f
Add comments
slevenick Aug 16, 2019
844410f
PR feedback
slevenick Aug 26, 2019
1929fbd
Fix rebase issue in website
slevenick Aug 26, 2019
ec10de2
Refactoring iam attributes
slevenick Aug 27, 2019
454ddb4
Typo
slevenick Aug 27, 2019
77fb300
Refactor examples to use attributes generated during test
slevenick Aug 27, 2019
0e62857
Website rename
slevenick Aug 27, 2019
fc1484d
Try not setting extra fields
slevenick Aug 28, 2019
7cdcc38
Project doc updates
slevenick Aug 28, 2019
e961994
Fix import parsing logic
slevenick Aug 28, 2019
c2e787c
Enough arguments
slevenick Aug 28, 2019
99195a1
Add back pubsub handwritten test
slevenick Aug 28, 2019
51a4eee
PR feedback, spacing, moving methods to iam.go, naming
slevenick Aug 29, 2019
2112af9
Add required import
slevenick Aug 29, 2019
fc427bb
Default to viewer role, not editor
slevenick Aug 30, 2019
10032ea
PR comments, moving functions/not depending on project.id
slevenick Sep 5, 2019
58567cb
Remove unused import
slevenick Sep 5, 2019
d3f06f2
Update tracked submodules -> HEAD on Thu Sep 5 21:46:55 UTC 2019
modular-magician Sep 5, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions api/resource/iam_policy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,40 @@ class IamPolicy < Api::Object
# While Compute subnetwork uses {resource}/getIamPolicy
attr_reader :method_name_separator

# The terraform type of the parent resource if it is not the same as the
# IAM resource. The IAP product needs these as its IAM policies refer
# to compute resources
attr_reader :parent_resource_type

# Some resources allow retrieving the IAM policy with GET requests,
# others expect POST requests
attr_reader :fetch_iam_policy_verb

# Certain resources allow different sets of roles to be set with IAM policies
# This is a role that is acceptable for the given IAM policy resource for use in tests
attr_reader :allowed_iam_role

# Certain resources need an attribute other than "id" from their parent resource
# Especially when a parent is not the same type as the IAM resource
attr_reader :parent_resource_attribute

# If the IAM resource test needs a new project to be created, this is the name of the project
attr_reader :test_project_name

# Resource name may need a custom diff suppress function. Default is to use
# compareSelfLinkOrResourceName
attr_reader :custom_diff_suppress

def validate
super

check :exclude, type: :boolean, default: false
check :method_name_separator, type: String, default: '/'
check :parent_resource_type, type: String
check :fetch_iam_policy_verb, type: Symbol, default: :GET, allowed: %i[GET POST]
check :allowed_iam_role, type: String, default: 'roles/viewer'
check :parent_resource_attribute, type: String, default: 'id'
check :test_project_name, type: String
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion build/terraform
2 changes: 1 addition & 1 deletion build/terraform-beta
2 changes: 1 addition & 1 deletion build/terraform-mapper
75 changes: 75 additions & 0 deletions products/iap/api.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
# Copyright 2019 Google Inc.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

--- !ruby/object:Api::Product
name: Iap
display_name: Identity-Aware Proxy
versions:
- !ruby/object:Api::Product::Version
name: ga
base_url: https://iap.googleapis.com/v1/
scopes:
- https://www.googleapis.com/auth/cloud-platform
apis_required:
- !ruby/object:Api::Product::ApiReference
name: Cloud Identity-Aware Proxy
url: https://console.cloud.google.com/apis/library/iap.googleapis.com/
objects:
- !ruby/object:Api::Resource
name: 'Web'
base_url: 'projects/{{project}}/iap_web'
self_link: 'projects/{{project}}/iap_web'
exclude_resource: true
description: |
Only used to generate IAM resources
properties:
- !ruby/object:Api::Type::String
name: 'name'
description: Dummy property.
required: true
- !ruby/object:Api::Resource
name: 'WebTypeCompute'
base_url: 'projects/{{project}}/iap_web/compute'
self_link: 'projects/{{project}}/iap_web/compute'
exclude_resource: true
description: |
Only used to generate IAM resources
properties:
- !ruby/object:Api::Type::String
name: 'name'
description: Dummy property.
required: true
- !ruby/object:Api::Resource
name: 'WebTypeAppEngine'
base_url: 'projects/{{project}}/iap_web/appengine-{{appId}}'
self_link: 'projects/{{project}}/iap_web/appengine-{{appId}}'
exclude_resource: true
description: |
Only used to generate IAM resources
properties:
- !ruby/object:Api::Type::String
name: 'appId'
description: Id of the App Engine application.
required: true
- !ruby/object:Api::Resource
name: 'WebBackendService'
base_url: 'projects/{{project}}/iap_web/compute/services/{{backendServiceName}}'
self_link: 'projects/{{project}}/iap_web/compute/services/{{backendServiceName}}'
exclude_resource: true
description: |
Only used to generate IAM resources
properties:
- !ruby/object:Api::Type::String
name: 'backendServiceName'
description: Name or self link of a backend service.
required: true
92 changes: 92 additions & 0 deletions products/iap/terraform.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
# Copyright 2019 Google Inc.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

--- !ruby/object:Provider::Terraform::Config
overrides: !ruby/object:Overrides::ResourceOverrides
Web: !ruby/object:Overrides::Terraform::ResourceOverride
id_format: "projects/{{project}}/iap_web"
import_format: ["projects/{{project}}/iap_web"]
iam_policy: !ruby/object:Api::Resource::IamPolicy
exclude: false
method_name_separator: ':'
parent_resource_type: 'google_project_service'
fetch_iam_policy_verb: :POST
allowed_iam_role: 'roles/iap.httpsResourceAccessor'
parent_resource_attribute: 'project'
examples:
- !ruby/object:Provider::Terraform::Examples
name: "iap_project"
primary_resource_id: "project_service"
primary_resource_name: "fmt.Sprintf(\"tf-test%s\", context[\"random_suffix\"])"
test_env_vars:
org_id: :ORG_ID
WebTypeCompute: !ruby/object:Overrides::Terraform::ResourceOverride
iam_policy: !ruby/object:Api::Resource::IamPolicy
exclude: false
method_name_separator: ':'
parent_resource_type: 'google_project_service'
parent_resource_attribute: 'project'
fetch_iam_policy_verb: :POST
allowed_iam_role: 'roles/iap.httpsResourceAccessor'
id_format: "projects/{{project}}/iap_web/compute"
import_format: ["projects/{{project}}/iap_web/compute"]
examples:
- !ruby/object:Provider::Terraform::Examples
name: "iap_project"
primary_resource_id: "project_service"
primary_resource_name: "fmt.Sprintf(\"tf-test%s\", context[\"random_suffix\"])"
test_env_vars:
org_id: :ORG_ID
WebTypeAppEngine: !ruby/object:Overrides::Terraform::ResourceOverride
iam_policy: !ruby/object:Api::Resource::IamPolicy
exclude: false
method_name_separator: ':'
parent_resource_type: 'google_app_engine_application'
parent_resource_attribute: 'app_id'
fetch_iam_policy_verb: :POST
allowed_iam_role: 'roles/iap.httpsResourceAccessor'
test_project_name: "tf-test"
custom_diff_suppress: 'templates/terraform/iam/iap_web_appengine_diff_suppress.go.erb'
id_format: "projects/{{project}}/iap_web/appengine-{{appId}}"
import_format: ["projects/{{project}}/iap_web/appengine-{{appId}}"]
examples:
- !ruby/object:Provider::Terraform::Examples
name: "iap_appengine"
primary_resource_id: "app"
primary_resource_name: "context[\"project_id\"]"
test_env_vars:
org_id: :ORG_ID
WebBackendService: !ruby/object:Overrides::Terraform::ResourceOverride
iam_policy: !ruby/object:Api::Resource::IamPolicy
exclude: false
method_name_separator: ':'
parent_resource_type: 'google_compute_backend_service'
parent_resource_attribute: 'name'
fetch_iam_policy_verb: :POST
allowed_iam_role: 'roles/iap.httpsResourceAccessor'
id_format: "projects/{{project}}/iap_web/compute/services/{{backendServiceName}}"
import_format: ["projects/{{project}}/iap_web/compute/services/{{backendServiceName}}"]
examples:
- !ruby/object:Provider::Terraform::Examples
name: "backend_service_basic"
primary_resource_id: "default"
vars:
backend_service_name: "backend-service"
http_health_check_name: "health-check"
primary_resource_name: "fmt.Sprintf(\"backend-service%s\", context[\"random_suffix\"])"
# This is for copying files over
files: !ruby/object:Provider::Config::Files
# These files have templating (ERB) code that will be run.
# This is usually to add licensing info, autogeneration notices, etc.
compile:
<%= lines(indent(compile('provider/terraform/product~compile.yaml'), 4)) -%>
4 changes: 4 additions & 0 deletions provider/terraform.rb
Original file line number Diff line number Diff line change
Expand Up @@ -242,5 +242,9 @@ def build_object_data(object, output_folder, version)
build_env
)
end

def extract_identifiers(url)
url.scan(/\{\{(\w+)\}\}/).flatten
end
end
end
Loading