provider/fastly: Make Fastly Service Backends optional

Backends must be defined in the config, but may optionally be declared
inside custom VCL. Here we mark Backends optional to enable that.
This commit is contained in:
clint shryock 2017-02-16 16:18:39 -06:00
parent ae6d82fea8
commit 896d1d30fb
3 changed files with 19 additions and 13 deletions

View File

@ -109,7 +109,7 @@ func resourceServiceV1() *schema.Resource {
"backend": { "backend": {
Type: schema.TypeSet, Type: schema.TypeSet,
Required: true, Optional: true,
Elem: &schema.Resource{ Elem: &schema.Resource{
Schema: map[string]*schema.Schema{ Schema: map[string]*schema.Schema{
// required fields // required fields

View File

@ -82,11 +82,6 @@ resource "fastly_service_v1" "foo" {
comment = "tf-testing-domain" comment = "tf-testing-domain"
} }
backend {
address = "aws.amazon.com"
name = "amazon docs"
}
vcl { vcl {
name = "my_custom_main_vcl" name = "my_custom_main_vcl"
content = <<EOF content = <<EOF
@ -99,6 +94,11 @@ sub vcl_recv {
return(lookup); return(lookup);
} }
backend amazondocs {
.host = "127.0.0.1";
.port = "80";
}
EOF EOF
main = true main = true
} }
@ -117,11 +117,6 @@ resource "fastly_service_v1" "foo" {
comment = "tf-testing-domain" comment = "tf-testing-domain"
} }
backend {
address = "aws.amazon.com"
name = "amazon docs"
}
vcl { vcl {
name = "my_custom_main_vcl" name = "my_custom_main_vcl"
content = <<EOF content = <<EOF
@ -134,6 +129,11 @@ sub vcl_recv {
return(lookup); return(lookup);
} }
backend amazondocs {
.host = "127.0.0.1";
.port = "80";
}
EOF EOF
main = true main = true
} }
@ -144,6 +144,11 @@ EOF
sub vcl_error { sub vcl_error {
#FASTLY error #FASTLY error
} }
backend amazondocs {
.host = "127.0.0.1";
.port = "80";
}
EOF EOF
} }

View File

@ -132,8 +132,9 @@ The following arguments are supported:
* `name` - (Required) The unique name for the Service to create. * `name` - (Required) The unique name for the Service to create.
* `domain` - (Required) A set of Domain names to serve as entry points for your * `domain` - (Required) A set of Domain names to serve as entry points for your
Service. Defined below. Service. Defined below.
* `backend` - (Required) A set of Backends to service requests from your Domains. * `backend` - (Optional) A set of Backends to service requests from your Domains.
Defined below. Defined below. Backends must be defined in this argument, or defined in the
`vcl` argument below
* `condition` - (Optional) A set of conditions to add logic to any basic * `condition` - (Optional) A set of conditions to add logic to any basic
configuration object in this service. Defined below. configuration object in this service. Defined below.
* `cache_setting` - (Optional) A set of Cache Settings, allowing you to override * `cache_setting` - (Optional) A set of Cache Settings, allowing you to override