github.com/jrasell/terraform@v0.6.17-0.20160523115548-2652f5232949/website/source/docs/providers/fastly/r/service_v1.html.markdown (about)

     1  ---
     2  layout: "fastly"
     3  page_title: "Fastly: aws_vpc"
     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  ```
    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  
    43  Basic usage with an Amazon S3 Website, and removes the `x-amz-request-id` header:
    44  
    45  ```
    46  resource "fastly_service_v1" "demo" {
    47    name = "demofastly"
    48  
    49    domain {
    50      name    = "demo.notexample.com"
    51      comment = "demo"
    52    }
    53  
    54    backend {
    55      address = "demo.notexample.com.s3-website-us-west-2.amazonaws.com"
    56      name    = "AWS S3 hosting"
    57      port    = 80
    58    }
    59  
    60    header {
    61      destination = "http.x-amz-request-id"
    62      type        = "cache"
    63      action      = "delete"
    64      name        = "remove x-amz-request-id"
    65    }
    66  
    67    gzip {
    68      name          = "file extensions and content types"
    69      extensions    = ["css", "js"]
    70      content_types = ["text/html", "text/css"]
    71    }
    72  
    73    default_host = "${aws_s3_bucket.website.name}.s3-website-us-west-2.amazonaws.com"
    74  
    75    force_destroy = true
    76  }
    77  
    78  resource "aws_s3_bucket" "website" {
    79    bucket = "demo.notexample.com"
    80    acl    = "public-read"
    81  
    82    website {
    83      index_document = "index.html"
    84      error_document = "error.html"
    85    }
    86  }
    87  ```
    88  
    89  Basic usage with [custom VCL](https://docs.fastly.com/guides/vcl/uploading-custom-vcl) (must be enabled on your Fastly account):
    90  
    91  ```
    92  resource "fastly_service_v1" "demo" {
    93    name = "demofastly"
    94  
    95    domain {
    96      name    = "demo.notexample.com"
    97      comment = "demo"
    98    }
    99  
   100    backend {
   101      address = "127.0.0.1"
   102      name    = "localhost"
   103      port    = 80
   104    }
   105  
   106    force_destroy = true
   107  
   108    vcl {
   109      name = "my_custom_main_vcl"
   110      content = "${file("${path.module}/my_custom_main.vcl")}"
   111      main = true
   112    }
   113  
   114    vcl {
   115      name = "my_custom_library_vcl"
   116      content = "${file("${path.module}/my_custom_library.vcl")}"
   117    }
   118  }
   119  ```
   120  
   121  **Note:** For an AWS S3 Bucket, the Backend address is
   122  `<domain>.s3-website-<region>.amazonaws.com`. The `default_host` attribute
   123  should be set to `<bucket_name>.s3-website-<region>.amazonaws.com`. See the
   124  Fastly documentation on [Amazon S3][fastly-s3].
   125  
   126  ## Argument Reference
   127  
   128  The following arguments are supported:
   129  
   130  * `name` - (Required) The unique name for the Service to create
   131  * `domain` - (Required) A set of Domain names to serve as entry points for your
   132  Service. Defined below
   133  * `backend` - (Required) A set of Backends to service requests from your Domains.
   134  Defined below
   135  * `condition` - (Optional) A set of conditions to add logic to any basic
   136  configuration object in this service. Defined below
   137  * `gzip` - (Required) A set of gzip rules to control automatic gzipping of
   138  content. Defined below
   139  * `header` - (Optional) A set of Headers to manipulate for each request. Defined
   140  below
   141  * `default_host` - (Optional) The default hostname
   142  * `default_ttl` - (Optional) The default Time-to-live (TTL) for requests
   143  * `force_destroy` - (Optional) Services that are active cannot be destroyed. In
   144  order to destroy the Service, set `force_destroy` to `true`. Default `false`.
   145  * `request_setting` - (Optional) A set of Request modifiers. Defined below
   146  * `s3logging` - (Optional) A set of S3 Buckets to send streaming logs too.
   147  Defined below
   148  * `vcl` - (Optional) A set of custom VCL configuration blocks. Note that the
   149  ability to upload custom VCL code is not enabled by default for new Fastly
   150  accounts (see the [Fastly documentation](https://docs.fastly.com/guides/vcl/uploading-custom-vcl) for details).
   151  
   152  
   153  The `domain` block supports:
   154  
   155  * `name` - (Required) The domain that this Service will respond to
   156  * `comment` - (Optional) An optional comment about the Domain
   157  
   158  The `backend` block supports:
   159  
   160  * `name` - (Required, string) Name for this Backend. Must be unique to this Service
   161  * `address` - (Required, string) An IPv4, hostname, or IPv6 address for the Backend
   162  * `auto_loadbalance` - (Optional, boolean) Denote if this Backend should be
   163  included in the pool of backends that requests are load balanced against.
   164  Default `true`
   165  * `between_bytes_timeout` - (Optional) How long to wait between bytes in milliseconds. Default `10000`
   166  * `connect_timeout` - (Optional) How long to wait for a timeout in milliseconds.
   167  Default `1000`
   168  * `error_threshold` - (Optional) Number of errors to allow before the Backend is marked as down. Default `0`
   169  * `first_byte_timeout` - (Optional) How long to wait for the first bytes in milliseconds. Default `15000`
   170  * `max_conn` - (Optional) Maximum number of connections for this Backend.
   171  Default `200`
   172  * `port` - (Optional) The port number Backend responds on. Default `80`
   173  * `ssl_check_cert` - (Optional) Be strict on checking SSL certs. Default `true`
   174  * `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`
   175  
   176  The `condition` block supports allows you to add logic to any basic configuration
   177  object in a service. See Fastly's documentation
   178  ["About Conditions"](https://docs.fastly.com/guides/conditions/about-conditions)
   179  for more detailed information on using Conditions. The Condition `name` can be
   180  used in the `request_condition`, `response_condition`, or
   181  `cache_condition` attributes of other block settings
   182  
   183  * `name` - (Required) A unique name of the condition
   184  * `statement` - (Required) The statement used to determine if the condition is met
   185  * `priority` - (Required) A number used to determine the order in which multiple
   186  conditions execute. Lower numbers execute first
   187  * `type` - (Required) Type of the condition, either `REQUEST` (req), `RESPONSE`
   188  (req, resp), or `CACHE` (req, beresp)
   189  
   190  The `gzip` block supports:
   191  
   192  * `name` - (Required) A unique name
   193  * `content_types` - (Optional) content-type for each type of content you wish to 
   194  have dynamically gzipped. Ex: `["text/html", "text/css"]`
   195  * `extensions` - (Optional) File extensions for each file type to dynamically 
   196  gzip. Ex: `["css", "js"]`
   197  
   198  
   199  The `Header` block supports adding, removing, or modifying Request and Response
   200  headers. See Fastly's documentation on 
   201  [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 
   202  of the properties below.
   203  
   204  * `name` - (Required) A unique name to refer to this header attribute
   205  * `action` - (Required) The Header manipulation action to take; must be one of
   206  `set`, `append`, `delete`, `regex`, or `regex_repeat`
   207  * `type` - (Required) The Request type to apply the selected Action on
   208  * `destination` - (Required) The name of the header that is going to be affected 
   209  by the Action
   210  * `ignore_if_set` - (Optional) Do not add the header if it is already present. 
   211  (Only applies to `set` action.). Default `false`
   212  * `source` - (Optional) Variable to be used as a source for the header content 
   213  (Does not apply to `delete` action.)
   214  * `regex` - (Optional) Regular expression to use (Only applies to `regex` and `regex_repeat` actions.)
   215  * `substitution` - (Optional) Value to substitute in place of regular expression. (Only applies to `regex` and `regex_repeat`.)
   216  * `priority` - (Optional) Lower priorities execute first. (Default: `100`.)
   217  
   218  The `request_setting` block allow you to customize Fastly's request handling, by
   219  defining behavior that should change based on a predefined `condition`:
   220  
   221  * `name` - (Required) The domain that this request setting
   222  * `request_condition` - (Required) The name of the corresponding `condition` to
   223  determin if this request setting should be applied. The `request_condition` must
   224  match the name of a defined `condition`
   225  * `max_stale_age` - (Optional) How old an object is allowed to be to serve
   226  stale-if-error or stale-while-revalidate, in seconds. Default `60`
   227  * `force_miss` - (Optional) Force a cache miss for the request. If specfified,
   228  can be `true` or `false`.
   229  * `force_ssl` - (Optional) Forces the request use SSL (redirects a non-SSL to SSL)
   230  * `action` - (Optional) Allows you to terminate request handling and immediately
   231  perform an action. When set it can be `lookup` or `pass` (ignore the cache completely)
   232  * `bypass_busy_wait` - (Optional) Disable collapsed forwarding, so you don't wait
   233  for other objects to origin
   234  * `hash_keys` - (Optional) Comma separated list of varnish request object fields
   235  that should be in the hash key
   236  * `xff` - (Optional) X-Forwarded-For -- should be `clear`, `leave`, `append`,
   237  `append_all`, or `overwrite`. Default `append`
   238  * `timer_support` - (Optional) Injects the X-Timer info into the request for
   239  viewing origin fetch durations
   240  * `geo_headers` - (Optional) Injects Fastly-Geo-Country, Fastly-Geo-City, and
   241  Fastly-Geo-Region into the request headers
   242  * `default_host` - (Optional) Sets the host header
   243  
   244  The `s3logging` block supports:
   245  
   246  * `name` - (Required) A unique name to identify this S3 Logging Bucket
   247  * `bucket_name` - (Optional) An optional comment about the Domain
   248  * `s3_access_key` - (Required) AWS Access Key of an account with the required
   249  permissions to post logs. It is **strongly** recommended you create a separate
   250  IAM user with permissions to only operate on this Bucket. This key will be
   251  not be encrypted. You can provide this key via an environment variable, `FASTLY_S3_ACCESS_KEY`
   252  * `s3_secret_key` - (Required) AWS Secret Key of an account with the required
   253  permissions to post logs. It is **strongly** recommended you create a separate
   254  IAM user with permissions to only operate on this Bucket. This secret will be
   255  not be encrypted. You can provide this secret via an environment variable, `FASTLY_S3_SECRET_KEY`
   256  * `path` - (Optional) Path to store the files. Must end with a trailing slash.
   257  If this field is left empty, the files will be saved in the bucket's root path.
   258  * `domain` - (Optional) If you created the S3 bucket outside of `us-east-1`,
   259  then specify the corresponding bucket endpoint. Ex: `s3-us-west-2.amazonaws.com`
   260  * `period` - (Optional) How frequently the logs should be transferred, in
   261  seconds. Default `3600`
   262  * `gzip_level` - (Optional) Level of GZIP compression, from `0-9`. `0` is no
   263  compression. `1` is fastest and least compressed, `9` is slowest and most
   264  compressed. Default `0`
   265  * `format` - (Optional) Apache-style string or VCL variables to use for log formatting. Default
   266  Apache Common Log format (`%h %l %u %t %r %>s`)
   267  * `timestamp_format` - (Optional) `strftime` specified timestamp formatting (default `%Y-%m-%dT%H:%M:%S.000`).
   268  * `request_condition` - (Optional) The VCL request condition to check if this
   269  Request Setting should be applied. For detailed information about Conditionals,
   270  see [Fastly's Documentation on Conditionals][fastly-conditionals]
   271  
   272  The `vcl` block supports:
   273  
   274  * `name` - (Required) A unique name for this configuration block
   275  * `content` - (Required) The custom VCL code to upload.
   276  * `main` - (Optional) If `true`, use this block as the main configuration. If
   277  `false`, use this block as an includable library. Only a single VCL block can be
   278  marked as the main block. Default is `false`.
   279  
   280  ## Attributes Reference
   281  
   282  The following attributes are exported:
   283  
   284  * `id` - The ID of the Service
   285  * `name` – Name of this service
   286  * `active_version` - The currently active version of your Fastly Service
   287  * `domain` – Set of Domains. See above for details
   288  * `backend` – Set of Backends. See above for details
   289  * `header` – Set of Headers. See above for details
   290  * `s3logging` – Set of S3 Logging configurations. See above for details
   291  * `vcl` – Set of custom VCL configurations. See above for details
   292  * `default_host` – Default host specified
   293  * `default_ttl` - Default TTL
   294  * `force_destroy` - Force the destruction of the Service on delete
   295  
   296  
   297  [fastly-s3]: https://docs.fastly.com/guides/integrations/amazon-s3
   298  [fastly-cname]: https://docs.fastly.com/guides/basic-setup/adding-cname-records
   299  [fastly-conditionals]: https://docs.fastly.com/guides/conditions/using-conditions