-
Notifications
You must be signed in to change notification settings - Fork 263
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add vpc access connector resource and vpc_connector attribute to clou…
…d functions
- Loading branch information
Showing
10 changed files
with
743 additions
and
0 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
// ---------------------------------------------------------------------------- | ||
// | ||
// *** AUTO GENERATED CODE *** AUTO GENERATED CODE *** | ||
// | ||
// ---------------------------------------------------------------------------- | ||
// | ||
// This file is automatically generated by Magic Modules and manual | ||
// changes will be clobbered when the file is regenerated. | ||
// | ||
// Please read more about how to change this file in | ||
// .github/CONTRIBUTING.md. | ||
// | ||
// ---------------------------------------------------------------------------- | ||
|
||
package google | ||
|
||
import "github.com/hashicorp/terraform/helper/schema" | ||
|
||
// If the base path has changed as a result of your PR, make sure to update | ||
// the provider_reference page! | ||
var VpcAccessDefaultBasePath = "https://vpcaccess.googleapis.com/v1beta1/" | ||
var VpcAccessCustomEndpointEntryKey = "vpc_access_custom_endpoint" | ||
var VpcAccessCustomEndpointEntry = &schema.Schema{ | ||
Type: schema.TypeString, | ||
Optional: true, | ||
ValidateFunc: validateCustomEndpoint, | ||
DefaultFunc: schema.MultiEnvDefaultFunc([]string{ | ||
"GOOGLE_VPC_ACCESS_CUSTOM_ENDPOINT", | ||
}, VpcAccessDefaultBasePath), | ||
} | ||
|
||
var GeneratedVpcAccessResourcesMap = map[string]*schema.Resource{ | ||
"google_vpc_access_connector": resourceVpcAccessConnector(), | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -326,6 +326,32 @@ func TestAccCloudFunctionsFunction_serviceAccountEmail(t *testing.T) { | |
}) | ||
} | ||
|
||
func TestAccCloudFunctionsFunction_vpcConnector(t *testing.T) { | ||
t.Parallel() | ||
|
||
functionName := fmt.Sprintf("tf-test-%s", acctest.RandString(10)) | ||
bucketName := fmt.Sprintf("tf-test-bucket-%d", acctest.RandInt()) | ||
vpcConnectorName := fmt.Sprintf("tf-test-connector-%s", acctest.RandString(5)) | ||
zipFilePath, err := createZIPArchiveForIndexJs(testHTTPTriggerPath) | ||
projectNumber := os.Getenv("GOOGLE_PROJECT_NUMBER") | ||
|
||
if err != nil { | ||
t.Fatal(err.Error()) | ||
} | ||
defer os.Remove(zipFilePath) // clean up | ||
|
||
resource.Test(t, resource.TestCase{ | ||
PreCheck: func() { testAccPreCheck(t) }, | ||
Providers: testAccProvidersOiCS, | ||
CheckDestroy: testAccCheckCloudFunctionsFunctionDestroy, | ||
Steps: []resource.TestStep{ | ||
{ | ||
Config: testAccCloudFunctionsFunction_vpcConnector(projectNumber, functionName, bucketName, zipFilePath, vpcConnectorName), | ||
}, | ||
}, | ||
}) | ||
} | ||
|
||
func testAccCheckCloudFunctionsFunctionDestroy(s *terraform.State) error { | ||
config := testAccProvider.Meta().(*Config) | ||
|
||
|
@@ -708,3 +734,56 @@ resource "google_cloudfunctions_function" "function" { | |
entry_point = "helloGET" | ||
}`, bucketName, zipFilePath, functionName) | ||
} | ||
|
||
func testAccCloudFunctionsFunction_vpcConnector(projectNumber, functionName, bucketName, zipFilePath, vpcConnectorName string) string { | ||
return fmt.Sprintf(` | ||
provider "google-beta" { } | ||
resource "google_project_iam_member" "project" { | ||
provider = "google-beta" | ||
role = "roles/editor" | ||
member = "serviceAccount:service-%[email protected]" | ||
} | ||
resource "google_vpc_access_connector" "connector" { | ||
provider = "google-beta" | ||
name = "%s" | ||
region = "us-central1" | ||
ip_cidr_range = "10.10.0.0/28" | ||
network = "default" | ||
} | ||
resource "google_storage_bucket" "bucket" { | ||
provider = "google-beta" | ||
name = "%s" | ||
} | ||
resource "google_storage_bucket_object" "archive" { | ||
provider = "google-beta" | ||
name = "index.zip" | ||
bucket = google_storage_bucket.bucket.name | ||
source = "%s" | ||
} | ||
resource "google_cloudfunctions_function" "function" { | ||
name = "%s" | ||
provider = "google-beta" | ||
description = "test function" | ||
available_memory_mb = 128 | ||
source_archive_bucket = google_storage_bucket.bucket.name | ||
source_archive_object = google_storage_bucket_object.archive.name | ||
trigger_http = true | ||
timeout = 61 | ||
entry_point = "helloGET" | ||
labels = { | ||
my-label = "my-label-value" | ||
} | ||
environment_variables = { | ||
TEST_ENV_VARIABLE = "test-env-variable-value" | ||
} | ||
max_instances = 10 | ||
vpc_connector = google_vpc_access_connector.connector.self_link | ||
}`, projectNumber, vpcConnectorName, bucketName, zipFilePath, functionName) | ||
} |
Oops, something went wrong.