Skip to content

Commit 779c907

Browse files
committed
add client_ssl_profile and http_to_https properties to fortiadc_loadbalance_virtual_server resource
1 parent 4e07759 commit 779c907

4 files changed

Lines changed: 37 additions & 2 deletions

File tree

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,8 @@ resource "fortiadc_loadbalance_virtual_server" "myvirtualserver" {
202202
| `profile` | Profile | String | false | `LB_PROF_TCP` |
203203
| `method` | Method | String | false | `LB_METHOD_ROUND_ROBIN` |
204204
| `pool` | Pool name | String | true | |
205+
| `client_ssl_profile` | Client SSL profile | String | false | ` ` |
206+
| `http_to_https` | Redirect HTTP to HTTPS when L7 | Bool | false | `false` |
205207

206208
#### Attributes
207209

fortiadc/resource_fortiadc_loadbalance_virtual_server.go

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,16 @@ func resourceFortiadcLoadbalanceVirtualServer() *schema.Resource {
9090
Type: schema.TypeString,
9191
Required: true,
9292
},
93+
"client_ssl_profile": &schema.Schema{
94+
Type: schema.TypeString,
95+
Optional: true,
96+
Default: "",
97+
},
98+
"http_to_https": &schema.Schema{
99+
Type: schema.TypeBool,
100+
Optional: true,
101+
Default: false,
102+
},
93103
},
94104
}
95105
}
@@ -106,6 +116,11 @@ func resourceFortiadcLoadbalanceVirtualServerCreate(d *schema.ResourceData, m in
106116
return errors.New("nat_source_pool cannot be defined when packet_forward_method is not FullNAT")
107117
}
108118

119+
http2https := "disable"
120+
if d.Get("http_to_https").(bool) {
121+
http2https = "enable"
122+
}
123+
109124
req := gofortiadc.LoadbalanceVirtualServerReq{
110125
Status: d.Get("status").(string),
111126
Type: d.Get("type").(string),
@@ -122,13 +137,15 @@ func resourceFortiadcLoadbalanceVirtualServerCreate(d *schema.ResourceData, m in
122137
Warmup: "0",
123138
Warmrate: "10",
124139
ConnectionRateLimit: fmt.Sprintf("%d", d.Get("connection_rate_limit").(int)),
125-
Log: "enable",
140+
Log: "disable",
126141
Alone: "enable",
127142
Mkey: d.Get("name").(string),
128143
Interface: d.Get("interface").(string),
129144
Profile: d.Get("profile").(string),
130145
Method: d.Get("method").(string),
131146
Pool: d.Get("pool").(string),
147+
ClientSSLProfile: d.Get("client_ssl_profile").(string),
148+
HTTP2HTTPS: http2https,
132149
}
133150

134151
err := client.LoadbalanceCreateVirtualServer(req)
@@ -154,6 +171,11 @@ func resourceFortiadcLoadbalanceVirtualServerRead(d *schema.ResourceData, m inte
154171
contentRouting = true
155172
}
156173

174+
http2https := false
175+
if rs.HTTP2HTTPS == "enable" {
176+
http2https = true
177+
}
178+
157179
d.Set("status", rs.Status)
158180
d.Set("type", rs.Type)
159181
d.Set("address_type", rs.AddrType)
@@ -165,6 +187,8 @@ func resourceFortiadcLoadbalanceVirtualServerRead(d *schema.ResourceData, m inte
165187
d.Set("profile", rs.Profile)
166188
d.Set("method", rs.Method)
167189
d.Set("pool", rs.Pool)
190+
d.Set("client_ssl_profile", rs.ClientSSLProfile)
191+
d.Set("http_to_https", http2https)
168192

169193
port, err := strconv.ParseInt(strings.TrimSpace(rs.Port), 10, 64)
170194
if err != nil {
@@ -199,6 +223,11 @@ func resourceFortiadcLoadbalanceVirtualServerUpdate(d *schema.ResourceData, m in
199223
return errors.New("nat_source_pool cannot be defined when packet_forward_method is not FullNAT")
200224
}
201225

226+
http2https := "disable"
227+
if d.Get("http_to_https").(bool) {
228+
http2https = "enable"
229+
}
230+
202231
req := gofortiadc.LoadbalanceVirtualServerReq{
203232
Status: d.Get("status").(string),
204233
Type: d.Get("type").(string),
@@ -222,6 +251,8 @@ func resourceFortiadcLoadbalanceVirtualServerUpdate(d *schema.ResourceData, m in
222251
Profile: d.Get("profile").(string),
223252
Method: d.Get("method").(string),
224253
Pool: d.Get("pool").(string),
254+
ClientSSLProfile: d.Get("client_ssl_profile").(string),
255+
HTTP2HTTPS: http2https,
225256
}
226257

227258
err := client.LoadbalanceUpdateVirtualServer(req)

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
module github.com/Ouest-France/terraform-provider-fortiadc
22

33
require (
4-
github.com/Ouest-France/gofortiadc v0.0.1
4+
github.com/Ouest-France/gofortiadc v0.0.2
55
github.com/apparentlymart/go-cidr v1.0.0 // indirect
66
github.com/blang/semver v3.5.1+incompatible // indirect
77
github.com/hashicorp/go-getter v0.0.0-20181119194526-bd1edc22f8ea // indirect

go.sum

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
github.com/Ouest-France/gofortiadc v0.0.1 h1:TACbZnsw4vgtCI1t/zlvh+sJy2AlRpTr255sIsvNmmA=
22
github.com/Ouest-France/gofortiadc v0.0.1/go.mod h1:ouc+Fl3luQg5r9Kk8SQNb2tbJaCpd3Xgre/rLswRYUA=
3+
github.com/Ouest-France/gofortiadc v0.0.2 h1:lvv6TjVw/1EwmHVnf5WN866l5ABovZRUz41t72XShqk=
4+
github.com/Ouest-France/gofortiadc v0.0.2/go.mod h1:ouc+Fl3luQg5r9Kk8SQNb2tbJaCpd3Xgre/rLswRYUA=
35
github.com/agext/levenshtein v1.2.1 h1:QmvMAjj2aEICytGiWzmxoE0x2KZvE0fvmqMOfy2tjT8=
46
github.com/agext/levenshtein v1.2.1/go.mod h1:JEDfjyjHDjOF/1e4FlBE/PkbqA9OfWu2ki2W0IB5558=
57
github.com/apparentlymart/go-cidr v1.0.0 h1:lGDvXx8Lv9QHjrAVP7jyzleG4F9+FkRhJcEsDFxeb8w=

0 commit comments

Comments
 (0)