| 1 | output "bucket_name" { |
| 2 | value = aws_s3_bucket.logs.bucket |
| 3 | } |
| 4 | |
| 5 | output "s3_domain" { |
| 6 | # I don't kno whow to get this from the S3 bucket resource :/. |
| 7 | value = "s3.eu-west-1.amazonaws.com" |
| 8 | } |
| 9 | |
| 10 | output "iam_role_arn" { |
| 11 | value = aws_iam_role.fastly_log_forwarder.arn |
| 12 | } |
| 13 | |
| 14 | |
| 15 | |
| 16 | output "period" { |
| 17 | # Frequency that Fastly servers will push a file to S3, in seconds |
| 18 | value = 3600 |
| 19 | } |
| 20 | |
| 21 | output "format" { |
| 22 | value = "{${join(",", [for k, v in { |
| 23 | asn = "%%{client.as.number}V", |
| 24 | elapsed_usec = "%%{json.escape(time.elapsed.usec)}V", |
| 25 | fastly_is_edge = "%%{if(fastly.ff.visits_this_service == 0, \"true\", \"false\")}V", |
| 26 | fastly_server = "\"%%{json.escape(server.identity)}V\"", |
| 27 | geo_country = "\"%%{json.escape(client.geo.country_name)}V\"", |
| 28 | geo_region = "\"%%{json.escape(client.geo.region.utf8)}V\"", |
| 29 | geo_speed = "\"%%{json.escape(client.geo.conn_speed)}V\"", |
| 30 | host = "\"%%{json.escape(if(req.http.Fastly-Orig-Host, req.http.Fastly-Orig-Host, req.http.Host))}V\"", |
| 31 | request_method = "\"%%{json.escape(req.method)}V\"", |
| 32 | request_protocol = "\"%%{json.escape(req.proto)}V\"", |
| 33 | request_referer = "\"%%{json.escape(req.http.referer)}V\"", |
| 34 | request_size = "%%{json.escape(req.bytes_read)}V", |
| 35 | request_user_agent = "\"%%{json.escape(req.http.User-Agent)}V\"", |
| 36 | response_body_size = "%%{resp.body_bytes_written}V", |
| 37 | response_reason = "%%{if(resp.response, \"%22\"+json.escape(resp.response)+\"%22\", \"null\")}V", |
| 38 | response_state = "\"%%{json.escape(fastly_info.state)}V\"", |
| 39 | response_status = "\"%%{resp.status}V\"", |
| 40 | timestamp = "\"%%{strftime(\\{\"%Y-%m-%dT%H:%M:%S%z\"\\}, time.start)}V\"", |
| 41 | tls_client_cipher = "\"%%{json.escape(if(tls.client.cipher, tls.client.cipher, \"null\"))}V\"", |
| 42 | tls_client_protocol = "\"%%{json.escape(if(tls.client.protocol, tls.client.protocol, \"null\"))}V\"", |
| 43 | url = "\"%%{json.escape(req.url)}V\"", |
| 44 | } : "\"${k}\": ${v}"])}}" |
| 45 | } |