Skip to content

Commit b653468

Browse files
Merge branch 'master' into feat/add-keymanager-encrypt-decrypt
2 parents 3d82d94 + 3d8e94d commit b653468

File tree

14 files changed

+256
-16
lines changed

14 files changed

+256
-16
lines changed

docs/resources/container.md

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,60 @@ resource "scaleway_container" "main" {
4848
}
4949
```
5050

51+
### Managing authentication of private containers with IAM
52+
53+
```terraform
54+
# Project to be referenced in the IAM policy
55+
data "scaleway_account_project" "default" {
56+
name = "default"
57+
}
58+
59+
# IAM resources
60+
resource "scaleway_iam_application" "container_auth" {
61+
name = "container-auth"
62+
}
63+
resource "scaleway_iam_policy" "access_private_containers" {
64+
application_id = scaleway_iam_application.container_auth.id
65+
rule {
66+
project_ids = [data.scaleway_account_project.default.id]
67+
permission_set_names = ["ContainersPrivateAccess"]
68+
}
69+
}
70+
resource "scaleway_iam_api_key" "api_key" {
71+
application_id = scaleway_iam_application.container_auth.id
72+
}
73+
74+
# Container resources
75+
resource "scaleway_container_namespace" "private" {
76+
name = "private-container-namespace"
77+
}
78+
resource "scaleway_container" "private" {
79+
namespace_id = scaleway_container_namespace.private.id
80+
registry_image = "rg.fr-par.scw.cloud/my-registry-ns/my-image:latest"
81+
privacy = "private"
82+
deploy = true
83+
}
84+
85+
# Output the secret key and the container's endpoint for the curl command
86+
output "secret_key" {
87+
value = scaleway_iam_api_key.api_key.secret_key
88+
sensitive = true
89+
}
90+
output "container_endpoint" {
91+
value = scaleway_container.private.domain_name
92+
}
93+
94+
```
95+
96+
Then you can access your private container using the API key:
97+
98+
```shell
99+
$ curl -H "X-Auth-Token: $(terraform output -raw secret_key)" \
100+
"https://$(terraform output -raw container_endpoint)/"
101+
```
102+
103+
Keep in mind that you should revoke your legacy JWT tokens to ensure maximum security.
104+
51105
## Argument Reference
52106

53107
The following arguments are supported:

docs/resources/container_token.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ page_title: "Scaleway: scaleway_container_token"
55

66
# Resource: scaleway_container_token
77

8+
> **Important:** The resource `scaleway_container_token` has been deprecated and will no longer be supported in v1 of the API.
9+
Please use IAM authentication instead. You will find an implementation example in the [IAM authentication](container.md#managing-authentication-of-private-containers-with-iam) section of the Container documentation.
10+
811
The `scaleway_container_token` resource allows you to create and manage authentication tokens for Scaleway [Serverless Containers](https://www.scaleway.com/en/docs/serverless/containers/).
912

1013
Refer to the Containers tokens [documentation](https://www.scaleway.com/en/docs/serverless/containers/how-to/create-auth-token-from-console/) and [API documentation](https://www.scaleway.com/en/developers/api/serverless-containers/#path-tokens-list-all-tokens) for more information.

docs/resources/function.md

Lines changed: 58 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ resource "scaleway_function_namespace" "main" {
2323
2424
resource "scaleway_function" "main" {
2525
namespace_id = scaleway_function_namespace.main.id
26-
runtime = "go118"
26+
runtime = "go124"
2727
handler = "Handle"
2828
privacy = "private"
2929
}
@@ -43,7 +43,7 @@ resource "scaleway_function" "main" {
4343
namespace_id = scaleway_function_namespace.main.id
4444
description = "function with zip file"
4545
tags = ["tag1", "tag2"]
46-
runtime = "go118"
46+
runtime = "go124"
4747
handler = "Handle"
4848
privacy = "private"
4949
timeout = 10
@@ -53,6 +53,62 @@ resource "scaleway_function" "main" {
5353
}
5454
```
5555

56+
### Managing authentication of private functions with IAM
57+
58+
```terraform
59+
# Project to be referenced in the IAM policy
60+
data "scaleway_account_project" "default" {
61+
name = "default"
62+
}
63+
64+
# IAM resources
65+
resource "scaleway_iam_application" "func_auth" {
66+
name = "function-auth"
67+
}
68+
resource "scaleway_iam_policy" "access_private_funcs" {
69+
application_id = scaleway_iam_application.func_auth.id
70+
rule {
71+
project_ids = [data.scaleway_account_project.default.id]
72+
permission_set_names = ["FunctionsPrivateAccess"]
73+
}
74+
}
75+
resource "scaleway_iam_api_key" "api_key" {
76+
application_id = scaleway_iam_application.func_auth.id
77+
}
78+
79+
# Function resources
80+
resource "scaleway_function_namespace" "private" {
81+
name = "private-function-namespace"
82+
}
83+
resource "scaleway_function" "private" {
84+
namespace_id = scaleway_function_namespace.private.id
85+
runtime = "go124"
86+
handler = "Handle"
87+
privacy = "private"
88+
zip_file = "function.zip"
89+
zip_hash = filesha256("function.zip")
90+
deploy = true
91+
}
92+
93+
# Output the secret key and the function's endpoint for the curl command
94+
output "secret_key" {
95+
value = scaleway_iam_api_key.api_key.secret_key
96+
sensitive = true
97+
}
98+
output "function_endpoint" {
99+
value = scaleway_function.private.domain_name
100+
}
101+
```
102+
103+
Then you can access your private function using the API key:
104+
105+
```shell
106+
$ curl -H "X-Auth-Token: $(terraform output -raw secret_key)" \
107+
"https://$(terraform output -raw function_endpoint)/"
108+
```
109+
110+
Keep in mind that you should revoke your legacy JWT tokens to ensure maximum security.
111+
56112
## Argument Reference
57113

58114
The following arguments are supported:

docs/resources/function_token.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ page_title: "Scaleway: scaleway_function_token"
55

66
# Resource: scaleway_function_token
77

8+
~> **Important:** The resource `scaleway_function_token` has been deprecated and will no longer be supported in v1 of the API.
9+
Please use IAM authentication instead. You will find an implementation example in the [IAM authentication](function.md#managing-authentication-of-private-functions-with-iam) section of the Function documentation.
10+
811
The `scaleway_function_token` resource allows you to create and manage authentication tokens for Scaleway [Serverless Functions](https://www.scaleway.com/en/docs/serverless/functions/).
912

1013
Refer to the Functions tokens [documentation](https://www.scaleway.com/en/docs/serverless/functions/how-to/create-auth-token-from-console/) and [API documentation](https://www.scaleway.com/en/developers/api/serverless-functions/#path-tokens-list-all-tokens) for more information.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
The [`scaleway_apple_silicon_server`](https://registry.terraform.io/providers/scaleway/scaleway/latest/docs/resources/apple_silicon_server) resource creates and manages Scaleway Apple silicon servers.
2+
3+
For more information, see the [API documentation](https://www.scaleway.com/en/developers/api/apple-silicon/).

internal/services/applesilicon/server.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package applesilicon
22

33
import (
44
"context"
5+
_ "embed"
56
"fmt"
67
"time"
78

@@ -21,8 +22,12 @@ import (
2122
"github.com/scaleway/terraform-provider-scaleway/v2/internal/verify"
2223
)
2324

25+
//go:embed descriptions/server.md
26+
var serverDescription string
27+
2428
func ResourceServer() *schema.Resource {
2529
return &schema.Resource{
30+
Description: serverDescription,
2631
CreateContext: ResourceAppleSiliconServerCreate,
2732
ReadContext: ResourceAppleSiliconServerRead,
2833
UpdateContext: ResourceAppleSiliconServerUpdate,

internal/services/container/token.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,10 @@ import (
1818

1919
func ResourceToken() *schema.Resource {
2020
return &schema.Resource{
21-
CreateContext: ResourceContainerTokenCreate,
22-
ReadContext: ResourceContainerTokenRead,
23-
DeleteContext: ResourceContainerTokenDelete,
21+
CreateContext: ResourceContainerTokenCreate,
22+
ReadContext: ResourceContainerTokenRead,
23+
DeleteContext: ResourceContainerTokenDelete,
24+
DeprecationMessage: "The \"scaleway_container_token\" resource is deprecated in favor of IAM authentication",
2425
Importer: &schema.ResourceImporter{
2526
StateContext: schema.ImportStatePassthroughContext,
2627
},

internal/services/function/token.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,10 @@ import (
2020

2121
func ResourceToken() *schema.Resource {
2222
return &schema.Resource{
23-
CreateContext: ResourceFunctionTokenCreate,
24-
ReadContext: ResourceFunctionTokenRead,
25-
DeleteContext: ResourceFunctionTokenDelete,
23+
CreateContext: ResourceFunctionTokenCreate,
24+
ReadContext: ResourceFunctionTokenRead,
25+
DeleteContext: ResourceFunctionTokenDelete,
26+
DeprecationMessage: "The \"scaleway_function_token\" resource is deprecated in favor of IAM authentication",
2627
Importer: &schema.ResourceImporter{
2728
StateContext: schema.ImportStatePassthroughContext,
2829
},

internal/services/jobs/jobs.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -147,10 +147,9 @@ func definitionSchema() map[string]*schema.Schema {
147147
ValidateFunc: validation.StringMatch(regexp.MustCompile(`^(/[^/]+)+$`), "must be an absolute path to the file"),
148148
},
149149
"environment": {
150-
Type: schema.TypeString,
151-
Optional: true,
152-
Description: "An environment variable containing the secret value.",
153-
ValidateFunc: validation.StringMatch(regexp.MustCompile(`^[A-Z|0-9]+(_[A-Z|0-9]+)*$`), "environment variable must be composed of uppercase letters separated by an underscore"),
150+
Type: schema.TypeString,
151+
Optional: true,
152+
Description: "An environment variable containing the secret value.",
154153
},
155154
},
156155
},

templates/resources/apple_silicon_server.md.tmpl

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@ page_title: "Scaleway: scaleway_apple_silicon"
66

77
# Resource: scaleway_apple_silicon_server
88

9-
Creates and manages Scaleway Apple silicon. For more information,
10-
see the [API documentation](https://www.scaleway.com/en/developers/api/apple-silicon/).
9+
{{ .Description }}
1110

1211
## Example Usage
1312

0 commit comments

Comments
 (0)