-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.tf
92 lines (84 loc) · 2.17 KB
/
main.tf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
terraform {
required_version = ">= 1.0.0"
required_providers {
transloadit = {
source = "transloadit/transloadit"
version = "0.4.0"
}
}
}
// Define our `urltransform` App and its credentials
variable "tl_urltransform_key" { type = string }
variable "tl_urltransform_secret" { type = string }
provider "transloadit" {
auth_key = var.tl_urltransform_key
auth_secret = var.tl_urltransform_secret
alias = "urltransform"
}
// Define our `preprocess` App and its credentials
variable "tl_preprocess_key" { type = string }
variable "tl_preprocess_secret" { type = string }
provider "transloadit" {
auth_key = var.tl_preprocess_key
auth_secret = var.tl_preprocess_secret
alias = "preprocess"
}
resource "transloadit_template" "resize-img" {
provider = transloadit.urltransform // <-- In which App to save the template
name = "resize-img"
template = <<EOT
{
"steps": {
"imported": {
"robot": "/s3/import",
"credentials": "my_s3_$${assembly.region}",
"path": "/onthefly/$${fields.input}"
},
"resized": {
"use": "imported",
"robot": "/image/resize",
"width": "$${fields.w}",
"imagemagick_stack": "v2.0.7"
},
"served": {
"use": "resized",
"robot": "/file/serve"
}
}
}
EOT
}
resource "transloadit_template" "video-encode" {
provider = transloadit.preprocess // <-- In which App to save the template
name = "video-encode"
template = <<EOT
{
"steps": {
":original": {
"robot": "/upload/handle"
},
"encoded": {
"use": ":original",
"robot": "/video/encode",
"preset": "ipad-high"
}
}
}
EOT
}
// Optionally, you can share Templates between apps by adding them
// to the ./shared-templates/shared.tf Module, invoking the Module
// for each App you want to include below, and running: `terraform init`
module "shared-in-urltransform" {
source = "./shared-templates"
providers = {
transloadit = transloadit.urltransform
}
}
module "shared-in-preprocess" {
source = "./shared-templates"
providers = {
transloadit = transloadit.preprocess
}
}
output "cdn-resize-id" { value = transloadit_template.resize-img.id }