You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat: add cors_behavior support to template resource (#294)
## Summary
Adds support for the `cors_behavior` field in the `coderd_template`
resource to allow configuring CORS settings for workspace apps via
Terraform.
## Changes
### Template Resource
- Added `cors_behavior` field to `TemplateResourceModel` struct
- Added schema attribute with validation (`simple` or `passthru`)
- Handle `cors_behavior` in Create, Read, and Update operations
- Added `cors_behavior` to `toUpdateRequest` for API calls
- Added `cors_behavior` to `EqualTemplateMetadata` comparison
### Template Data Source
- Added `cors_behavior` field to data source struct and schema
- Added reading `cors_behavior` in the Read function
## Usage
```hcl
resource "coderd_template" "example" {
name = "example"
cors_behavior = "passthru" # or "simple" (default)
versions {
# ...
}
}
```
## Background
The Coder backend supports a `cors_behavior` field on templates with two
possible values:
- `simple` - uses the default CORS middleware
- `passthru` - bypasses CORS middleware for workspace apps
This setting is available in the Template Settings page in the Coder UI
but was not previously configurable via the Terraform provider.
Fixes#293
---
Created on behalf of @matifali
---------
Co-authored-by: blink-so[bot] <211532188+blink-so[bot]@users.noreply.github.com>
Co-authored-by: ethan <ethan@coder.com>
-`allow_user_cancel_workspace_jobs` (Boolean) Whether users can cancel jobs in workspaces created from the template.
57
57
-`auto_start_permitted_days_of_week` (Set of String) List of days of the week in which autostart is allowed to happen, for all workspaces created from this template. Defaults to all days. If no days are specified, autostart is not allowed.
58
58
-`auto_stop_requirement` (Attributes) The auto-stop requirement for all workspaces created from this template. (see [below for nested schema](#nestedatt--auto_stop_requirement))
59
+
-`cors_behavior` (String) The CORS behavior for workspace apps in this template. Requires a Coder deployment running v2.26.0 or later.
59
60
-`created_at` (Number) Unix timestamp of when the template was created.
60
61
-`created_by_user_id` (String) ID of the user who created the template.
61
62
-`default_ttl_ms` (Number) Default time-to-live for workspaces created from the template.
-`allow_user_cancel_workspace_jobs` (Boolean) Whether users can cancel in-progress workspace jobs using this template. Defaults to true.
73
73
-`auto_start_permitted_days_of_week` (Set of String) (Enterprise) List of days of the week in which autostart is allowed to happen, for all workspaces created from this template. Defaults to all days. If no days are specified, autostart is not allowed.
74
74
-`auto_stop_requirement` (Attributes) (Enterprise) The auto-stop requirement for all workspaces created from this template. (see [below for nested schema](#nestedatt--auto_stop_requirement))
75
+
-`cors_behavior` (String) The CORS behavior for workspace apps in this template. Valid values are `simple` (default CORS middleware) or `passthru` (bypass CORS middleware). Defaults to `simple`. Requires a Coder deployment running v2.26.0 or later.
75
76
-`default_ttl_ms` (Number) The default time-to-live for all workspaces created from this template, in milliseconds.
76
77
-`deprecation_message` (String) If set, the template will be marked as deprecated with the provided message and users will be blocked from creating new workspaces from it. Does nothing if set when the resource is created.
77
78
-`description` (String) A description of the template.
MarkdownDescription: "The CORS behavior for workspace apps in this template. Valid values are `simple` (default CORS middleware) or `passthru` (bypass CORS middleware). Defaults to `simple`. Requires a Coder deployment running v2.26.0 or later.",
0 commit comments