Skip to content
This repository has been archived by the owner on Jan 13, 2023. It is now read-only.

Commit

Permalink
add support for changing traffic type in spectrum apps (cloudflare#481)
Browse files Browse the repository at this point in the history
  • Loading branch information
gposton authored and patryk committed Oct 1, 2019
1 parent eb7c153 commit fc4e5ec
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
14 changes: 14 additions & 0 deletions cloudflare/resource_cloudflare_spectrum_application.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,15 @@ func resourceCloudflareSpectrumApplication() *schema.Resource {
Required: true,
},

"traffic_type": {
Type: schema.TypeString,
Default: "direct",
Optional: true,
ValidateFunc: validation.StringInSlice([]string{
"direct", "http", "https",
}, false),
},

"dns": {
Type: schema.TypeList,
Required: true,
Expand Down Expand Up @@ -176,6 +185,7 @@ func resourceCloudflareSpectrumApplicationRead(d *schema.ResourceData, meta inte

d.Set("origin_port", application.OriginPort)
d.Set("tls", application.TLS)
d.Set("traffic_type", application.TrafficType)
d.Set("ip_firewall", application.IPFirewall)
d.Set("proxy_protocol", application.ProxyProtocol)

Expand Down Expand Up @@ -273,6 +283,10 @@ func applicationFromResource(d *schema.ResourceData) cloudflare.SpectrumApplicat
application.TLS = tls.(string)
}

if traffic_type, ok := d.GetOk("traffic_type"); ok {
application.TrafficType = traffic_type.(string)
}

if ipFirewall, ok := d.GetOk("ip_firewall"); ok {
application.IPFirewall = ipFirewall.(bool)
}
Expand Down
2 changes: 2 additions & 0 deletions website/docs/r/spectrum_application.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ Provides a Cloudflare Spectrum Application. You can extend the power of Cloudfla
# Define a spectrum application proxies ssh traffic
resource "cloudflare_spectrum_application" "ssh_proxy" {
protocol = "tcp/22"
traffic_type = "direct"
dns = {
type = "CNAME"
name = "ssh.example.com"
Expand All @@ -37,6 +38,7 @@ resource "cloudflare_spectrum_application" "ssh_proxy" {
* `tls` - (Optional) TLS configuration option for Cloudflare to connect to your origin. Valid values are: `off`, `flexible`, `full` and `strict`. Defaults to `off`.
* `ip_firewall` - (Optional) Enables the IP Firewall for this application. Defaults to `true`.
* `proxy_protocol` - (Optional) Enables Proxy Protocol v1 to the origin. Defaults to `false`.
* `traffic_type` - (Optional) Set's application type. Valid values are: `direct`, `http`, `https`. Defaults to `direct`.

**dns**

Expand Down

0 comments on commit fc4e5ec

Please sign in to comment.