-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(blocks): add
prefect_block_access
resource for binding ACLs to…
… Block resources (#206) * add block_access resource * docs * Generate Terraform Docs * ok * Generate Terraform Docs * add delay * add file --------- Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
- Loading branch information
1 parent
2fa004f
commit 39c62c1
Showing
20 changed files
with
536 additions
and
81 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
--- | ||
# generated by https://github.com/hashicorp/terraform-plugin-docs | ||
page_title: "prefect_block_access Resource - prefect" | ||
subcategory: "" | ||
description: |- | ||
This resource manages access control to Blocks. Accessors can be Service Accounts, Users, or Teams. Accessors can be Managers or Viewers. | ||
All Actors/Teams must first be granted access to the Workspace where the Block resides. | ||
Leave fields empty to use the default access controls | ||
--- | ||
|
||
# prefect_block_access (Resource) | ||
|
||
This resource manages access control to Blocks. Accessors can be Service Accounts, Users, or Teams. Accessors can be Managers or Viewers. | ||
|
||
All Actors/Teams must first be granted access to the Workspace where the Block resides. | ||
|
||
Leave fields empty to use the default access controls | ||
|
||
## Example Usage | ||
|
||
```terraform | ||
provider "prefect" {} | ||
# All Blocks are scoped to a Workspace | ||
data "prefect_workspace" "my_workspace" { | ||
handle = "my-workspace" | ||
} | ||
resource "prefect_block" "my_secret" { | ||
name = "my-secret" | ||
type_slug = "secret" | ||
data = jsonencode({ | ||
"value" : "foobar" | ||
}) | ||
workspace_id = data.prefect_workspace.my_workspace.id | ||
} | ||
# Be sure to grant all Actors/Teams who need Block access | ||
# to first be invited to the Workspace (with a role). | ||
data "prefect_workspace_role" "developer" { | ||
name = "Developer" | ||
} | ||
# Example: invite a Service Account to the Workspace | ||
resource "prefect_service_account" "bot" { | ||
name = "bot" | ||
} | ||
resource "prefect_workspace_access" "bot_developer" { | ||
accessor_type = "SERVICE_ACCOUNT" | ||
accessor_id = prefect_service_account.bot.id | ||
workspace_role_id = data.prefect_workspace_role.developer.id | ||
workspace_id = data.prefect_workspace.my_workspace.id | ||
} | ||
# Example: invite a User to the Workspace | ||
data "prefect_account_member" "user" { | ||
email = "[email protected]" | ||
} | ||
resource "prefect_workspace_access" "user_developer" { | ||
accessor_type = "USER" | ||
accessor_id = data.prefect_account_member.user.user_id | ||
workspace_role_id = data.prefect_workspace_role.developer.id | ||
workspace_id = data.prefect_workspace.my_workspace.id | ||
} | ||
# Example: invite a Team to the Workspace | ||
data "prefect_team" "eng" { | ||
name = "my-team" | ||
} | ||
resource "prefect_workspace_access" "team_developer" { | ||
accessor_type = "TEAM" | ||
accessor_id = data.prefect_team.eng.id | ||
workspace_role_id = data.prefect_workspace_role.developer.id | ||
workspace_id = data.prefect_workspace.my_workspace.id | ||
} | ||
# Grant all Actors/Teams the appropriate Manage or View access to the Block | ||
resource "prefect_block_access" "custom_access" { | ||
block_id = prefect_block.my_secret.id | ||
manage_actor_ids = [prefect_service_account.bot.actor_id] | ||
view_actor_ids = [data.prefect_account_member.user.actor_id] | ||
manage_team_ids = [data.prefect_team.eng.id] | ||
workspace_id = data.prefect_workspace.my_workspace.id | ||
} | ||
# Optionally, leave all fields empty to use the default access controls | ||
resource "prefect_block_access" "default_access" { | ||
block_id = prefect_block.my_secret.id | ||
manage_actor_ids = [] | ||
view_actor_ids = [] | ||
manage_team_ids = [] | ||
view_team_ids = [] | ||
workspace_id = data.prefect_workspace.my_workspace.id | ||
} | ||
``` | ||
|
||
<!-- schema generated by tfplugindocs --> | ||
## Schema | ||
|
||
### Required | ||
|
||
- `block_id` (String) Block ID (UUID) | ||
|
||
### Optional | ||
|
||
- `account_id` (String) Account ID (UUID) where the Block is located | ||
- `manage_actor_ids` (List of String) List of actor IDs with manage access to the Block | ||
- `manage_team_ids` (List of String) List of team IDs with manage access to the Block | ||
- `view_actor_ids` (List of String) List of actor IDs with view access to the Block | ||
- `view_team_ids` (List of String) List of team IDs with view access to the Block | ||
- `workspace_id` (String) Workspace ID (UUID) where the Block is located. In Prefect Cloud, either the `prefect_block_access` resource or the provider's `workspace_id` must be set. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
provider "prefect" {} | ||
|
||
# All Blocks are scoped to a Workspace | ||
data "prefect_workspace" "my_workspace" { | ||
handle = "my-workspace" | ||
} | ||
resource "prefect_block" "my_secret" { | ||
name = "my-secret" | ||
type_slug = "secret" | ||
data = jsonencode({ | ||
"value" : "foobar" | ||
}) | ||
workspace_id = data.prefect_workspace.my_workspace.id | ||
} | ||
|
||
# Be sure to grant all Actors/Teams who need Block access | ||
# to first be invited to the Workspace (with a role). | ||
data "prefect_workspace_role" "developer" { | ||
name = "Developer" | ||
} | ||
|
||
# Example: invite a Service Account to the Workspace | ||
resource "prefect_service_account" "bot" { | ||
name = "bot" | ||
} | ||
resource "prefect_workspace_access" "bot_developer" { | ||
accessor_type = "SERVICE_ACCOUNT" | ||
accessor_id = prefect_service_account.bot.id | ||
workspace_role_id = data.prefect_workspace_role.developer.id | ||
workspace_id = data.prefect_workspace.my_workspace.id | ||
} | ||
|
||
# Example: invite a User to the Workspace | ||
data "prefect_account_member" "user" { | ||
email = "[email protected]" | ||
} | ||
resource "prefect_workspace_access" "user_developer" { | ||
accessor_type = "USER" | ||
accessor_id = data.prefect_account_member.user.user_id | ||
workspace_role_id = data.prefect_workspace_role.developer.id | ||
workspace_id = data.prefect_workspace.my_workspace.id | ||
} | ||
|
||
# Example: invite a Team to the Workspace | ||
data "prefect_team" "eng" { | ||
name = "my-team" | ||
} | ||
resource "prefect_workspace_access" "team_developer" { | ||
accessor_type = "TEAM" | ||
accessor_id = data.prefect_team.eng.id | ||
workspace_role_id = data.prefect_workspace_role.developer.id | ||
workspace_id = data.prefect_workspace.my_workspace.id | ||
} | ||
|
||
# Grant all Actors/Teams the appropriate Manage or View access to the Block | ||
resource "prefect_block_access" "custom_access" { | ||
block_id = prefect_block.my_secret.id | ||
manage_actor_ids = [prefect_service_account.bot.actor_id] | ||
view_actor_ids = [data.prefect_account_member.user.actor_id] | ||
manage_team_ids = [data.prefect_team.eng.id] | ||
workspace_id = data.prefect_workspace.my_workspace.id | ||
} | ||
|
||
# Optionally, leave all fields empty to use the default access controls | ||
resource "prefect_block_access" "default_access" { | ||
block_id = prefect_block.my_secret.id | ||
manage_actor_ids = [] | ||
view_actor_ids = [] | ||
manage_team_ids = [] | ||
view_team_ids = [] | ||
workspace_id = data.prefect_workspace.my_workspace.id | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.