Skip to content

Commit 4e9a3d5

Browse files
authored
feat(jobs): support secret manager references in serverless jobs defi… (#3030)
* feat(jobs): support secret manager references in serverless jobs definitions * fix(jobs): support secret regional and uuid, fix diff detection and update * chore(jobs): update documentation with secret_reference
1 parent 6435ee8 commit 4e9a3d5

18 files changed

+10149
-512
lines changed

cmd/tftemplate/main.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,8 @@ import (
66
"log"
77
"text/template"
88

9-
"tftemplate/models"
10-
119
"github.com/AlecAivazis/survey/v2"
10+
"tftemplate/models"
1211
)
1312

1413
var (

docs/resources/job_definition.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,35 @@ resource scaleway_job_definition main {
3131
}
3232
```
3333

34+
### With Secret Reference
35+
36+
```terraform
37+
resource scaleway_job_definition main {
38+
name = "testjob"
39+
cpu_limit = 140
40+
memory_limit = 256
41+
image_uri = "docker.io/alpine:latest"
42+
command = "ls"
43+
timeout = "10m"
44+
45+
cron {
46+
schedule = "5 4 1 * *" # cron at 04:05 on day-of-month 1
47+
timezone = "Europe/Paris"
48+
}
49+
50+
secret_reference {
51+
secret_id = "11111111-1111-1111-1111-111111111111"
52+
file = "/home/dev/secret_file"
53+
}
54+
55+
secret_reference {
56+
secret_id = scaleway_secret.job_secret.id
57+
secret_version = "1"
58+
environment = "FOO"
59+
}
60+
}
61+
```
62+
3463
## Argument Reference
3564

3665
The following arguments are supported:
@@ -48,6 +77,13 @@ The following arguments are supported:
4877
- `timezone` - The timezone, must be a canonical TZ identifier as found in this [list](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones).
4978
- `region` - (Defaults to [provider](../index.md#region) `region`) The [region](../guides/regions_and_zones.md#regions) of the Job.
5079
- `project_id` - (Defaults to [provider](../index.md#project_id) `project_id`) The ID of the project the Job is associated with.
80+
- `secret_reference` - (Optional) A reference to a secret stored in [Secret Manager](../resources/secret.md).
81+
- `secret_id` - (Required) The secret unique identifier, it could be formatted as region/UUID or UUID. In case the region is passed, it must be the same as the job definition. You could reference the same secret multiple times in the same job definition.
82+
- `secret_version` - (Default: `latest`) The secret version.
83+
- `file` - (Optional) The absolute file path where the secret will be mounted. Must be specified if `environment` is not specified.
84+
- `environment` - (Optional) An environment variable containing the secret value. Must be specified if `file` is not specified.
85+
- `secret_reference_id` - The secret reference UUID that is automatically generated by the provider.
86+
5187

5288
## Attributes Reference
5389

internal/services/jobs/definition_test.go

Lines changed: 0 additions & 215 deletions
This file was deleted.

0 commit comments

Comments
 (0)