-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add app_engine_service_network_settings resource #4810
Merged
c2thorn
merged 6 commits into
GoogleCloudPlatform:master
from
matty-rose:app-engine-ingress-settings
Jun 22, 2021
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
81636ac
Initial functional app engine network settings resource
matty-rose 210f1cb
Add service_network_settings example to generate test
matty-rose 4bec6e0
Add default value for enum
matty-rose a362677
Exclude ServiceNetworkSettings from Inspec
matty-rose 409a839
Exclude ServiceNetworkSettings from Ansible
matty-rose 74419fb
Add update test, remove ignore_read from yaml
matty-rose File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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
35 changes: 35 additions & 0 deletions
35
mmv1/templates/terraform/examples/app_engine_service_network_settings.tf.erb
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,35 @@ | ||
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" "liveapp_v1" { | ||
version_id = "v1" | ||
service = "liveapp" | ||
delete_service_on_destroy = true | ||
|
||
runtime = "nodejs10" | ||
entrypoint { | ||
shell = "node ./app.js" | ||
} | ||
deployment { | ||
zip { | ||
source_url = "https://storage.googleapis.com/${google_storage_bucket.bucket.name}/${google_storage_bucket_object.object.name}" | ||
} | ||
} | ||
env_variables = { | ||
port = "8080" | ||
} | ||
} | ||
|
||
resource "google_app_engine_service_network_settings" "<%= ctx[:primary_resource_id] %>" { | ||
service = google_app_engine_standard_app_version.liveapp_v1.service | ||
network_settings { | ||
ingress_traffic_allowed = "INGRESS_TRAFFIC_ALLOWED_INTERNAL_ONLY" | ||
} | ||
} |
116 changes: 116 additions & 0 deletions
116
mmv1/third_party/terraform/tests/resource_app_engine_service_network_settings_test.go
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,116 @@ | ||
package google | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" | ||
) | ||
|
||
func TestAccAppEngineServiceNetworkSettings_update(t *testing.T) { | ||
t.Parallel() | ||
|
||
context := map[string]interface{}{ | ||
"random_suffix": randString(t, 10), | ||
} | ||
|
||
vcrTest(t, resource.TestCase{ | ||
PreCheck: func() { testAccPreCheck(t) }, | ||
Providers: testAccProviders, | ||
Steps: []resource.TestStep{ | ||
{ | ||
Config: testAccAppEngineServiceNetworkSettings_basic(context), | ||
}, | ||
{ | ||
ResourceName: "google_app_engine_service_network_settings.main", | ||
ImportState: true, | ||
ImportStateVerify: true, | ||
}, | ||
{ | ||
Config: testAccAppEngineServiceNetworkSettings_update(context), | ||
}, | ||
{ | ||
ResourceName: "google_app_engine_service_network_settings.main", | ||
ImportState: true, | ||
ImportStateVerify: true, | ||
}, | ||
}, | ||
}) | ||
} | ||
|
||
func testAccAppEngineServiceNetworkSettings_basic(context map[string]interface{}) string { | ||
return Nprintf(` | ||
resource "google_storage_bucket" "bucket" { | ||
name = "tf-test-%{random_suffix}-ae-networksettings" | ||
} | ||
|
||
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" "app" { | ||
version_id = "v1" | ||
service = "app-%{random_suffix}" | ||
delete_service_on_destroy = true | ||
|
||
runtime = "nodejs10" | ||
entrypoint { | ||
shell = "node ./app.js" | ||
} | ||
deployment { | ||
zip { | ||
source_url = "https://storage.googleapis.com/${google_storage_bucket.bucket.name}/${google_storage_bucket_object.object.name}" | ||
} | ||
} | ||
env_variables = { | ||
port = "8080" | ||
} | ||
} | ||
|
||
resource "google_app_engine_service_network_settings" "main" { | ||
service = google_app_engine_standard_app_version.app.service | ||
network_settings { | ||
ingress_traffic_allowed = "INGRESS_TRAFFIC_ALLOWED_ALL" | ||
} | ||
}`, context) | ||
} | ||
|
||
func testAccAppEngineServiceNetworkSettings_update(context map[string]interface{}) string { | ||
return Nprintf(` | ||
resource "google_storage_bucket" "bucket" { | ||
name = "tf-test-%{random_suffix}-ae-networksettings" | ||
} | ||
|
||
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" "app" { | ||
version_id = "v1" | ||
service = "app-%{random_suffix}" | ||
delete_service_on_destroy = true | ||
|
||
runtime = "nodejs10" | ||
entrypoint { | ||
shell = "node ./app.js" | ||
} | ||
deployment { | ||
zip { | ||
source_url = "https://storage.googleapis.com/${google_storage_bucket.bucket.name}/${google_storage_bucket_object.object.name}" | ||
} | ||
} | ||
env_variables = { | ||
port = "8080" | ||
} | ||
} | ||
|
||
resource "google_app_engine_service_network_settings" "main" { | ||
service = google_app_engine_standard_app_version.app.service | ||
network_settings { | ||
ingress_traffic_allowed = "INGRESS_TRAFFIC_ALLOWED_INTERNAL_ONLY" | ||
} | ||
}`, context) | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this something that is updatable without recreating the resource?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think technically yes? since the API call the terraform resource makes is only a PATCH - This is another one I took from the SplitTraffic resource since they are very similar, but not really sure on the correct behaviour here