Skip to content

Commit c0f0b0c

Browse files
Add serviceAgentAuthentication for Uptime Checks (#10503) (#7276)
[upstream:df4342ed269e6fbfd22d0c344bfee6828abf8b74] Signed-off-by: Modular Magician <[email protected]>
1 parent 968ffe1 commit c0f0b0c

File tree

3 files changed

+85
-2
lines changed

3 files changed

+85
-2
lines changed

google-beta/services/monitoring/resource_monitoring_uptime_check_config.go

Lines changed: 66 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ func ResourceMonitoringUptimeCheckConfig() *schema.Resource {
151151
"auth_info": {
152152
Type: schema.TypeList,
153153
Optional: true,
154-
Description: `The authentication information. Optional when creating an HTTP check; defaults to empty.`,
154+
Description: `The authentication information using username and password. Optional when creating an HTTP check; defaults to empty. Do not use with other authentication fields.`,
155155
MaxItems: 1,
156156
Elem: &schema.Resource{
157157
Schema: map[string]*schema.Schema{
@@ -238,6 +238,22 @@ func ResourceMonitoringUptimeCheckConfig() *schema.Resource {
238238
Description: `The HTTP request method to use for the check. If set to 'METHOD_UNSPECIFIED' then 'request_method' defaults to 'GET'. Default value: "GET" Possible values: ["METHOD_UNSPECIFIED", "GET", "POST"]`,
239239
Default: "GET",
240240
},
241+
"service_agent_authentication": {
242+
Type: schema.TypeList,
243+
Optional: true,
244+
Description: `The authentication information using the Monitoring Service Agent. Optional when creating an HTTPS check; defaults to empty. Do not use with other authentication fields.`,
245+
MaxItems: 1,
246+
Elem: &schema.Resource{
247+
Schema: map[string]*schema.Schema{
248+
"type": {
249+
Type: schema.TypeString,
250+
Optional: true,
251+
ValidateFunc: verify.ValidateEnum([]string{"SERVICE_AGENT_AUTHENTICATION_TYPE_UNSPECIFIED", "OIDC_TOKEN", ""}),
252+
Description: `The type of authentication to use. Possible values: ["SERVICE_AGENT_AUTHENTICATION_TYPE_UNSPECIFIED", "OIDC_TOKEN"]`,
253+
},
254+
},
255+
},
256+
},
241257
"use_ssl": {
242258
Type: schema.TypeBool,
243259
Optional: true,
@@ -981,6 +997,8 @@ func flattenMonitoringUptimeCheckConfigHttpCheck(v interface{}, d *schema.Resour
981997
flattenMonitoringUptimeCheckConfigHttpCheckCustomContentType(original["customContentType"], d, config)
982998
transformed["auth_info"] =
983999
flattenMonitoringUptimeCheckConfigHttpCheckAuthInfo(original["authInfo"], d, config)
1000+
transformed["service_agent_authentication"] =
1001+
flattenMonitoringUptimeCheckConfigHttpCheckServiceAgentAuthentication(original["serviceAgentAuthentication"], d, config)
9841002
transformed["port"] =
9851003
flattenMonitoringUptimeCheckConfigHttpCheckPort(original["port"], d, config)
9861004
transformed["headers"] =
@@ -1036,6 +1054,23 @@ func flattenMonitoringUptimeCheckConfigHttpCheckAuthInfoUsername(v interface{},
10361054
return v
10371055
}
10381056

1057+
func flattenMonitoringUptimeCheckConfigHttpCheckServiceAgentAuthentication(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
1058+
if v == nil {
1059+
return nil
1060+
}
1061+
original := v.(map[string]interface{})
1062+
if len(original) == 0 {
1063+
return nil
1064+
}
1065+
transformed := make(map[string]interface{})
1066+
transformed["type"] =
1067+
flattenMonitoringUptimeCheckConfigHttpCheckServiceAgentAuthenticationType(original["type"], d, config)
1068+
return []interface{}{transformed}
1069+
}
1070+
func flattenMonitoringUptimeCheckConfigHttpCheckServiceAgentAuthenticationType(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
1071+
return v
1072+
}
1073+
10391074
func flattenMonitoringUptimeCheckConfigHttpCheckPort(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
10401075
// Handles the string fixed64 format
10411076
if strVal, ok := v.(string); ok {
@@ -1432,6 +1467,13 @@ func expandMonitoringUptimeCheckConfigHttpCheck(v interface{}, d tpgresource.Ter
14321467
transformed["authInfo"] = transformedAuthInfo
14331468
}
14341469

1470+
transformedServiceAgentAuthentication, err := expandMonitoringUptimeCheckConfigHttpCheckServiceAgentAuthentication(original["service_agent_authentication"], d, config)
1471+
if err != nil {
1472+
return nil, err
1473+
} else if val := reflect.ValueOf(transformedServiceAgentAuthentication); val.IsValid() && !tpgresource.IsEmptyValue(val) {
1474+
transformed["serviceAgentAuthentication"] = transformedServiceAgentAuthentication
1475+
}
1476+
14351477
transformedPort, err := expandMonitoringUptimeCheckConfigHttpCheckPort(original["port"], d, config)
14361478
if err != nil {
14371479
return nil, err
@@ -1544,6 +1586,29 @@ func expandMonitoringUptimeCheckConfigHttpCheckAuthInfoUsername(v interface{}, d
15441586
return v, nil
15451587
}
15461588

1589+
func expandMonitoringUptimeCheckConfigHttpCheckServiceAgentAuthentication(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) {
1590+
l := v.([]interface{})
1591+
if len(l) == 0 || l[0] == nil {
1592+
return nil, nil
1593+
}
1594+
raw := l[0]
1595+
original := raw.(map[string]interface{})
1596+
transformed := make(map[string]interface{})
1597+
1598+
transformedType, err := expandMonitoringUptimeCheckConfigHttpCheckServiceAgentAuthenticationType(original["type"], d, config)
1599+
if err != nil {
1600+
return nil, err
1601+
} else if val := reflect.ValueOf(transformedType); val.IsValid() && !tpgresource.IsEmptyValue(val) {
1602+
transformed["type"] = transformedType
1603+
}
1604+
1605+
return transformed, nil
1606+
}
1607+
1608+
func expandMonitoringUptimeCheckConfigHttpCheckServiceAgentAuthenticationType(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) {
1609+
return v, nil
1610+
}
1611+
15471612
func expandMonitoringUptimeCheckConfigHttpCheckPort(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) {
15481613
return v, nil
15491614
}

google-beta/services/monitoring/resource_monitoring_uptime_check_config_generated_test.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,9 @@ resource "google_monitoring_uptime_check_config" "https" {
206206
port = "443"
207207
use_ssl = true
208208
validate_ssl = true
209+
service_agent_authentication {
210+
type = "OIDC_TOKEN"
211+
}
209212
}
210213
211214
monitored_resource {

website/docs/r/monitoring_uptime_check_config.html.markdown

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,9 @@ resource "google_monitoring_uptime_check_config" "https" {
134134
port = "443"
135135
use_ssl = true
136136
validate_ssl = true
137+
service_agent_authentication {
138+
type = "OIDC_TOKEN"
139+
}
137140
}
138141
139142
monitored_resource {
@@ -362,9 +365,14 @@ The following arguments are supported:
362365

363366
* `auth_info` -
364367
(Optional)
365-
The authentication information. Optional when creating an HTTP check; defaults to empty.
368+
The authentication information using username and password. Optional when creating an HTTP check; defaults to empty. Do not use with other authentication fields.
366369
Structure is [documented below](#nested_auth_info).
367370

371+
* `service_agent_authentication` -
372+
(Optional)
373+
The authentication information using the Monitoring Service Agent. Optional when creating an HTTPS check; defaults to empty. Do not use with other authentication fields.
374+
Structure is [documented below](#nested_service_agent_authentication).
375+
368376
* `port` -
369377
(Optional)
370378
The port to the page to run the check against. Will be combined with `host` (specified within the [`monitored_resource`](#nested_monitored_resource)) and path to construct the full URL. Optional (defaults to 80 without SSL, or 443 with SSL).
@@ -415,6 +423,13 @@ The following arguments are supported:
415423
(Required)
416424
The username to authenticate.
417425

426+
<a name="nested_service_agent_authentication"></a>The `service_agent_authentication` block supports:
427+
428+
* `type` -
429+
(Optional)
430+
The type of authentication to use.
431+
Possible values are: `SERVICE_AGENT_AUTHENTICATION_TYPE_UNSPECIFIED`, `OIDC_TOKEN`.
432+
418433
<a name="nested_accepted_response_status_codes"></a>The `accepted_response_status_codes` block supports:
419434

420435
* `status_value` -

0 commit comments

Comments
 (0)