|
| 1 | +--- |
| 2 | +# generated by https://github.com/hashicorp/terraform-plugin-docs |
| 3 | +page_title: "posthog_access_control Resource - posthog" |
| 4 | +subcategory: "" |
| 5 | +description: |- |
| 6 | + Manages access control for resources within a PostHog project. |
| 7 | + This resource allows you to set access levels for resource types (like feature flags, dashboards, etc.). |
| 8 | + You can set permissions at three levels: |
| 9 | + Project default: Applies to everyone in the project for this resource type. Omit both role and organization_member.Role-specific: Applies to members of a specific role. Set role.Member-specific: Applies to a specific organization member. Set organization_member. |
| 10 | + Additionally, you can scope to: |
| 11 | + Resource-type level: Applies to all resources of a type (e.g., all dashboards). Omit resource_id.Resource-instance level: Applies to a specific resource (e.g., one dashboard). Set resource_id. |
| 12 | + You can combine these: set a project default for all dashboards, or set a project default for a specific dashboard. |
| 13 | + ~> Note: role and organization_member are mutually exclusive - you cannot specify both. Omit both for project defaults. |
| 14 | + ~> Enterprise Feature: Role-based access control (RBAC) requires a PostHog Enterprise plan. See Access Control documentation https://posthog.com/docs/settings/access-control for more details. |
| 15 | +--- |
| 16 | + |
| 17 | +# posthog_access_control (Resource) |
| 18 | + |
| 19 | +Manages access control for resources within a PostHog project. |
| 20 | + |
| 21 | +This resource allows you to set access levels for resource types (like feature flags, dashboards, etc.). |
| 22 | + |
| 23 | +You can set permissions at three levels: |
| 24 | +- **Project default**: Applies to everyone in the project for this resource type. Omit both `role` and `organization_member`. |
| 25 | +- **Role-specific**: Applies to members of a specific role. Set `role`. |
| 26 | +- **Member-specific**: Applies to a specific organization member. Set `organization_member`. |
| 27 | + |
| 28 | +Additionally, you can scope to: |
| 29 | +- **Resource-type level**: Applies to all resources of a type (e.g., all dashboards). Omit `resource_id`. |
| 30 | +- **Resource-instance level**: Applies to a specific resource (e.g., one dashboard). Set `resource_id`. |
| 31 | + |
| 32 | +You can combine these: set a project default for all dashboards, or set a project default for a specific dashboard. |
| 33 | + |
| 34 | +~> **Note:** `role` and `organization_member` are mutually exclusive - you cannot specify both. Omit both for project defaults. |
| 35 | + |
| 36 | +~> **Enterprise Feature:** Role-based access control (RBAC) requires a PostHog Enterprise plan. See [Access Control documentation](https://posthog.com/docs/settings/access-control) for more details. |
| 37 | + |
| 38 | +## Example Usage |
| 39 | + |
| 40 | +```terraform |
| 41 | +# --- Project Defaults (no role or organization_member) --- |
| 42 | +
|
| 43 | +# Set project-wide default: everyone can view surveys |
| 44 | +resource "posthog_access_control" "surveys_project_default" { |
| 45 | + resource = "survey" |
| 46 | + access_level = "viewer" |
| 47 | +} |
| 48 | +
|
| 49 | +# Set default for a specific dashboard: everyone can view this dashboard |
| 50 | +resource "posthog_access_control" "analytics_dashboard_default" { |
| 51 | + resource = "dashboard" |
| 52 | + resource_id = posthog_dashboard.analytics.id |
| 53 | + access_level = "viewer" |
| 54 | +} |
| 55 | +
|
| 56 | +# --- Role-based Access --- |
| 57 | +
|
| 58 | +# Grant a role editor access to all feature flags in the project |
| 59 | +resource "posthog_access_control" "engineering_feature_flags" { |
| 60 | + resource = "feature_flag" |
| 61 | + access_level = "editor" |
| 62 | + role = posthog_role.engineering.id |
| 63 | +} |
| 64 | +
|
| 65 | +# Grant a role viewer access to all dashboards |
| 66 | +resource "posthog_access_control" "support_dashboards" { |
| 67 | + resource = "dashboard" |
| 68 | + access_level = "viewer" |
| 69 | + role = posthog_role.support.id |
| 70 | +} |
| 71 | +
|
| 72 | +# Grant a role viewer access to a specific dashboard |
| 73 | +resource "posthog_access_control" "support_analytics_dashboard" { |
| 74 | + resource = "dashboard" |
| 75 | + resource_id = posthog_dashboard.analytics.id |
| 76 | + access_level = "viewer" |
| 77 | + role = posthog_role.support.id |
| 78 | +} |
| 79 | +
|
| 80 | +# Explicitly deny a role access to experiments (access_level = "none") |
| 81 | +resource "posthog_access_control" "support_no_experiments" { |
| 82 | + resource = "experiment" |
| 83 | + access_level = "none" |
| 84 | + role = posthog_role.support.id |
| 85 | +} |
| 86 | +
|
| 87 | +# --- User-specific Access --- |
| 88 | +
|
| 89 | +# Grant a specific user editor access to a specific dashboard |
| 90 | +resource "posthog_access_control" "alice_analytics_dashboard" { |
| 91 | + resource = "dashboard" |
| 92 | + resource_id = posthog_dashboard.analytics.id |
| 93 | + access_level = "editor" |
| 94 | + organization_member = posthog_organization_member.alice.id |
| 95 | +} |
| 96 | +``` |
| 97 | + |
| 98 | +<!-- schema generated by tfplugindocs --> |
| 99 | +## Schema |
| 100 | + |
| 101 | +### Required |
| 102 | + |
| 103 | +- `access_level` (String) The access level to grant. Common values are `none`, `viewer`, `editor`. |
| 104 | +- `resource` (String) The resource type to control access for. Valid values include: `action`, `alert`, `annotation`, `cohort`, `dashboard`, `experiment`, `feature_flag`, `insight`, `notebook`, `session_recording`, `survey`, etc. |
| 105 | + |
| 106 | +### Optional |
| 107 | + |
| 108 | +- `organization_member` (String) The organization member ID to grant access to (either `organization_member_id` from `posthog_user` data source, or `posthog_organization_member.<name>.id`). Mutually exclusive with `role`. If neither `role` nor `organization_member` is set, this becomes the project default for the resource type. |
| 109 | +- `project_id` (String) Project ID (environment) for this resource. Overrides the provider-level project_id. |
| 110 | +- `resource_id` (String) The ID of a specific resource to control access for. If omitted, the access control applies to all resources of the specified type. |
| 111 | +- `role` (String) The UUID of the role to grant access to. Mutually exclusive with `organization_member`. If neither `role` nor `organization_member` is set, this becomes the project default for the resource type. |
| 112 | + |
| 113 | +### Read-Only |
| 114 | + |
| 115 | +- `created_at` (String) Timestamp when the access control was created. |
| 116 | +- `id` (String) Composite identifier for the access control. |
| 117 | +- `updated_at` (String) Timestamp when the access control was last updated. |
| 118 | + |
| 119 | +## Import |
| 120 | + |
| 121 | +Import is supported using the following syntax: |
| 122 | + |
| 123 | +The [`terraform import` command](https://developer.hashicorp.com/terraform/cli/commands/import) can be used, for example: |
| 124 | + |
| 125 | +```shell |
| 126 | +# Import format for project default (all resources of a type): |
| 127 | +# project_id/resource_type/default |
| 128 | +terraform import posthog_access_control.surveys_project_default 12345/survey/default |
| 129 | + |
| 130 | +# Import format for project default on a specific resource: |
| 131 | +# project_id/resource_type/resource_id/default |
| 132 | +terraform import posthog_access_control.analytics_dashboard_default 12345/dashboard/999/default |
| 133 | + |
| 134 | +# Import format for role-based access control (resource type level): |
| 135 | +# project_id/resource_type/role/role_id |
| 136 | +terraform import posthog_access_control.engineering_feature_flags 12345/feature_flag/role/abc-123-def |
| 137 | + |
| 138 | +# Import format for member-based access control (resource type level): |
| 139 | +# project_id/resource_type/member/member_id |
| 140 | +terraform import posthog_access_control.alice_dashboards 12345/dashboard/member/xyz-456-uvw |
| 141 | + |
| 142 | +# Import format for role-based access control (specific resource): |
| 143 | +# project_id/resource_type/resource_id/role/role_id |
| 144 | +terraform import posthog_access_control.role_specific_dashboard 12345/dashboard/999/role/abc-123-def |
| 145 | + |
| 146 | +# Import format for member-based access control (specific resource): |
| 147 | +# project_id/resource_type/resource_id/member/member_id |
| 148 | +terraform import posthog_access_control.alice_specific_dashboard 12345/dashboard/999/member/xyz-456-uvw |
| 149 | +``` |
0 commit comments