github.com/nathanielks/terraform@v0.6.1-0.20170509030759-13e1a62319dc/website/source/docs/providers/fastly/r/service_v1.html.markdown (about)

     1  ---
     2  layout: "fastly"
     3  page_title: "Fastly: service_v1"
     4  sidebar_current: "docs-fastly-resource-service-v1"
     5  description: |-
     6    Provides an Fastly Service
     7  ---
     8  
     9  # fastly_service_v1
    10  
    11  Provides a Fastly Service, representing the configuration for a website, app,
    12  API, or anything else to be served through Fastly. A Service encompasses Domains
    13  and Backends.
    14  
    15  The Service resource requires a domain name that is correctly set up to direct
    16  traffic to the Fastly service. See Fastly's guide on [Adding CNAME Records][fastly-cname]
    17  on their documentation site for guidance.
    18  
    19  ## Example Usage
    20  
    21  Basic usage:
    22  
    23  ```hcl
    24  resource "fastly_service_v1" "demo" {
    25    name = "demofastly"
    26  
    27    domain {
    28      name    = "demo.notexample.com"
    29      comment = "demo"
    30    }
    31  
    32    backend {
    33      address = "127.0.0.1"
    34      name    = "localhost"
    35      port    = 80
    36    }
    37  
    38    force_destroy = true
    39  }
    40  ```
    41  
    42  Basic usage with an Amazon S3 Website and that removes the `x-amz-request-id` header:
    43  
    44  ```hcl
    45  resource "fastly_service_v1" "demo" {
    46    name = "demofastly"
    47  
    48    domain {
    49      name    = "demo.notexample.com"
    50      comment = "demo"
    51    }
    52  
    53    backend {
    54      address = "demo.notexample.com.s3-website-us-west-2.amazonaws.com"
    55      name    = "AWS S3 hosting"
    56      port    = 80
    57    }
    58  
    59    header {
    60      destination = "http.x-amz-request-id"
    61      type        = "cache"
    62      action      = "delete"
    63      name        = "remove x-amz-request-id"
    64    }
    65  
    66    gzip {
    67      name          = "file extensions and content types"
    68      extensions    = ["css", "js"]
    69      content_types = ["text/html", "text/css"]
    70    }
    71  
    72    default_host = "${aws_s3_bucket.website.name}.s3-website-us-west-2.amazonaws.com"
    73  
    74    force_destroy = true
    75  }
    76  
    77  resource "aws_s3_bucket" "website" {
    78    bucket = "demo.notexample.com"
    79    acl    = "public-read"
    80  
    81    website {
    82      index_document = "index.html"
    83      error_document = "error.html"
    84    }
    85  }
    86  ```
    87  
    88  Basic usage with [custom
    89  VCL](https://docs.fastly.com/guides/vcl/uploading-custom-vcl) (must be
    90  enabled on your Fastly account):
    91  
    92  ```hcl
    93  resource "fastly_service_v1" "demo" {
    94    name = "demofastly"
    95  
    96    domain {
    97      name    = "demo.notexample.com"
    98      comment = "demo"
    99    }
   100  
   101    backend {
   102      address = "127.0.0.1"
   103      name    = "localhost"
   104      port    = 80
   105    }
   106  
   107    force_destroy = true
   108  
   109    vcl {
   110      name    = "my_custom_main_vcl"
   111      content = "${file("${path.module}/my_custom_main.vcl")}"
   112      main    = true
   113    }
   114  
   115    vcl {
   116      name    = "my_custom_library_vcl"
   117      content = "${file("${path.module}/my_custom_library.vcl")}"
   118    }
   119  }
   120  ```
   121  
   122  -> **Note:** For an AWS S3 Bucket, the Backend address is
   123  `<domain>.s3-website-<region>.amazonaws.com`. The `default_host` attribute
   124  should be set to `<bucket_name>.s3-website-<region>.amazonaws.com`. See the
   125  Fastly documentation on [Amazon S3][fastly-s3].
   126  
   127  ## Argument Reference
   128  
   129  The following arguments are supported:
   130  
   131  * `name` - (Required) The unique name for the Service to create.
   132  * `domain` - (Required) A set of Domain names to serve as entry points for your
   133  Service. Defined below.
   134  * `backend` - (Optional) A set of Backends to service requests from your Domains.
   135  Defined below. Backends must be defined in this argument, or defined in the
   136  `vcl` argument below
   137  * `condition` - (Optional) A set of conditions to add logic to any basic
   138  configuration object in this service. Defined below.
   139  * `cache_setting` - (Optional) A set of Cache Settings, allowing you to override
   140  when an item is not to be cached based on an above `condition`. Defined below
   141  * `gzip` - (Required) A set of gzip rules to control automatic gzipping of
   142  content. Defined below.
   143  * `header` - (Optional) A set of Headers to manipulate for each request. Defined
   144  below.
   145  * `healthcheck` - (Optional) Automated healthchecks on the cache that can change how fastly interacts with the cache based on its health.
   146  * `default_host` - (Optional) The default hostname.
   147  * `default_ttl` - (Optional) The default Time-to-live (TTL) for
   148  requests.
   149  * `force_destroy` - (Optional) Services that are active cannot be destroyed. In
   150  order to destroy the Service, set `force_destroy` to `true`. Default `false`.
   151  * `request_setting` - (Optional) A set of Request modifiers. Defined below
   152  * `s3logging` - (Optional) A set of S3 Buckets to send streaming logs too.
   153  Defined below.
   154  * `papertrail` - (Optional) A Papertrail endpoint to send streaming logs too.
   155  Defined below.
   156  * `sumologic` - (Optional) A Sumologic endpoint to send streaming logs too.
   157  Defined below.
   158  * `gcslogging` - (Optional) A gcs endpoint to send streaming logs too.
   159  Defined below.
   160  * `response_object` - (Optional) Allows you to create synthetic responses that exist entirely on the varnish machine. Useful for creating error or maintenance pages that exists outside the scope of your datacenter. Best when used with Condition objects.
   161  * `vcl` - (Optional) A set of custom VCL configuration blocks. The
   162  ability to upload custom VCL code is not enabled by default for new Fastly
   163  accounts (see the [Fastly documentation](https://docs.fastly.com/guides/vcl/uploading-custom-vcl) for details).
   164  
   165  The `domain` block supports:
   166  
   167  * `name` - (Required) The domain to which this Service will respond.
   168  * `comment` - (Optional) An optional comment about the Domain.
   169  
   170  The `backend` block supports:
   171  
   172  * `name` - (Required, string) Name for this Backend. Must be unique to this Service.
   173  * `address` - (Required, string) An IPv4, hostname, or IPv6 address for the Backend.
   174  * `auto_loadbalance` - (Optional, boolean) Denotes if this Backend should be
   175  included in the pool of backends that requests are load balanced against.
   176  Default `true`.
   177  * `between_bytes_timeout` - (Optional) How long to wait between bytes in milliseconds. Default `10000`.
   178  * `connect_timeout` - (Optional) How long to wait for a timeout in milliseconds.
   179  Default `1000`
   180  * `error_threshold` - (Optional) Number of errors to allow before the Backend is marked as down. Default `0`.
   181  * `first_byte_timeout` - (Optional) How long to wait for the first bytes in milliseconds. Default `15000`.
   182  * `max_conn` - (Optional) Maximum number of connections for this Backend.
   183  Default `200`.
   184  * `port` - (Optional) The port number on which the Backend responds. Default `80`.
   185  * `request_condition` - (Optional, string) Name of already defined `condition`, which if met, will select this backend during a request.
   186  * `ssl_check_cert` - (Optional) Be strict about checking SSL certs. Default `true`.
   187  * `ssl_hostname` - (Optional, deprecated by Fastly) Used for both SNI during the TLS handshake and to validate the cert.
   188  * `ssl_cert_hostname` - (Optional) Overrides ssl_hostname, but only for cert verification. Does not affect SNI at all.
   189  * `ssl_sni_hostname` - (Optional) Overrides ssl_hostname, but only for SNI in the handshake. Does not affect cert validation at all.
   190  * `shield` - (Optional) The POP of the shield designated to reduce inbound load.
   191  * `weight` - (Optional) The [portion of traffic](https://docs.fastly.com/guides/performance-tuning/load-balancing-configuration.html#how-weight-affects-load-balancing) to send to this Backend. Each Backend receives `weight / total` of the traffic. Default `100`.
   192  
   193  The `condition` block supports allows you to add logic to any basic configuration
   194  object in a service. See Fastly's documentation
   195  ["About Conditions"](https://docs.fastly.com/guides/conditions/about-conditions)
   196  for more detailed information on using Conditions. The Condition `name` can be
   197  used in the `request_condition`, `response_condition`, or
   198  `cache_condition` attributes of other block settings.
   199  
   200  * `name` - (Required) The unique name for the condition.
   201  * `statement` - (Required) The statement used to determine if the condition is met.
   202  * `priority` - (Required) A number used to determine the order in which multiple
   203  conditions execute. Lower numbers execute first.
   204  * `type` - (Required) Type of condition, either `REQUEST` (req), `RESPONSE`
   205  (req, resp), or `CACHE` (req, beresp).
   206  
   207  The `cache_setting` block supports:
   208  
   209  * `name` - (Required) Unique name for this Cache Setting.
   210  * `action` - (Required) One of `cache`, `pass`, or `restart`, as defined
   211  on Fastly's documentation under ["Caching action descriptions"](https://docs.fastly.com/guides/performance-tuning/controlling-caching#caching-action-descriptions).
   212  * `cache_condition` - (Optional) Name of already defined `condition` used to test whether this settings object should be used. This `condition` must be of type `CACHE`.
   213  * `stale_ttl` - (Optional) Max "Time To Live" for stale (unreachable) objects.
   214  Default `300`.
   215  * `ttl` - (Optional) The Time-To-Live (TTL) for the object.
   216  
   217  The `gzip` block supports:
   218  
   219  * `name` - (Required) A unique name.
   220  * `content_types` - (Optional) The content-type for each type of content you wish to
   221  have dynamically gzip'ed. Example: `["text/html", "text/css"]`.
   222  * `extensions` - (Optional) File extensions for each file type to dynamically
   223  gzip. Example: `["css", "js"]`.
   224  * `cache_condition` - (Optional) Name of already defined `condition` controlling when this gzip configuration applies. This `condition` must be of type `CACHE`. For detailed information about Conditionals,
   225  see [Fastly's Documentation on Conditionals][fastly-conditionals].
   226  
   227  
   228  The `Header` block supports adding, removing, or modifying Request and Response
   229  headers. See Fastly's documentation on
   230  [Adding or modifying headers on HTTP requests and responses](https://docs.fastly.com/guides/basic-configuration/adding-or-modifying-headers-on-http-requests-and-responses#field-description-table) for more detailed information on any of the properties below.
   231  
   232  * `name` - (Required) Unique name for this header attribute.
   233  * `action` - (Required) The Header manipulation action to take; must be one of
   234  `set`, `append`, `delete`, `regex`, or `regex_repeat`.
   235  * `type` - (Required) The Request type on which to apply the selected Action; must be one of `request`, `fetch`, `cache` or `response`.
   236  * `destination` - (Required) The name of the header that is going to be affected by the Action.
   237  * `ignore_if_set` - (Optional) Do not add the header if it is already present. (Only applies to the `set` action.). Default `false`.
   238  * `source` - (Optional) Variable to be used as a source for the header
   239  content. (Does not apply to the `delete` action.)
   240  * `regex` - (Optional) Regular expression to use (Only applies to the `regex` and `regex_repeat` actions.)
   241  * `substitution` - (Optional) Value to substitute in place of regular expression. (Only applies to the `regex` and `regex_repeat` actions.)
   242  * `priority` - (Optional) Lower priorities execute first. Default: `100`.
   243  * `request_condition` - (Optional) Name of already defined `condition` to apply. This `condition` must be of type `REQUEST`.
   244  * `cache_condition` - (Optional) Name of already defined `condition` to apply. This `condition` must be of type `CACHE`.
   245  * `response_condition` - (Optional) Name of already defined `condition` to apply. This `condition` must be of type `RESPONSE`. For detailed information about Conditionals,
   246  see [Fastly's Documentation on Conditionals][fastly-conditionals].
   247  
   248  The `healthcheck` block supports:
   249  
   250  * `name` - (Required) A unique name to identify this Healthcheck.
   251  * `host` - (Required) Address of the host to check.
   252  * `path` - (Required) The path to check.
   253  * `check_interval` - (Optional) How often to run the Healthcheck in milliseconds. Default `5000`.
   254  * `expected_response` - (Optional) The status code expected from the host. Default `200`.
   255  * `http_version` - (Optional) Whether to use version 1.0 or 1.1 HTTP. Default `1.1`.
   256  * `initial` - (Optional) When loading a config, the initial number of probes to be seen as OK. Default `2`.
   257  * `method` - (Optional) Which HTTP method to use. Default `HEAD`.
   258  * `threshold` - (Optional) How many Healthchecks must succeed to be considered healthy. Default `3`.
   259  * `timeout` - (Optional) Timeout in milliseconds. Default `500`.
   260  * `window` - (Optional) The number of most recent Healthcheck queries to keep for this Healthcheck. Default `5`.
   261  
   262  The `request_setting` block allow you to customize Fastly's request handling, by
   263  defining behavior that should change based on a predefined `condition`:
   264  
   265  * `name` - (Required) The domain for this request setting.
   266  * `request_condition` - (Optional) Name of already defined `condition` to
   267  determine if this request setting should be applied.
   268  * `max_stale_age` - (Optional) How old an object is allowed to be to serve
   269  `stale-if-error` or `stale-while-revalidate`, in seconds. Default `60`.
   270  * `force_miss` - (Optional) Force a cache miss for the request. If specified,
   271  can be `true` or `false`.
   272  * `force_ssl` - (Optional) Forces the request to use SSL (Redirects a non-SSL request to SSL).
   273  * `action` - (Optional) Allows you to terminate request handling and immediately
   274  perform an action. When set it can be `lookup` or `pass` (Ignore the cache completely).
   275  * `bypass_busy_wait` - (Optional) Disable collapsed forwarding, so you don't wait
   276  for other objects to origin.
   277  * `hash_keys` - (Optional) Comma separated list of varnish request object fields
   278  that should be in the hash key.
   279  * `xff` - (Optional) X-Forwarded-For, should be `clear`, `leave`, `append`,
   280  `append_all`, or `overwrite`. Default `append`.
   281  * `timer_support` - (Optional) Injects the X-Timer info into the request for
   282  viewing origin fetch durations.
   283  * `geo_headers` - (Optional) Injects Fastly-Geo-Country, Fastly-Geo-City, and
   284  Fastly-Geo-Region into the request headers.
   285  * `default_host` - (Optional) Sets the host header.
   286  
   287  The `s3logging` block supports:
   288  
   289  * `name` - (Required) A unique name to identify this S3 Logging Bucket.
   290  * `bucket_name` - (Optional) An optional comment about the Domain.
   291  * `s3_access_key` - (Required) AWS Access Key of an account with the required
   292  permissions to post logs. It is **strongly** recommended you create a separate
   293  IAM user with permissions to only operate on this Bucket. This key will be
   294  not be encrypted. You can provide this key via an environment variable, `FASTLY_S3_ACCESS_KEY`.
   295  * `s3_secret_key` - (Required) AWS Secret Key of an account with the required
   296  permissions to post logs. It is **strongly** recommended you create a separate
   297  IAM user with permissions to only operate on this Bucket. This secret will be
   298  not be encrypted. You can provide this secret via an environment variable, `FASTLY_S3_SECRET_KEY`.
   299  * `path` - (Optional) Path to store the files. Must end with a trailing slash.
   300  If this field is left empty, the files will be saved in the bucket's root path.
   301  * `domain` - (Optional) If you created the S3 bucket outside of `us-east-1`,
   302  then specify the corresponding bucket endpoint. Example: `s3-us-west-2.amazonaws.com`.
   303  * `period` - (Optional) How frequently the logs should be transferred, in
   304  seconds. Default `3600`.
   305  * `gzip_level` - (Optional) Level of GZIP compression, from `0-9`. `0` is no
   306  compression. `1` is fastest and least compressed, `9` is slowest and most
   307  compressed. Default `0`.
   308  * `format` - (Optional) Apache-style string or VCL variables to use for log formatting. Defaults to Apache Common Log format (`%h %l %u %t %r %>s`)
   309  * `timestamp_format` - (Optional) `strftime` specified timestamp formatting (default `%Y-%m-%dT%H:%M:%S.000`).
   310  * `response_condition` - (Optional) Name of already defined `condition` to apply. This `condition` must be of type `RESPONSE`. For detailed information about Conditionals,
   311  see [Fastly's Documentation on Conditionals][fastly-conditionals].
   312  
   313  The `papertrail` block supports:
   314  
   315  * `name` - (Required) A unique name to identify this Papertrail endpoint.
   316  * `address` - (Required) The address of the Papertrail endpoint.
   317  * `port` - (Required) The port associated with the address where the Papertrail endpoint can be accessed.
   318  * `format` - (Optional) Apache-style string or VCL variables to use for log formatting. Defaults to Apache Common Log format (`%h %l %u %t %r %>s`)
   319  * `response_condition` - (Optional) Name of already defined `condition` to apply. This `condition` must be of type `RESPONSE`. For detailed information about Conditionals,
   320  see [Fastly's Documentation on Conditionals][fastly-conditionals].
   321  
   322  The `sumologic` block supports:
   323  
   324  * `name` - (Required) A unique name to identify this Sumologic endpoint.
   325  * `url` - (Required) The URL to Sumologic collector endpoint
   326  * `format` - (Optional) Apache-style string or VCL variables to use for log formatting. Defaults to Apache Common Log format (`%h %l %u %t %r %>s`)
   327  * `format_version` - (Optional) The version of the custom logging format used for the configured endpoint. Can be either 1 (the default, version 1 log format) or 2 (the version 2 log format).
   328  * `response_condition` - (Optional) Name of already defined `condition` to apply. This `condition` must be of type `RESPONSE`. For detailed information about Conditionals, see [Fastly's Documentation on Conditionals][fastly-conditionals].
   329  * `message_type` - (Optional) How the message should be formatted. One of: classic, loggly, logplex, blank. See [Fastly's Documentation on Sumologic][fastly-sumologic]
   330  
   331  The `gcslogging` block supports:
   332  
   333  * `name` - (Required) A unique name to identify this GCS endpoint.
   334  * `email` - (Required) The email address associated with the target GCS bucket on your account.
   335  * `bucket_name` - (Required) The name of the bucket in which to store the logs.
   336  * `secret_key` - (Required) The secret key associated with the target gcs bucket on your account.
   337  * `path` - (Optional) Path to store the files. Must end with a trailing slash.
   338  If this field is left empty, the files will be saved in the bucket's root path.
   339  * `period` - (Optional) How frequently the logs should be transferred, in
   340  seconds. Default `3600`.
   341  * `gzip_level` - (Optional) Level of GZIP compression, from `0-9`. `0` is no
   342  compression. `1` is fastest and least compressed, `9` is slowest and most
   343  compressed. Default `0`.
   344  * `format` - (Optional) Apache-style string or VCL variables to use for log formatting. Defaults to Apache Common Log format (`%h %l %u %t %r %>s`)
   345  * `response_condition` - (Optional) Name of already defined `condition` to apply. This `condition` must be of type `RESPONSE`. For detailed information about Conditionals, see [Fastly's Documentation on Conditionals][fastly-conditionals].
   346  
   347  The `response_object` block supports:
   348  
   349  * `name` - (Required) A unique name to identify this Response Object.
   350  * `status` - (Optional) The HTTP Status Code. Default `200`.
   351  * `response` - (Optional) The HTTP Response. Default `Ok`.
   352  * `content` - (Optional) The content to deliver for the response object.
   353  * `content_type` - (Optional) The MIME type of the content.
   354  * `request_condition` - (Optional) Name of already defined `condition` to be checked during the request phase. If the condition passes then this object will be delivered. This `condition` must be of type `REQUEST`.
   355  * `cache_condition` - (Optional) Name of already defined `condition` to check after we have retrieved an object. If the condition passes then deliver this Request Object instead. This `condition` must be of type `CACHE`. For detailed information about Conditionals,
   356  see [Fastly's Documentation on Conditionals][fastly-conditionals].
   357  
   358  
   359  The `vcl` block supports:
   360  
   361  * `name` - (Required) A unique name for this configuration block.
   362  * `content` - (Required) The custom VCL code to upload.
   363  * `main` - (Optional) If `true`, use this block as the main configuration. If
   364  `false`, use this block as an includable library. Only a single VCL block can be
   365  marked as the main block. Default is `false`.
   366  
   367  ## Attributes Reference
   368  
   369  The following attributes are exported:
   370  
   371  * `id` - The ID of the Service.
   372  * `name` – Name of this service.
   373  * `active_version` - The currently active version of your Fastly
   374  Service.
   375  * `domain` – Set of Domains. See above for details.
   376  * `backend` – Set of Backends. See above for details.
   377  * `header` – Set of Headers. See above for details.
   378  * `s3logging` – Set of S3 Logging configurations. See above for details.
   379  * `papertrail` – Set of Papertrail configurations. See above for details.
   380  * `response_object` - Set of Response Object configurations. See above for details.
   381  * `vcl` – Set of custom VCL configurations. See above for details.
   382  * `default_host` – Default host specified.
   383  * `default_ttl` - Default TTL.
   384  * `force_destroy` - Force the destruction of the Service on delete.
   385  
   386  [fastly-s3]: https://docs.fastly.com/guides/integrations/amazon-s3
   387  [fastly-cname]: https://docs.fastly.com/guides/basic-setup/adding-cname-records
   388  [fastly-conditionals]: https://docs.fastly.com/guides/conditions/using-conditions
   389  [fastly-sumologic]: https://docs.fastly.com/api/logging#logging_sumologic
   390  [fastly-gcs]: https://docs.fastly.com/api/logging#logging_gcs