github.com/jdextraze/terraform@v0.6.17-0.20160511153921-e33847c8a8af/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 **Note:** For an AWS S3 Bucket, the Backend address is 90 `<domain>.s3-website-<region>.amazonaws.com`. The `default_host` attribute 91 should be set to `<bucket_name>.s3-website-<region>.amazonaws.com`. See the 92 Fastly documentation on [Amazon S3][fastly-s3]. 93 94 ## Argument Reference 95 96 The following arguments are supported: 97 98 * `name` - (Required) The unique name for the Service to create 99 * `domain` - (Required) A set of Domain names to serve as entry points for your 100 Service. Defined below 101 * `backend` - (Required) A set of Backends to service requests from your Domains. 102 Defined below 103 * `condition` - (Optional) A set of conditions to add logic to any basic 104 configuration object in this service. Defined below 105 * `gzip` - (Required) A set of gzip rules to control automatic gzipping of 106 content. Defined below 107 * `header` - (Optional) A set of Headers to manipulate for each request. Defined 108 below 109 * `default_host` - (Optional) The default hostname 110 * `default_ttl` - (Optional) The default Time-to-live (TTL) for requests 111 * `force_destroy` - (Optional) Services that are active cannot be destroyed. In 112 order to destroy the Service, set `force_destroy` to `true`. Default `false`. 113 * `s3logging` - (Optional) A set of S3 Buckets to send streaming logs too. 114 Defined below 115 116 117 The `domain` block supports: 118 119 * `name` - (Required) The domain that this Service will respond to 120 * `comment` - (Optional) An optional comment about the Domain 121 122 The `backend` block supports: 123 124 * `name` - (Required, string) Name for this Backend. Must be unique to this Service 125 * `address` - (Required, string) An IPv4, hostname, or IPv6 address for the Backend 126 * `auto_loadbalance` - (Optional, boolean) Denote if this Backend should be 127 included in the pool of backends that requests are load balanced against. 128 Default `true` 129 * `between_bytes_timeout` - (Optional) How long to wait between bytes in milliseconds. Default `10000` 130 * `connect_timeout` - (Optional) How long to wait for a timeout in milliseconds. 131 Default `1000` 132 * `error_threshold` - (Optional) Number of errors to allow before the Backend is marked as down. Default `0` 133 * `first_byte_timeout` - (Optional) How long to wait for the first bytes in milliseconds. Default `15000` 134 * `max_conn` - (Optional) Maximum number of connections for this Backend. 135 Default `200` 136 * `port` - (Optional) The port number Backend responds on. Default `80` 137 * `ssl_check_cert` - (Optional) Be strict on checking SSL certs. Default `true` 138 * `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` 139 140 The `condition` block supports allows you to add logic to any basic configuration 141 object in a service. See Fastly's documentation 142 ["About Conditions"](https://docs.fastly.com/guides/conditions/about-conditions) 143 for more detailed information on using Conditions. The Condition `name` can be 144 used in the `request_condition`, `response_condition`, or 145 `cache_condition` attributes of other block settings 146 147 * `name` - (Required) A unique name of the condition 148 * `statement` - (Required) The statement used to determine if the condition is met 149 * `priority` - (Required) A number used to determine the order in which multiple 150 conditions execute. Lower numbers execute first 151 * `type` - (Required) Type of the condition, either `REQUEST` (req), `RESPONSE` 152 (req, resp), or `CACHE` (req, beresp) 153 154 The `gzip` block supports: 155 156 * `name` - (Required) A unique name 157 * `content_types` - (Optional) content-type for each type of content you wish to 158 have dynamically gzipped. Ex: `["text/html", "text/css"]` 159 * `extensions` - (Optional) File extensions for each file type to dynamically 160 gzip. Ex: `["css", "js"]` 161 162 163 The `Header` block supports adding, removing, or modifying Request and Response 164 headers. See Fastly's documentation on 165 [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 166 of the properties below. 167 168 * `name` - (Required) A unique name to refer to this header attribute 169 * `action` - (Required) The Header manipulation action to take; must be one of 170 `set`, `append`, `delete`, `regex`, or `regex_repeat` 171 * `type` - (Required) The Request type to apply the selected Action on 172 * `destination` - (Required) The name of the header that is going to be affected 173 by the Action 174 * `ignore_if_set` - (Optional) Do not add the header if it is already present. 175 (Only applies to `set` action.). Default `false` 176 * `source` - (Optional) Variable to be used as a source for the header content 177 (Does not apply to `delete` action.) 178 * `regex` - (Optional) Regular expression to use (Only applies to `regex` and `regex_repeat` actions.) 179 * `substitution` - (Optional) Value to substitute in place of regular expression. (Only applies to `regex` and `regex_repeat`.) 180 * `priority` - (Optional) Lower priorities execute first. (Default: `100`.) 181 182 The `s3logging` block supports: 183 184 * `name` - (Required) A unique name to identify this S3 Logging Bucket 185 * `bucket_name` - (Optional) An optional comment about the Domain 186 * `s3_access_key` - (Required) AWS Access Key of an account with the required 187 permissions to post logs. It is **strongly** recommended you create a separate 188 IAM user with permissions to only operate on this Bucket. This key will be 189 not be encrypted. You can provide this key via an environment variable, `FASTLY_S3_ACCESS_KEY` 190 * `s3_secret_key` - (Required) AWS Secret Key of an account with the required 191 permissions to post logs. It is **strongly** recommended you create a separate 192 IAM user with permissions to only operate on this Bucket. This secret will be 193 not be encrypted. You can provide this secret via an environment variable, `FASTLY_S3_SECRET_KEY` 194 * `path` - (Optional) Path to store the files. Must end with a trailing slash. 195 If this field is left empty, the files will be saved in the bucket's root path. 196 * `domain` - (Optional) If you created the S3 bucket outside of `us-east-1`, 197 then specify the corresponding bucket endpoint. Ex: `s3-us-west-2.amazonaws.com` 198 * `period` - (Optional) How frequently the logs should be transferred, in 199 seconds. Default `3600` 200 * `gzip_level` - (Optional) Level of GZIP compression, from `0-9`. `0` is no 201 compression. `1` is fastest and least compressed, `9` is slowest and most 202 compressed. Default `0` 203 * `format` - (Optional) Apache-style string or VCL variables to use for log formatting. Default 204 Apache Common Log format (`%h %l %u %t %r %>s`) 205 * `timestamp_format` - (Optional) `strftime` specified timestamp formatting (default `%Y-%m-%dT%H:%M:%S.000`). 206 207 208 ## Attributes Reference 209 210 The following attributes are exported: 211 212 * `id` - The ID of the Service 213 * `name` – Name of this service 214 * `active_version` - The currently active version of your Fastly Service 215 * `domain` – Set of Domains. See above for details 216 * `backend` – Set of Backends. See above for details 217 * `header` – Set of Headers. See above for details 218 * `s3logging` – Set of S3 Logging configurations. See above for details 219 * `default_host` – Default host specified 220 * `default_ttl` - Default TTL 221 * `force_destroy` - Force the destruction of the Service on delete 222 223 224 [fastly-s3]: https://docs.fastly.com/guides/integrations/amazon-s3 225 [fastly-cname]: https://docs.fastly.com/guides/basic-setup/adding-cname-records