diff --git a/build/int.cloudbuild.yaml b/build/int.cloudbuild.yaml index 8c80949b7..7661274dc 100644 --- a/build/int.cloudbuild.yaml +++ b/build/int.cloudbuild.yaml @@ -31,10 +31,25 @@ steps: - prepare name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS' args: ['/bin/bash', '-c', 'source /usr/local/bin/task_helper_functions.sh && source_test_env && init_credentials && cd test/integration && RUN_STAGE=init go test -v ./... -p 1 -timeout 0'] -- id: converge simple-project-local +- id: converge service-networking waitFor: - create all name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS' + args: ['/bin/bash', '-c', 'cft test run TestServiceNetworking --stage apply --verbose'] +- id: verify service-networking + waitFor: + - converge service-networking + name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS' + args: ['/bin/bash', '-c', 'cft test run TestServiceNetworking --stage verify --verbose'] +- id: destroy service-networking + waitFor: + - verify service-networking + name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS' + args: ['/bin/bash', '-c', 'cft test run TestServiceNetworking --stage teardown --verbose'] +- id: converge simple-project-local + waitFor: + - destroy service-networking + name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS' args: ['/bin/bash', '-c', 'source /usr/local/bin/task_helper_functions.sh && source_test_env && init_credentials && cd test/integration && RUN_STAGE=apply go test -v ./... -p 1 -timeout 0 -run ^TestSimpleProject$'] - id: verify simple-project-local waitFor: diff --git a/examples/service-networking/main.tf b/examples/service-networking/main.tf index e1e06b4ed..00907a348 100644 --- a/examples/service-networking/main.tf +++ b/examples/service-networking/main.tf @@ -1,6 +1,23 @@ +/** + * Copyright 2024 Google LLC + * + * 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. + */ + resource "google_compute_network" "peering_network" { name = "private-network" auto_create_subnetworks = "false" + project = var.project_id } module "service_networking" { diff --git a/examples/service-networking/outputs.tf b/examples/service-networking/outputs.tf index 01a549fb0..1ce92daea 100644 --- a/examples/service-networking/outputs.tf +++ b/examples/service-networking/outputs.tf @@ -1,3 +1,19 @@ +/** + * Copyright 2024 Google LLC + * + * 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. + */ + output "project_id" { description = "Project ID" value = var.project_id diff --git a/examples/service-networking/variables.tf b/examples/service-networking/variables.tf index 9867b3060..4c2ad67f1 100644 --- a/examples/service-networking/variables.tf +++ b/examples/service-networking/variables.tf @@ -1,3 +1,19 @@ +/** + * Copyright 2024 Google LLC + * + * 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. + */ + variable "project_id" { description = "Project ID" type = string diff --git a/modules/service-networking/main.tf b/modules/service-networking/main.tf index 0361fba5d..f9578f154 100644 --- a/modules/service-networking/main.tf +++ b/modules/service-networking/main.tf @@ -1,3 +1,19 @@ +/** + * Copyright 2024 Google LLC + * + * 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. + */ + resource "google_compute_global_address" "global_address" { project = var.project_id name = var.address_name diff --git a/modules/service-networking/metadata.yaml b/modules/service-networking/metadata.yaml index dd4dc9eb5..196bb5c59 100644 --- a/modules/service-networking/metadata.yaml +++ b/modules/service-networking/metadata.yaml @@ -1,3 +1,17 @@ + # Copyright 2024 Google LLC + # + # 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. + apiVersion: blueprints.cloud.google.com/v1alpha1 kind: BlueprintMetadata metadata: diff --git a/modules/service-networking/outputs.tf b/modules/service-networking/outputs.tf index 6a1f5c3fe..a3a9a1539 100644 --- a/modules/service-networking/outputs.tf +++ b/modules/service-networking/outputs.tf @@ -1,3 +1,19 @@ +/** + * Copyright 2024 Google LLC + * + * 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. + */ + output "address_id" { description = "Global address id" value = google_compute_global_address.global_address.id diff --git a/modules/service-networking/variables.tf b/modules/service-networking/variables.tf index 4c45a74f7..5b1048e18 100644 --- a/modules/service-networking/variables.tf +++ b/modules/service-networking/variables.tf @@ -1,3 +1,19 @@ +/** + * Copyright 2024 Google LLC + * + * 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. + */ + variable "project_id" { description = "Project ID" type = string diff --git a/modules/service-networking/versions.tf b/modules/service-networking/versions.tf index 9ae855d10..dc20a141e 100644 --- a/modules/service-networking/versions.tf +++ b/modules/service-networking/versions.tf @@ -1,3 +1,19 @@ +/** + * Copyright 2024 Google LLC + * + * 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. + */ + terraform { required_version = ">= 0.13.0" diff --git a/test/integration/service-networking/service_networking_test.go b/test/integration/service-networking/service_networking_test.go index e2333cb9b..8b31ac609 100644 --- a/test/integration/service-networking/service_networking_test.go +++ b/test/integration/service-networking/service_networking_test.go @@ -26,10 +26,9 @@ func TestServiceNetworking(t *testing.T) { net.DefineVerify( func(assert *assert.Assertions) { net.DefaultVerify(assert) - projectID := net.GetStringOutput("project_id") peering := net.GetStringOutput("peering") - assert.Contains(peering, "xyz") + assert.Contains(peering, "servicenetworking-googleapis-com") }) net.Test() } diff --git a/test/setup/main.tf b/test/setup/main.tf index 79cbb95db..02a949100 100644 --- a/test/setup/main.tf +++ b/test/setup/main.tf @@ -54,5 +54,6 @@ module "project" { "dns.googleapis.com", "networksecurity.googleapis.com", "iam.googleapis.com", + "servicenetworking.googleapis.com", ] }