-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Appengine's firewall rules. (#1081)
Merged PR #1081.
- Loading branch information
1 parent
a269f7d
commit 7e78e6f
Showing
13 changed files
with
224 additions
and
15 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
Submodule terraform
updated
from 0385bf to 142ef9
Submodule terraform-beta
updated
from 248772 to a6dab8
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,64 @@ | ||
# Copyright 2018 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: Google App Engine | ||
prefix: gappengine | ||
versions: | ||
- !ruby/object:Api::Product::Version | ||
name: ga | ||
base_url: https://appengine.googleapis.com/v1/ | ||
scopes: | ||
- https://www.googleapis.com/auth/cloud-platform | ||
objects: | ||
- !ruby/object:Api::Resource | ||
name: 'FirewallRule' | ||
description: | | ||
A single firewall rule that is evaluated against incoming traffic | ||
and provides an action to take on matched requests. | ||
base_url: 'apps/{{project}}/firewall/ingressRules' | ||
self_link: 'apps/{{project}}/firewall/ingressRules/{{priority}}' | ||
update_verb: :PATCH | ||
references: !ruby/object:Api::Resource::ReferenceLinks | ||
guides: | ||
'Official Documentation': | ||
'https://cloud.google.com/appengine/docs/standard/python/creating-firewalls#creating_firewall_rules' | ||
api: 'https://cloud.google.com/appengine/docs/admin-api/reference/rest/v1/apps.firewall.ingressRules' | ||
parameters: | ||
- !ruby/object:Api::Type::Integer | ||
name: 'priority' | ||
description: | | ||
A positive integer that defines the order of rule evaluation. | ||
Rules with the lowest priority are evaluated first. | ||
A default rule at priority Int32.MaxValue matches all IPv4 and | ||
IPv6 traffic when no previous rule matches. Only the action of | ||
this rule can be modified by the user. | ||
properties: | ||
- !ruby/object:Api::Type::String | ||
name: 'description' | ||
description: 'An optional string description of this rule.' | ||
required: false | ||
- !ruby/object:Api::Type::String | ||
name: 'sourceRange' | ||
description: 'IP address or range, defined using CIDR notation, of requests that this rule applies to.' | ||
required: true | ||
- !ruby/object:Api::Type::Enum | ||
name: 'action' | ||
description: | | ||
The action to take if this rule matches. | ||
required: true | ||
values: | ||
- UNSPECIFIED_ACTION | ||
- ALLOW | ||
- DENY |
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,36 @@ | ||
# Copyright 2017 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:Provider::ResourceOverrides | ||
FirewallRule: !ruby/object:Provider::Terraform::ResourceOverride | ||
id_format: "{{project}}/{{priority}}" | ||
import_format: ["{{project}}/{{priority}}"] | ||
custom_code: !ruby/object:Provider::Terraform::CustomCode | ||
pre_update: templates/terraform/pre_update/update_mask.erb | ||
example: | ||
- !ruby/object:Provider::Terraform::Examples | ||
name: "appengine_firewall_rule_basic" | ||
primary_resource_id: "rule" | ||
version: <%= version_name %> | ||
vars: | ||
project_id: "test-project" | ||
test_env_vars: | ||
org_id: :ORG_ID | ||
|
||
# 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)) -%> |
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 |
---|---|---|
|
@@ -66,8 +66,27 @@ class Examples < Api::Object | |
# } | ||
attr_reader :primary_resource_id | ||
|
||
# vars is a Hash from template variable names to output variable names | ||
# vars is a Hash from template variable names to output variable names. | ||
# It will use the provided value as a prefix for generated tests, and | ||
# insert it into the docs verbatim. | ||
attr_reader :vars | ||
# Some variables need to hold special values during tests, and cannot | ||
# be inferred by Open in Cloud Shell. For instance, org_id | ||
# needs to be the correct value during integration tests, or else | ||
# org tests cannot pass. Other examples include an existing project_id, | ||
# a zone, a service account name, etc. | ||
# | ||
# test_env_vars is a Hash from template variable names to one of the | ||
# following symbols: | ||
# - :PROJECT_NAME | ||
# - :CREDENTIALS | ||
# - :REGION | ||
# - :ORG_ID | ||
# - :ORG_TARGET | ||
# - :BILLING_ACCT | ||
# - :SERVICE_ACCT | ||
# This list corresponds to the `get*FromEnv` methods in provider_test.go. | ||
attr_reader :test_env_vars | ||
|
||
# the version (ga, beta, etc.) this example is being generated at | ||
attr_reader :version | ||
|
@@ -80,9 +99,21 @@ class Examples < Api::Object | |
attr_reader :skip_test | ||
|
||
def config_documentation | ||
docs_defaults = { | ||
PROJECT_NAME: 'my-project-name', | ||
CREDENTIALS: 'my/credentials/filename.json', | ||
REGION: 'us-west1', | ||
ORG_ID: '123456789', | ||
ORG_TARGET: '123456789', | ||
BILLING_ACCT: '000000-0000000-0000000-000000', | ||
SERVICE_ACCT: 'emailAddress:[email protected]' | ||
} | ||
@vars ||= {} | ||
@test_env_vars ||= {} | ||
body = lines(compile_file( | ||
{ | ||
vars: vars, | ||
test_env_vars: test_env_vars.map { |k, v| [k, docs_defaults[v]] }.to_h, | ||
primary_resource_id: primary_resource_id, | ||
version: version | ||
}, | ||
|
@@ -95,10 +126,12 @@ def config_documentation | |
end | ||
|
||
def config_test | ||
@vars ||= [] | ||
@vars ||= {} | ||
@test_env_vars ||= {} | ||
body = lines(compile_file( | ||
{ | ||
vars: vars.map { |k, str| [k, "#{str}-%s"] }.to_h, | ||
vars: vars.map { |k, str| [k, "#{str}-%{random_suffix}"] }.to_h, | ||
test_env_vars: test_env_vars.map { |k, _| [k, "%{#{k}}"] }.to_h, | ||
primary_resource_id: primary_resource_id, | ||
version: version | ||
}, | ||
|
17 changes: 17 additions & 0 deletions
17
templates/terraform/examples/appengine_firewall_rule_basic.tf.erb
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,17 @@ | ||
resource "google_project" "my_project" { | ||
name = "tf-test-project" | ||
project_id = "<%= ctx[:vars]['project_id'] %>" | ||
org_id = "<%= ctx[:test_env_vars]['org_id'] %>" | ||
} | ||
|
||
resource "google_app_engine_application" "app" { | ||
project = "${google_project.my_project.project_id}" | ||
location_id = "us-central" | ||
} | ||
|
||
resource "google_appengine_firewall_rule" "rule" { | ||
project = "${google_app_engine_application.app.project}" | ||
priority = 1000 | ||
action = "ALLOW" | ||
source_range = "*" | ||
} |
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 |
---|---|---|
@@ -1,4 +1,3 @@ | ||
return fmt.Sprintf(` | ||
return Nprintf(` | ||
<%= ctx[:content] -%> | ||
`,<%= " val," * ctx[:count] %> | ||
) | ||
`, context) |
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
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
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
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
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