id: gcloud-func-no-vpc-access info: name: No Serverless VPC Access in Google Cloud Functions author: princechaddha severity: high description: | Ensure that your Google Cloud functions are configured to use Serverless VPC Access in order to connect functions directly to your VPC network, allowing access to other VPC resources such as VM instances, MemoryStore instances, or any other cloud resources with an internal IP address. Without Serverless VPC Access, these functions may not be able to communicate efficiently with other resources in the same VPC. impact: | Lack of Serverless VPC Access in Google Cloud functions can lead to inefficient or failed communications between your serverless functions and other resources within the same VPC, impacting application performance and increasing latency. remediation: | Configure Serverless VPC Access for your Google Cloud functions by setting the vpcConnector parameter to the name of an already configured VPC connector in your project settings. reference: - https://cloud.google.com/functions/docs/connecting-vpc tags: cloud,devops,gcp,gcloud,google-cloud-functions,gcp-cloud-config flow: | code(1) for(let projectId of iterate(template.projectIds)){ set("projectId", projectId) code(2) for(let functionName of iterate(template.functions)){ set("functionName", functionName) code(3) } } self-contained: true code: - engine: - sh - bash source: | gcloud projects list --format="json(projectId)" extractors: - type: json name: projectIds internal: true json: - '.[].projectId' - engine: - sh - bash source: | gcloud functions list --project $projectId --format="json(name)" extractors: - type: json name: functions internal: true json: - '.[].name' - engine: - sh - bash source: | gcloud functions describe $functionName --region=us-central1 --format="json(vpcConnector)" matchers: - type: word words: - 'null' extractors: - type: dsl dsl: - '"No Serverless VPC Access in function: " + functionName + " in " + projectId + " project"' # digest: 4a0a004730450220397c7cc5e8bbd815dc87d42001c3d67f3ad2a5472ae673d8a30ae79533a5298d0221009dc8716a28b3dbf002ecacb0ea76d8df3890c5fa966d55041b173ea247e57cd4:922c64590222798bb761d5b6d8e72950