Skip to content

Commit 8000f1a

Browse files
ADD: add ssl policy support in google app engine application (#15445)
1 parent 293b912 commit 8000f1a

File tree

4 files changed

+73
-10
lines changed

4 files changed

+73
-10
lines changed

mmv1/third_party/terraform/services/appengine/resource_app_engine_application.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,17 @@ func ResourceAppEngineApplication() *schema.Resource {
6868
Computed: true,
6969
Description: `The serving status of the app.`,
7070
},
71+
"ssl_policy": {
72+
Type: schema.TypeString,
73+
Optional: true,
74+
ValidateFunc: validation.StringInSlice([]string{
75+
"SSL_POLICY_UNSPECIFIED",
76+
"DEFAULT",
77+
"MODERN",
78+
}, false),
79+
Computed: true,
80+
Description: `The SSL policy that will be applied to the application. If set to Modern it will restrict traffic with TLS \u003c 1.2 and allow only Modern Ciphers suite`,
81+
},
7182
"database_type": {
7283
Type: schema.TypeString,
7384
Optional: true,
@@ -280,6 +291,9 @@ func resourceAppEngineApplicationRead(d *schema.ResourceData, meta interface{})
280291
if err := d.Set("serving_status", app.ServingStatus); err != nil {
281292
return fmt.Errorf("Error setting serving_status: %s", err)
282293
}
294+
if err := d.Set("ssl_policy", app.SslPolicy); err != nil {
295+
return fmt.Errorf("Error setting ssl_policy: %s", err)
296+
}
283297
if err := d.Set("gcr_domain", app.GcrDomain); err != nil {
284298
return fmt.Errorf("Error setting gcr_domain: %s", err)
285299
}
@@ -364,6 +378,7 @@ func expandAppEngineApplication(d *schema.ResourceData, project string) (*appeng
364378
GcrDomain: d.Get("gcr_domain").(string),
365379
DatabaseType: d.Get("database_type").(string),
366380
ServingStatus: d.Get("serving_status").(string),
381+
SslPolicy: d.Get("ssl_policy").(string),
367382
}
368383
featureSettings, err := expandAppEngineApplicationFeatureSettings(d)
369384
if err != nil {

mmv1/third_party/terraform/services/appengine/resource_app_engine_application_meta.yaml.tmpl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ fields:
2525
- api_field: 'name'
2626
- field: 'project'
2727
- api_field: 'servingStatus'
28+
- api_field: 'ssl_policy'
2829
- field: 'url_dispatch_rule.domain'
2930
- field: 'url_dispatch_rule.path'
3031
- field: 'url_dispatch_rule.service'

mmv1/third_party/terraform/services/appengine/resource_app_engine_application_test.go

Lines changed: 54 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -71,12 +71,39 @@ func TestAccAppEngineApplication_withIAP(t *testing.T) {
7171
})
7272
}
7373

74+
func TestAccAppEngineApplication_withSSLPolicy(t *testing.T) {
75+
t.Parallel()
76+
77+
org := envvar.GetTestOrgFromEnv(t)
78+
pid := fmt.Sprintf("tf-test-%d", acctest.RandInt(t))
79+
billingAccount := envvar.GetTestBillingAccountFromEnv(t)
80+
81+
acctest.VcrTest(t, resource.TestCase{
82+
PreCheck: func() { acctest.AccTestPreCheck(t) },
83+
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t),
84+
Steps: []resource.TestStep{
85+
{
86+
Config: testAccAppEngineApplication_withSSLPolicy(pid, org, billingAccount),
87+
Check: resource.ComposeTestCheckFunc(
88+
resource.TestCheckResourceAttr("google_app_engine_application.acceptance", "ssl_policy", "MODERN"),
89+
resource.TestCheckResourceAttr("google_app_engine_application.acceptance", "location_id", "us-central"),
90+
),
91+
},
92+
{
93+
ResourceName: "google_app_engine_application.acceptance",
94+
ImportState: true,
95+
ImportStateVerify: true,
96+
},
97+
},
98+
})
99+
}
100+
74101
func testAccAppEngineApplication_withIAP(pid, org, billingAccount string) string {
75102
return fmt.Sprintf(`
76103
resource "google_project" "acceptance" {
77-
project_id = "%s"
78-
name = "%s"
79-
org_id = "%s"
104+
project_id = "%s"
105+
name = "%s"
106+
org_id = "%s"
80107
billing_account = "%s"
81108
deletion_policy = "DELETE"
82109
}
@@ -99,9 +126,9 @@ resource "google_app_engine_application" "acceptance" {
99126
func testAccAppEngineApplication_basic(pid, org, billingAccount string) string {
100127
return fmt.Sprintf(`
101128
resource "google_project" "acceptance" {
102-
project_id = "%s"
103-
name = "%s"
104-
org_id = "%s"
129+
project_id = "%s"
130+
name = "%s"
131+
org_id = "%s"
105132
billing_account = "%s"
106133
deletion_policy = "DELETE"
107134
}
@@ -119,9 +146,9 @@ resource "google_app_engine_application" "acceptance" {
119146
func testAccAppEngineApplication_update(pid, org, billingAccount string) string {
120147
return fmt.Sprintf(`
121148
resource "google_project" "acceptance" {
122-
project_id = "%s"
123-
name = "%s"
124-
org_id = "%s"
149+
project_id = "%s"
150+
name = "%s"
151+
org_id = "%s"
125152
billing_account = "%s"
126153
deletion_policy = "DELETE"
127154
}
@@ -135,3 +162,21 @@ resource "google_app_engine_application" "acceptance" {
135162
}
136163
`, pid, pid, org, billingAccount)
137164
}
165+
166+
func testAccAppEngineApplication_withSSLPolicy(pid, org, billingAccount string) string {
167+
return fmt.Sprintf(`
168+
resource "google_project" "acceptance" {
169+
project_id = "%s"
170+
name = "%s"
171+
org_id = "%s"
172+
billing_account = "%s"
173+
deletion_policy = "DELETE"
174+
}
175+
176+
resource "google_app_engine_application" "acceptance" {
177+
project = google_project.acceptance.project_id
178+
location_id = "us-central"
179+
ssl_policy = "MODERN"
180+
}
181+
`, pid, pid, org, billingAccount)
182+
}

mmv1/third_party/terraform/website/docs/r/app_engine_application.html.markdown

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@ The following arguments are supported:
5353

5454
* `serving_status` - (Optional) The serving status of the app.
5555

56+
* `ssl_policy` - (Optional) A list of the SSL policy that will be applied. Each block has a `SSL_POLICY_UNSPECIFIED`, `DEFAULT`, and `MODERN` field.
57+
5658
* `feature_settings` - (Optional) A block of optional settings to configure specific App Engine features:
5759

5860
* `split_health_checks` - (Required) Set to false to use the legacy health check instead of the readiness
@@ -120,4 +122,4 @@ When using the [`terraform import` command](https://developer.hashicorp.com/terr
120122

121123
```
122124
$ terraform import google_app_engine_application.default {{project-id}}
123-
```
125+
```

0 commit comments

Comments
 (0)