Skip to content

Commit

Permalink
Merge branch 'master' into extract-bigtable-instance-type-from-instan…
Browse files Browse the repository at this point in the history
…ceinfo
  • Loading branch information
nickmoorman committed Oct 22, 2019
2 parents bc8246d + 28c2961 commit d30fe62
Show file tree
Hide file tree
Showing 44 changed files with 472 additions and 747 deletions.
4 changes: 2 additions & 2 deletions .ci/ci.yml.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -192,15 +192,15 @@ jobs:

- put: {{v.short_name}}-intermediate
params:
repository: terraform-diff/new
repository: terraform-diff/{{k}}/new
branch_file: magic-modules-branched/branchname
force: true
get_params:
skip_clone: true

- put: {{v.short_name}}-intermediate
params:
repository: terraform-diff/old
repository: terraform-diff/{{k}}/old
branch_file: magic-modules-previous/branchname
force: true
get_params:
Expand Down
6 changes: 4 additions & 2 deletions .ci/magic-modules/diff-terraform.sh
Original file line number Diff line number Diff line change
Expand Up @@ -82,5 +82,7 @@ for mm_dir in magic-modules-branched magic-modules-previous; do

done

git clone "magic-modules-branched/build/$SHORT_NAME" "./terraform-diff/new"
git clone "magic-modules-previous/build/$SHORT_NAME" "./terraform-diff/old"
mkdir "./terraform-diff/$VERSION"

git clone "magic-modules-branched/build/$SHORT_NAME" "./terraform-diff/$VERSION/new"
git clone "magic-modules-previous/build/$SHORT_NAME" "./terraform-diff/$VERSION/old"
2 changes: 1 addition & 1 deletion build/ansible
2 changes: 1 addition & 1 deletion build/inspec
Submodule inspec updated 372 files
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
2 changes: 2 additions & 0 deletions products/appengine/ansible.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ datasources: !ruby/object:Overrides::ResourceOverrides
DomainMapping: !ruby/object:Overrides::Ansible::ResourceOverride
exclude: true
overrides: !ruby/object:Overrides::ResourceOverrides
ApplicationUrlDispatchRules: !ruby/object:Overrides::Ansible::ResourceOverride
exclude: true
FirewallRule: !ruby/object:Overrides::Ansible::ResourceOverride
# Because of lack of state, Ansible treats identity
# differently than Terraform.
Expand Down
57 changes: 57 additions & 0 deletions products/appengine/api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -446,3 +446,60 @@ objects:
Instance class that is used to run this version. Valid values are
AutomaticScaling F1, F2, F4, F4_1G
(Only AutomaticScaling is supported at the moment)
- !ruby/object:Api::Resource
name: 'ApplicationUrlDispatchRules'
description: |
Rules to match an HTTP request and dispatch that request to a service.
base_url: 'apps/{{project}}'
create_url: 'apps/{{project}}?updateMask=dispatch_rules'
create_verb: :PATCH
delete_url: 'apps/{{project}}?updateMask=dispatch_rules'
delete_verb: :PATCH
update_url: 'apps/{{project}}?updateMask=dispatch_rules'
update_verb: :PATCH
references: !ruby/object:Api::Resource::ReferenceLinks
api: 'https://cloud.google.com/appengine/docs/admin-api/reference/rest/v1/apps#UrlDispatchRule'
async: !ruby/object:Api::Async
operation: !ruby/object:Api::Async::Operation
path: 'name'
base_url: '{{op_id}}'
wait_ms: 1000
result: !ruby/object:Api::Async::Result
path: 'response'
status: !ruby/object:Api::Async::Status
path: 'status'
complete: 'DONE'
allowed:
- 'PENDING'
- 'RUNNING'
- 'DONE'
error: !ruby/object:Api::Async::Error
path: 'error/errors'
message: 'message'
properties:
- !ruby/object:Api::Type::Array
name: 'dispatchRules'
required: true
description: |
Rules to match an HTTP request and dispatch that request to a service.
item_type: !ruby/object:Api::Type::NestedObject
properties:
- !ruby/object:Api::Type::String
name: 'domain'
default_value: '*'
description: |
Domain name to match against. The wildcard "*" is supported if specified before a period: "*.".
Defaults to matching all domains: "*".
- !ruby/object:Api::Type::String
name: 'path'
description: |
Pathname within the host. Must start with a "/". A single "*" can be included at the end of the path.
The sum of the lengths of the domain and path may not exceed 100 characters.
required: true
- !ruby/object:Api::Type::String
name: 'service'
description: |
Pathname within the host. Must start with a "/". A single "*" can be included at the end of the path.
The sum of the lengths of the domain and path may not exceed 100 characters.
required: true

2 changes: 2 additions & 0 deletions products/appengine/inspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
--- !ruby/object:Provider::Inspec::Config
legacy_name: appengine
overrides: !ruby/object:Overrides::ResourceOverrides
ApplicationUrlDispatchRules: !ruby/object:Overrides::Inspec::ResourceOverride
exclude: true
DomainMapping: !ruby/object:Overrides::Inspec::ResourceOverride
exclude: true
FirewallRule: !ruby/object:Overrides::Inspec::ResourceOverride
Expand Down
17 changes: 15 additions & 2 deletions products/appengine/terraform.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ overrides: !ruby/object:Overrides::ResourceOverrides
StandardAppVersion: !ruby/object:Overrides::Terraform::ResourceOverride
id_format: "apps/{{project}}/services/{{service}}/versions/{{version_id}}"
import_format: ["apps/{{project}}/services/{{service}}/versions/{{version_id}}"]
mutex: "apps/{{project}}/services/{{service}}"
mutex: "apps/{{project}}"
parameters:
service: !ruby/object:Overrides::Terraform::PropertyOverride
default_from_api: true
Expand All @@ -43,7 +43,7 @@ overrides: !ruby/object:Overrides::ResourceOverrides
If set to `true`, the service will be deleted if it is the last version.
custom_code: !ruby/object:Provider::Terraform::CustomCode
custom_delete: templates/terraform/custom_delete/appversion_delete.go.erb
test_check_destroy: templates/terraform/custom_check_destroy/appengine_version.go.erb
test_check_destroy: templates/terraform/custom_check_destroy/appengine.go.erb
properties:
id: !ruby/object:Overrides::Terraform::PropertyOverride
name: 'version_id'
Expand Down Expand Up @@ -93,6 +93,19 @@ overrides: !ruby/object:Overrides::ResourceOverrides
update_mask_fields:
- "ssl_settings.certificate_id"
- "ssl_settings.ssl_management_type"
ApplicationUrlDispatchRules: !ruby/object:Overrides::Terraform::ResourceOverride
id_format: "{{project}}"
import_format: ["{{project}}"]
mutex: "apps/{{project}}"
custom_code: !ruby/object:Provider::Terraform::CustomCode
test_check_destroy: templates/terraform/custom_check_destroy/appengine.go.erb
examples:
- !ruby/object:Provider::Terraform::Examples
name: "app_engine_application_url_dispatch_rules_basic"
primary_resource_id: "service_rules"
vars:
project: "my-project"
bucket_name: "appengine-test-bucket"

# This is for copying files over
files: !ruby/object:Provider::Config::Files
Expand Down
1 change: 1 addition & 0 deletions products/compute/api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7720,6 +7720,7 @@ objects:
delete_verb: :PATCH
identity:
- name
collection_url_key: nats
nested_query: !ruby/object:Api::Resource::NestedQuery
modify_by_patch: true
keys:
Expand Down
2 changes: 0 additions & 2 deletions products/compute/inspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,6 @@ overrides: !ruby/object:Overrides::ResourceOverrides
exclude: true
ResourcePolicy: !ruby/object:Overrides::Inspec::ResourceOverride
exclude: true
RouterNat: !ruby/object:Overrides::Inspec::ResourceOverride
exclude: true
Subnetwork: !ruby/object:Overrides::Inspec::ResourceOverride
exclude_resource: true
iam_policy: !ruby/object:Api::Resource::IamPolicy
Expand Down
2 changes: 2 additions & 0 deletions products/pubsub/terraform.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ overrides: !ruby/object:Overrides::ResourceOverrides
diff_suppress_func: 'compareSelfLinkOrResourceName'
custom_expand: templates/terraform/custom_expand/resource_from_self_link.go.erb
custom_flatten: templates/terraform/custom_flatten/name_from_self_link.erb
messageStoragePolicy: !ruby/object:Overrides::Terraform::PropertyOverride
default_from_api: true
custom_code: !ruby/object:Provider::Terraform::CustomCode
encoder: templates/terraform/encoders/no_send_name.go.erb
update_encoder: templates/terraform/update_encoder/pubsub_topic.erb
Expand Down
4 changes: 2 additions & 2 deletions provider/ansible/documentation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -168,8 +168,8 @@ def auth_docs
# Notes related to authentication
def auth_notes
[
'for authentication, you can set service_account_file using the c(gcp_service_account_file) env variable.',
'for authentication, you can set service_account_contents using the c(GCP_SERVICE_ACCOUNT_CONTENTS) env variable.',
'for authentication, you can set service_account_file using the C(gcp_service_account_file) env variable.',
'for authentication, you can set service_account_contents using the C(GCP_SERVICE_ACCOUNT_CONTENTS) env variable.',
'For authentication, you can set service_account_email using the C(GCP_SERVICE_ACCOUNT_EMAIL) env variable.',
'For authentication, you can set auth_kind using the C(GCP_AUTH_KIND) env variable.',
'For authentication, you can set scopes using the C(GCP_SCOPES) env variable.',
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<% gcp_project_id = "#{external_attribute('gcp_project_id', doc_generation)}" -%>
<% gcp_location = "#{external_attribute('gcp_location', doc_generation)}" -%>
<% router = grab_attributes['router'] -%>
<% router_nat = grab_attributes['router_nat'] -%>
describe google_compute_router_nat(project: <%= gcp_project_id -%>, region: <%= gcp_location -%>, router: <%= doc_generation ? "'#{router['name']}'" : "router['name']" -%>, name: <%= doc_generation ? "'#{router_nat['name']}'" : "router_nat['name']" -%>) do
it { should exist }
its('nat_ip_allocate_option') { should cmp <%= doc_generation ? "'#{router_nat['nat_ip_allocate_option']}'" : "router_nat['nat_ip_allocate_option']" -%> }
its('source_subnetwork_ip_ranges_to_nat') { should cmp <%= doc_generation ? "'#{router_nat['source_subnetwork_ip_ranges_to_nat']}'" : "router_nat['source_subnetwork_ip_ranges_to_nat']" -%> }
its('min_ports_per_vm') { should cmp <%= doc_generation ? "'#{router_nat['min_ports_per_vm']}'" : "router_nat['min_ports_per_vm']" -%> }
its('log_config.enable') { should cmp <%= doc_generation ? "'#{router_nat['log_config_enable']}'" : "router_nat['log_config_enable']" -%> }
its('log_config.filter') { should cmp <%= doc_generation ? "'#{router_nat['log_config_filter']}'" : "router_nat['log_config_filter']" -%> }
end

describe google_compute_router(project: <%= gcp_project_id -%>, region: <%= gcp_location -%>, router: 'nonexistent', name: 'nonexistent') do
it { should_not exist }
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
gcp_project_id = attribute(:gcp_project_id, default: '<%= external_attribute('gcp_project_id') -%>', description: 'The GCP project identifier.')
gcp_location = attribute(:gcp_location, default: '<%= external_attribute('gcp_location') -%>', description: 'The GCP project region.')
router = attribute('router', default: <%= JSON.pretty_generate(grab_attributes['router']) -%>, description: 'Compute router description')
router_nat = attribute('router_nat', default: <%= JSON.pretty_generate(grab_attributes['router_nat']) -%>, description: 'Compute router NAT description')
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<% gcp_project_id = "#{external_attribute('gcp_project_id', doc_generation)}" -%>
<% gcp_location = "#{external_attribute('gcp_location', doc_generation)}" -%>
<% router = grab_attributes['router'] -%>
<% router_nat = grab_attributes['router_nat'] -%>
describe google_compute_router_nats(project: <%= gcp_project_id -%>, region: <%= gcp_location -%>, router: <%= doc_generation ? "'#{router['name']}'" : "router['name']" -%>) do
its('names') { should include <%= doc_generation ? "'#{router_nat['name']}'" : "router_nat['name']" -%> }
end
23 changes: 22 additions & 1 deletion templates/inspec/tests/integration/build/gcp-mm.tf
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,10 @@ variable "node_group" {
type = "map"
}

variable "router_nat" {
type = "map"
}

resource "google_compute_ssl_policy" "custom-ssl-policy" {
name = "${var.ssl_policy["name"]}"
min_tls_version = "${var.ssl_policy["min_tls_version"]}"
Expand Down Expand Up @@ -669,6 +673,7 @@ resource "google_ml_engine_model" "inspec-gcp-model" {
}

resource "google_compute_firewall" "dataproc" {
project = var.gcp_project_id
name = "dataproc-firewall"
network = "${google_compute_network.dataproc.name}"

Expand All @@ -688,7 +693,8 @@ resource "google_compute_firewall" "dataproc" {
}

resource "google_compute_network" "dataproc" {
name = "dataproc-network"
project = var.gcp_project_id
name = "dataproc-network"
}

resource "google_dataproc_cluster" "mycluster" {
Expand Down Expand Up @@ -836,3 +842,18 @@ resource "google_compute_node_group" "inspec-node-group" {
size = var.node_group["size"]
node_template = "${google_compute_node_template.inspec-template.self_link}"
}

resource "google_compute_router_nat" "inspec-nat" {
project = var.gcp_project_id
name = var.router_nat["name"]
router = google_compute_router.gcp-inspec-router.name
region = google_compute_router.gcp-inspec-router.region
nat_ip_allocate_option = var.router_nat["nat_ip_allocate_option"]
source_subnetwork_ip_ranges_to_nat = var.router_nat["source_subnetwork_ip_ranges_to_nat"]
min_ports_per_vm = var.router_nat["min_ports_per_vm"]

log_config {
enable = var.router_nat["log_config_enable"]
filter = var.router_nat["log_config_filter"]
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -315,4 +315,12 @@ node_template:
node_group:
name: inspec-node-group
description: A description of the node group
size: 0
size: 0

router_nat:
name: inspec-router-nat
nat_ip_allocate_option: AUTO_ONLY
source_subnetwork_ip_ranges_to_nat: ALL_SUBNETWORKS_ALL_IP_RANGES
min_ports_per_vm: 2
log_config_enable: true
log_config_filter: ERRORS_ONLY
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
resource "google_storage_bucket" "bucket" {
name = "<%= ctx[:vars]['bucket_name'] %>"
}

resource "google_storage_bucket_object" "object" {
name = "hello-world.zip"
bucket = "${google_storage_bucket.bucket.name}"
source = "./test-fixtures/appengine/hello-world.zip"
}

resource "google_app_engine_standard_app_version" "myapp_v1" {
version_id = "v1"
service = "myapp"
runtime = "nodejs10"
noop_on_destroy = true
entrypoint {
shell = "node ./app.js"
}
deployment {
zip {
source_url = "https://storage.googleapis.com/${google_storage_bucket.bucket.name}/hello-world.zip"
}
}
env_variables = {
port = "8080"
}
depends_on = ["google_storage_bucket_object.object"]

}

resource "google_app_engine_application_url_dispatch_rules" "service_rules" {
# project = "my-project"
dispatch_rules {
domain = "*"
path = "/default/*"
service = "default"
}
dispatch_rules {
domain = "*"
path = "/myapp/*"
service = "${google_app_engine_standard_app_version.myapp_v1.service}"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ func resourceComputeInstanceGroup() *schema.Resource {
Optional: true,
Computed: true,
Elem: &schema.Schema{Type: schema.TypeString},
Set: schema.HashString,
Set: selfLinkRelativePathHash,
},

"named_port": {
Expand All @@ -71,10 +71,11 @@ func resourceComputeInstanceGroup() *schema.Resource {
},

"network": {
Type: schema.TypeString,
Optional: true,
Computed: true,
ForceNew: true,
Type: schema.TypeString,
Optional: true,
Computed: true,
DiffSuppressFunc: compareSelfLinkOrResourceName,
ForceNew: true,
},

"project": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -514,15 +514,15 @@ func resourceComputeInstanceTemplateSourceImageCustomizeDiff(diff *schema.Resour
if err != nil {
return err
}
oldResolved, err = resolvedImageSelfLink(project, oldResolved)
oldResolved, err = resolveImageRefToRelativeURI(project, oldResolved)
if err != nil {
return err
}
newResolved, err := resolveImage(config, project, new.(string))
if err != nil {
return err
}
newResolved, err = resolvedImageSelfLink(project, newResolved)
newResolved, err = resolveImageRefToRelativeURI(project, newResolved)
if err != nil {
return err
}
Expand Down Expand Up @@ -781,13 +781,9 @@ func flattenDisk(disk *computeBeta.AttachedDisk, defaultProject string) (map[str
diskMap := make(map[string]interface{})
if disk.InitializeParams != nil {
if disk.InitializeParams.SourceImage != "" {
selfLink, err := resolvedImageSelfLink(defaultProject, disk.InitializeParams.SourceImage)
path, err := resolveImageRefToRelativeURI(defaultProject, disk.InitializeParams.SourceImage)
if err != nil {
return nil, errwrap.Wrapf("Error expanding source image input to self_link: {{err}}", err)
}
path, err := getRelativePath(selfLink)
if err != nil {
return nil, errwrap.Wrapf("Error getting relative path for source image: {{err}}", err)
return nil, errwrap.Wrapf("Error expanding source image input to relative URI: {{err}}", err)
}
diskMap["source_image"] = path
} else {
Expand Down
Loading

0 comments on commit d30fe62

Please sign in to comment.