Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion docs/resources/container.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ resource "scaleway_container_namespace" "main" {
resource "scaleway_container" "main" {
name = "my-container-02"
description = "environment variables test"
tags = ["tag1", "tag2"]
namespace_id = scaleway_container_namespace.main.id
registry_image = "${scaleway_container_namespace.main.registry_endpoint}/alpine:test"
port = 9997
Expand Down Expand Up @@ -56,6 +57,8 @@ The following arguments are supported:

- `description` (Optional) The description of the container.

- `tags` - (Optional) The list of tags associated with the container.

- `environment_variables` - (Optional) The [environment variables](https://www.scaleway.com/en/docs/serverless-containers/concepts/#environment-variables) of the container.

- `secret_environment_variables` - (Optional) The [secret environment variables](https://www.scaleway.com/en/docs/serverless-containers/concepts/#secrets) of the container.
Expand Down Expand Up @@ -99,7 +102,7 @@ The following arguments are supported:

- `deploy` - (Optional) Boolean indicating whether the container is in a production environment.

- `local_storage_limit` - Local storage limit of the container (in MB)
- `local_storage_limit` - (Optional) Local storage limit of the container (in MB)

Note that if you want to use your own configuration, you must consult our configuration [restrictions](https://www.scaleway.com/en/docs/serverless-containers/reference-content/containers-limitations/#configuration-restrictions) section.

Expand Down
9 changes: 6 additions & 3 deletions docs/resources/container_namespace.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ Refer to the Containers namespace [documentation](https://www.scaleway.com/en/do
resource "scaleway_container_namespace" "main" {
name = "main-container-namespace"
description = "Main container namespace"
tags = ["tag1", "tag2"]
}
```

Expand All @@ -27,15 +28,17 @@ The following arguments are supported:

~> **Important** Updates to the `name` argument will recreate the namespace.

- `description` (Optional) The description of the namespace.
- `description` - (Optional) The description of the namespace.

- `tags` - (Optional) The list of tags associated with the namespace.

- `region` - (Defaults to [provider](../index.md#region) `region`). The [region](../guides/regions_and_zones.md#regions) in which the namespace is created.

- `project_id` - (Defaults to [provider](../index.md#project_id) `project_id`) The unique identifier of the project that contains the namespace.

- `environment_variables` - The environment variables of the namespace.
- `environment_variables` - (Optional) The environment variables of the namespace.

- `secret_environment_variables` - The secret environment variables of the namespace.
- `secret_environment_variables` - (Optional) The secret environment variables of the namespace.

## Attributes Reference

Expand Down
14 changes: 9 additions & 5 deletions docs/resources/function.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ resource "scaleway_function_namespace" "main" {

resource "scaleway_function" "main" {
namespace_id = scaleway_function_namespace.main.id
description = "function with zip file"
tags = ["tag1", "tag2"]
runtime = "go118"
handler = "Handle"
privacy = "private"
Expand All @@ -63,29 +65,31 @@ The following arguments are supported:

- `description` (Optional) The description of the function.

- `tags` - (Optional) The list of tags associated with the function.

- `environment_variables` - (Optional) The [environment variables](https://www.scaleway.com/en/docs/compute/functions/concepts/#environment-variables) of the function.

- `secret_environment_variables` - (Optional) The [secret environment variables](https://www.scaleway.com/en/docs/compute/functions/concepts/#secrets) of the function.

- `privacy` - (Optional) The privacy type defines the way to authenticate to your function. Please check our dedicated [section](https://www.scaleway.com/en/developers/api/serverless-functions/#protocol-9dd4c8).

- `runtime` - Runtime of the function. Runtimes can be fetched using [specific route](https://www.scaleway.com/en/developers/api/serverless-functions/#path-functions-get-a-function)
- `runtime` - (Required) Runtime of the function. Runtimes can be fetched using [specific route](https://www.scaleway.com/en/developers/api/serverless-functions/#path-functions-get-a-function)

- `min_scale` - (Optional) The minimum number of function instances running continuously. Defaults to 0. Functions are billed when executed, and using a `min_scale` greater than 0 will cause your function to run constantly.

- `max_scale` - (Optional) The maximum number of instances this function can scale to. Default to 20. Your function will scale automatically based on the incoming workload, but will never exceed the configured `max_scale` value.

- `memory_limit` - (Optional) The memory resources in MB to allocate to each function. Defaults to 256 MB.

- `handler` - Handler of the function, depends on the runtime. Refer to the [dedicated documentation](https://www.scaleway.com/en/developers/api/serverless-functions/#path-functions-create-a-new-function) for the list of supported runtimes.
- `handler` - (Required) Handler of the function, depends on the runtime. Refer to the [dedicated documentation](https://www.scaleway.com/en/developers/api/serverless-functions/#path-functions-create-a-new-function) for the list of supported runtimes.

- `timeout` - (Optional) The maximum amount of time your function can spend processing a request before being stopped. Defaults to 300s.

- `zip_file` - Path to the zip file containing your function sources to upload.
- `zip_file` - (Optional) Path to the zip file containing your function sources to upload.

- `zip_hash` - The hash of your source zip file, changing it will redeploy the function. Can be any string, changing it will simply trigger a state change. You can use any Terraform hash function to trigger a change on your zip change (see examples).
- `zip_hash` - (Optional) The hash of your source zip file, changing it will redeploy the function. Can be any string, changing it will simply trigger a state change. You can use any Terraform hash function to trigger a change on your zip change (see examples).

- `deploy` - Define whether the function should be deployed. Terraform will wait for the function to be deployed. Your function will be redeployed if you update the source zip file.
- `deploy` - (Optional, defaults to `false`) Define whether the function should be deployed. Terraform will wait for the function to be deployed. Your function will be redeployed if you update the source zip file.

- `http_option` - (Optional) Allows both HTTP and HTTPS (`enabled`) or redirect HTTP to HTTPS (`redirected`). Defaults to `enabled`.

Expand Down
7 changes: 5 additions & 2 deletions docs/resources/function_namespace.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ Refer to the Functions namespace [documentation](https://www.scaleway.com/en/doc
resource "scaleway_function_namespace" "main" {
name = "main-function-namespace"
description = "Main function namespace"
tags = ["tag1", "tag2"]
}
```

Expand All @@ -29,13 +30,15 @@ The following arguments are supported:

- `description` (Optional) The description of the namespace.

- `tags` - (Optional) The list of tags associated with the namespace.

- `region` - (Defaults to [provider](../index.md#region) `region`). The [region](../guides/regions_and_zones.md#regions) in which the namespace is created.

- `project_id` - (Defaults to [provider](../index.md#project_id) `project_id`) The unique identifier of the project that contains the namespace.

- `environment_variables` - The environment variables of the namespace.
- `environment_variables` - (Optional) The environment variables of the namespace.

- `secret_environment_variables` - The secret environment variables of the namespace.
- `secret_environment_variables` - (Optional) The secret environment variables of the namespace.

## Attributes Reference

Expand Down
13 changes: 13 additions & 0 deletions internal/services/container/container.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,14 @@ func ResourceContainer() *schema.Resource {
Required: true,
Description: "The container namespace associated",
},
"tags": {
Type: schema.TypeList,
Elem: &schema.Schema{
Type: schema.TypeString,
},
Optional: true,
Description: "List of tags [\"tag1\", \"tag2\", ...] attached to the container.",
},
"environment_variables": {
Type: schema.TypeMap,
Optional: true,
Expand Down Expand Up @@ -361,6 +369,7 @@ func ResourceContainerRead(ctx context.Context, d *schema.ResourceData, m interf
_ = d.Set("region", co.Region.String())
_ = d.Set("local_storage_limit", int(co.LocalStorageLimit))
_ = d.Set("secret_environment_variables", flattenContainerSecrets(co.SecretEnvironmentVariables))
_ = d.Set("tags", types.FlattenSliceString(co.Tags))

return nil
}
Expand Down Expand Up @@ -400,6 +409,10 @@ func ResourceContainerUpdate(ctx context.Context, d *schema.ResourceData, m inte
req.SecretEnvironmentVariables = filterSecretEnvsToPatch(expandContainerSecrets(oldEnv), expandContainerSecrets(newEnv))
}

if d.HasChange("tags") {
req.Tags = types.ExpandUpdatedStringsPtr(d.Get("tags"))
}

if d.HasChanges("min_scale") {
req.MinScale = scw.Uint32Ptr(uint32(d.Get("min_scale").(int)))
}
Expand Down
8 changes: 8 additions & 0 deletions internal/services/container/container_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ func TestAccContainer_Basic(t *testing.T) {

resource scaleway_container main {
namespace_id = scaleway_container_namespace.main.id
tags = ["tag1", "tag2"]
}
`,
Check: resource.ComposeTestCheckFunc(
Expand All @@ -49,6 +50,9 @@ func TestAccContainer_Basic(t *testing.T) {
resource.TestCheckResourceAttrSet("scaleway_container.main", "min_scale"),
resource.TestCheckResourceAttrSet("scaleway_container.main", "privacy"),
resource.TestCheckResourceAttrSet("scaleway_container.main", "local_storage_limit"),
resource.TestCheckResourceAttr("scaleway_container.main", "tags.#", "2"),
resource.TestCheckResourceAttr("scaleway_container.main", "tags.0", "tag1"),
resource.TestCheckResourceAttr("scaleway_container.main", "tags.1", "tag2"),
),
},
{
Expand All @@ -67,6 +71,7 @@ func TestAccContainer_Basic(t *testing.T) {
timeout = 300
deploy = false
local_storage_limit = 1000
tags = ["tag"]
}
`,
Check: resource.ComposeTestCheckFunc(
Expand All @@ -84,6 +89,8 @@ func TestAccContainer_Basic(t *testing.T) {
resource.TestCheckResourceAttr("scaleway_container.main", "privacy", containerSDK.ContainerPrivacyPublic.String()),
resource.TestCheckResourceAttr("scaleway_container.main", "protocol", containerSDK.ContainerProtocolHTTP1.String()),
resource.TestCheckResourceAttr("scaleway_container.main", "local_storage_limit", "1000"),
resource.TestCheckResourceAttr("scaleway_container.main", "tags.#", "1"),
resource.TestCheckResourceAttr("scaleway_container.main", "tags.0", "tag"),
),
},
{
Expand Down Expand Up @@ -118,6 +125,7 @@ func TestAccContainer_Basic(t *testing.T) {
resource.TestCheckResourceAttr("scaleway_container.main", "deploy", "false"),
resource.TestCheckResourceAttr("scaleway_container.main", "protocol", containerSDK.ContainerProtocolHTTP1.String()),
resource.TestCheckResourceAttr("scaleway_container.main", "local_storage_limit", "1500"),
resource.TestCheckResourceAttr("scaleway_container.main", "tags.#", "0"),
),
},
},
Expand Down
4 changes: 4 additions & 0 deletions internal/services/container/helpers_container.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,10 @@ func setCreateContainerRequest(d *schema.ResourceData, region scw.Region) (*cont
req.LocalStorageLimit = scw.Uint32Ptr(uint32(localStorageLimit.(int)))
}

if tags, ok := d.GetOk("tags"); ok {
req.Tags = types.ExpandStrings(tags)
}

return req, nil
}

Expand Down
Loading
Loading