Skip to content

Commit 185b7ef

Browse files
authored
Fix: Cloud Sql example instructions (#58)
1 parent 42bf7a6 commit 185b7ef

3 files changed

Lines changed: 59 additions & 1 deletion

File tree

examples/secure_cloud_function_with_sql/README.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,27 @@ _Note: Please refer to [Secure Web Proxy documentation](../../docs/secure-web-pr
144144

145145
<!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
146146

147+
To provision this example, run the following commands from within this directory:
148+
149+
* `mv terraform.tfvars.example terraform.tfvars` to rename the example `tfvars` file.
150+
* Fill the `terraform.tfvars` with your values.
151+
* `terraform init` to get the plugins.
152+
* `terraform plan` to see the infrastructure plan.
153+
* `terraform apply` to apply the infrastructure build.
154+
* `terraform destroy` to destroy the built infrastructure.
155+
156+
### Testing
157+
158+
You can see the Secure Cloud Function running, forcing the Scheduler job to run.
159+
160+
* Go to [Cloud Scheduler console](https://console.cloud.google.com/cloudscheduler/).
161+
* Select your Serverless project.
162+
* Click in Actions at your Cloud Scheduler job and click in Force run.
163+
* Go to the [Cloud Function console](https://console.cloud.google.com/functions).
164+
* Select your project and Cloud Function.
165+
* Go to logs.
166+
* When upload is done, you can see the Cloud Function logs consulting the Cloud SQL Database.
167+
147168
## Requirements
148169

149170
### Software
@@ -210,3 +231,17 @@ the resources of this module:
210231
* Compute Shared VPC Admin: `roles/compute.xpnAdmin`
211232
* Billing:
212233
* Billing User: `roles/billing.user`
234+
235+
### Required APIs enabled at Service Account project
236+
237+
The service account project must have the following APIs enabled:
238+
239+
* Access Context Manager API: `accesscontextmanager.googleapis.com`
240+
* Cloud Billing API: `cloudbilling.googleapis.com`
241+
* Cloud Build API: `cloudbuild.googleapis.com`
242+
* Cloud Key Management Service (KMS) API: `cloudkms.googleapis.com`
243+
* Cloud Pub/Sub API: `pubsub.googleapis.com`
244+
* Cloud SQL Admin API: `sqladmin.googleapis.com`
245+
* Cloud Resource Manager API: `cloudresourcemanager.googleapis.com`
246+
* Identity and Access Management (IAM) API: `iam.googleapis.com`
247+
* Service Networking API: `servicenetworking.googleapis.com`

examples/secure_cloud_function_with_sql/main.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ module "secure_harness" {
5050
private_service_connect_ip = "10.3.0.5"
5151
create_access_context_manager_access_policy = var.create_access_context_manager_access_policy
5252
access_context_manager_policy_id = var.access_context_manager_policy_id
53-
access_level_members = var.access_level_members
53+
access_level_members = distinct(concat(var.access_level_members, ["serviceAccount:${var.terraform_service_account}"]))
5454
key_name = "key-secure-artifact-registry"
5555
keyring_name = "krg-secure-artifact-registry"
5656
prevent_destroy = false
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# /**
2+
# * Copyright 2023 Google LLC
3+
# *
4+
# * Licensed under the Apache License, Version 2.0 (the "License");
5+
# * you may not use this file except in compliance with the License.
6+
# * You may obtain a copy of the License at
7+
# *
8+
# * http://www.apache.org/licenses/LICENSE-2.0
9+
# *
10+
# * Unless required by applicable law or agreed to in writing, software
11+
# * distributed under the License is distributed on an "AS IS" BASIS,
12+
# * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# * See the License for the specific language governing permissions and
14+
# * limitations under the License.
15+
# */
16+
17+
billing_account = "000000-000000-000000"
18+
org_id = "000000000000000000"
19+
folder_id = "000000000000"
20+
create_access_context_manager_access_policy = false
21+
access_context_manager_policy_id = "000000000000"
22+
access_level_members = ["user:email@email.com"]
23+
terraform_service_account = "ci-account@PROJECT.iam.gserviceaccount.com"

0 commit comments

Comments
 (0)