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