Skip to content

Commit 85f04ea

Browse files
committed
Update authentication and service connector configurations
1 parent d84a9ae commit 85f04ea

File tree

4 files changed

+101
-35
lines changed

4 files changed

+101
-35
lines changed

docs/guides/authentication.md

+32-12
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,16 @@ description: |-
77

88
# Authentication
99

10-
The ZenML provider requires authentication to interact with your ZenML server. This guide explains how to set up authentication for the provider.
10+
The ZenML provider requires authentication to interact with your ZenML server. The provider uses API key authentication to obtain access tokens.
1111

1212
## Configuration
1313

14-
The provider can be configured with the following environment variables:
14+
The provider can be configured using environment variables:
1515

16-
- `ZENML_SERVER_URL`: The URL of your ZenML server
17-
- `ZENML_API_KEY`: Your ZenML API key
16+
* `ZENML_SERVER_URL` - (Required) The URL of your ZenML server
17+
* `ZENML_API_KEY` - (Required) Your ZenML API key
1818

19-
Alternatively, you can provide these credentials in the provider configuration:
19+
Alternatively, you can provide these credentials directly in the provider configuration:
2020

2121
```hcl
2222
provider "zenml" {
@@ -27,18 +27,38 @@ provider "zenml" {
2727

2828
!> **Warning:** Hard-coding credentials into your Terraform configuration is not recommended. Use environment variables or other secure methods to provide credentials.
2929

30+
## Authentication Process
31+
32+
The provider automatically handles the authentication process by:
33+
1. Making a login request to `/api/v1/login` with your API key
34+
2. Obtaining an access token
35+
3. Using this token for subsequent API requests
36+
37+
The access token is automatically refreshed for each request to ensure continuous operation.
38+
3039
## Obtaining Credentials
3140

32-
1. **Server URL**: This is the URL where your ZenML server is hosted.
41+
1. **Server URL**: This is the URL where your ZenML server is hosted. For example: `https://your-zenml-server.com`
3342

3443
2. **API Key**: You can generate an API key from the ZenML UI or CLI:
35-
- UI: Navigate to your user settings and create a new API key
36-
- CLI: Use the command `zenml api-key create --name="terraform" --description="For Terraform"`
44+
```bash
45+
zenml api-key create --name="terraform" --description="For Terraform provider"
46+
```
3747

3848
## Best Practices
3949

40-
- Use environment variables or a secure secret management system to handle credentials.
41-
- Rotate your API keys regularly.
42-
- Use separate API keys for different environments (development, staging, production).
50+
* Store credentials using environment variables:
51+
```bash
52+
export ZENML_SERVER_URL="https://your-zenml-server.com"
53+
export ZENML_API_KEY="your-api-key"
54+
```
55+
* Use different API keys for different environments
56+
* Rotate API keys regularly
57+
* Never commit API keys to version control
58+
59+
## Troubleshooting
4360

44-
For more information on ZenML authentication, refer to the [ZenML documentation](https://docs.zenml.io/user-guide/advanced-guide/environment-management/connect-to-zenml).
61+
If you encounter authentication errors:
62+
1. Verify your server URL is correct and accessible
63+
2. Ensure your API key is valid and not expired
64+
3. Check that your server URL doesn't have a trailing slash

docs/resources/service_connector.md

+22-8
Original file line numberDiff line numberDiff line change
@@ -29,22 +29,36 @@ resource "zenml_service_connector" "gcp_connector" {
2929
service_account_json = jsonencode({
3030
"type": "service_account",
3131
"project_id": "my-gcp-project",
32-
# ... other service account details
32+
"private_key_id": "key-id",
33+
"private_key": "-----BEGIN PRIVATE KEY-----\n...\n-----END PRIVATE KEY-----\n",
34+
"client_email": "service-account@project.iam.gserviceaccount.com",
35+
"client_id": "client-id",
36+
"auth_uri": "https://accounts.google.com/o/oauth2/auth",
37+
"token_uri": "https://oauth2.googleapis.com/token"
3338
})
3439
}
40+
41+
labels = {
42+
environment = "production"
43+
team = "ml-ops"
44+
}
3545
}
3646
```
3747

3848
## Argument Reference
3949

4050
* `name` - (Required) The name of the service connector.
41-
* `type` - (Required) The type of the service connector (e.g., "gcp", "aws", "azure").
42-
* `auth_method` - (Required) The authentication method used by the service connector.
43-
* `user` - (Required) The ID of the user who owns this connector.
44-
* `workspace` - (Required) The ID of the workspace this connector belongs to.
45-
* `resource_types` - (Optional) A list of resource types this connector can be used for.
46-
* `configuration` - (Required) A map of configuration key-value pairs for the connector.
47-
* `secrets` - (Optional) A map of secret key-value pairs for the connector. These are sensitive and will not be output.
51+
* `type` - (Required, Forces new resource) The type of the service connector. Valid values include: `aws`, `gcp`, `azure`, and others depending on your ZenML version.
52+
* `auth_method` - (Required, Forces new resource) The authentication method used by the connector. Valid values include:
53+
* AWS: `iam-role`, `aws-access-keys`, `web-identity`
54+
* GCP: `service-account`, `oauth2`, `workload-identity`
55+
* Azure: `service-principal`, `managed-identity`
56+
* Kubernetes: `kubeconfig`, `service-account`
57+
* `user` - (Required, Forces new resource) The ID of the user who owns this connector.
58+
* `workspace` - (Required, Forces new resource) The ID of the workspace this connector belongs to.
59+
* `resource_types` - (Optional) A list of resource types this connector can be used for (e.g., `artifact-store`, `container-registry`, `orchestrator`).
60+
* `configuration` - (Required, Sensitive) A map of configuration key-value pairs for the connector.
61+
* `secrets` - (Optional, Sensitive) A map of secret key-value pairs for the connector.
4862
* `labels` - (Optional) A map of labels to associate with the connector.
4963

5064
## Attributes Reference

docs/resources/stack.md

+34-5
Original file line numberDiff line numberDiff line change
@@ -12,36 +12,65 @@ Manages a ZenML stack, which is a collection of components that define the infra
1212
## Example Usage
1313

1414
```hcl
15+
# First, create the required stack components
1516
resource "zenml_stack_component" "artifact_store" {
1617
name = "my-artifact-store"
1718
type = "artifact_store"
1819
flavor = "gcp"
19-
user = "user-uuid"
20-
workspace = "workspace-uuid"
20+
workspace = "default"
2121
2222
configuration = {
2323
path = "gs://my-bucket/artifacts"
2424
}
2525
}
2626
27+
resource "zenml_stack_component" "orchestrator" {
28+
name = "my-orchestrator"
29+
type = "orchestrator"
30+
flavor = "kubernetes"
31+
workspace = "default"
32+
33+
configuration = {
34+
kubernetes_context = "my-k8s-cluster"
35+
}
36+
}
37+
38+
# Then create the stack using the component IDs
2739
resource "zenml_stack" "my_stack" {
28-
name = "my-stack"
40+
name = "my-production-stack"
41+
42+
# Map component types to their IDs
2943
components = {
3044
artifact_store = zenml_stack_component.artifact_store.id
45+
orchestrator = zenml_stack_component.orchestrator.id
3146
}
3247
3348
labels = {
3449
environment = "production"
50+
team = "ml-ops"
3551
}
3652
}
3753
```
3854

3955
## Argument Reference
4056

4157
* `name` - (Required) The name of the stack.
42-
* `components` - (Required) A map of component types to component IDs that make up this stack.
58+
* `components` - (Required) A map where keys are component types and values are component IDs. Each component type can only have one component. Valid component types include:
59+
* `artifact_store`
60+
* `container_registry`
61+
* `orchestrator`
62+
* `step_operator`
63+
* `model_deployer`
64+
* `experiment_tracker`
65+
* `alerter`
66+
* `annotator`
67+
* `data_validator`
68+
* `feature_store`
69+
* `image_builder`
4370
* `labels` - (Optional) A map of labels to associate with the stack.
4471

72+
-> **Note** The stack will be created in the default workspace. Future versions may allow workspace configuration.
73+
4574
## Attributes Reference
4675

4776
In addition to all arguments above, the following attributes are exported:
@@ -52,6 +81,6 @@ In addition to all arguments above, the following attributes are exported:
5281

5382
Stacks can be imported using the `id`, e.g.
5483

55-
```
84+
```shell
5685
$ terraform import zenml_stack.example 12345678-1234-1234-1234-123456789012
5786
```

docs/resources/stack_component.md

+13-10
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,16 @@ resource "zenml_stack_component" "artifact_store" {
1616
name = "my-artifact-store"
1717
type = "artifact_store"
1818
flavor = "gcp"
19-
user = "user-uuid"
20-
workspace = "workspace-uuid"
19+
workspace = "default"
2120
2221
configuration = {
2322
path = "gs://my-bucket/artifacts"
2423
}
2524
25+
# Optional: Connect to a service connector
26+
connector_id = "connector-uuid"
27+
connector_resource_id = "resource-id"
28+
2629
labels = {
2730
environment = "production"
2831
}
@@ -32,15 +35,15 @@ resource "zenml_stack_component" "artifact_store" {
3235
## Argument Reference
3336

3437
* `name` - (Required) The name of the stack component.
35-
* `type` - (Required) The type of the stack component (e.g., "artifact_store", "orchestrator").
38+
* `type` - (Required) The type of the stack component (e.g., "artifact_store", "orchestrator"). Must be one of the valid component types supported by ZenML.
3639
* `flavor` - (Required) The flavor of the stack component (e.g., "local", "gcp", "aws").
37-
* `user` - (Required) The ID of the user who owns this component.
38-
* `workspace` - (Required) The ID of the workspace this component belongs to.
39-
* `configuration` - (Required) A map of configuration key-value pairs for the component.
40-
* `connector_resource_id` - (Optional) The ID of the connector resource to use with this component.
40+
* `workspace` - (Required, Forces new resource) The name of the workspace this component belongs to.
41+
* `configuration` - (Optional, Sensitive) A map of configuration key-value pairs for the component.
42+
* `connector_id` - (Optional) The ID of the service connector to use with this component. Must be specified together with `connector_resource_id`.
43+
* `connector_resource_id` - (Optional) The ID of the connector resource to use with this component. Must be specified together with `connector_id`.
4144
* `labels` - (Optional) A map of labels to associate with the component.
42-
* `component_spec_path` - (Optional) The path to the component specification file.
43-
* `connector` - (Optional) The ID of the service connector to use with this component.
45+
46+
-> **Note** When using service connectors, both `connector_id` and `connector_resource_id` must be specified together. Specifying only one will result in an error.
4447

4548
## Attributes Reference
4649

@@ -52,6 +55,6 @@ In addition to all arguments above, the following attributes are exported:
5255

5356
Stack components can be imported using the `id`, e.g.
5457

55-
```
58+
```shell
5659
$ terraform import zenml_stack_component.example 12345678-1234-1234-1234-123456789012
5760
```

0 commit comments

Comments
 (0)