PrefectHQ / terraform-provider-prefect

Terraform Provider for Prefect Cloud
https://registry.terraform.io/providers/PrefectHQ/prefect/latest/docs
Apache License 2.0
29 stars 13 forks source link

feat(blocks): add `prefect_block_access` resource for binding ACLs to Block resources #206

Closed parkedwards closed 3 weeks ago

parkedwards commented 3 weeks ago

resolves https://github.com/PrefectHQ/terraform-provider-prefect/issues/204

Testing Creates Creation - I also created (or queried) different actors/teams and passed them into the `prefect_block_access` resource ```shell Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the following symbols: + create Terraform will perform the following actions: # prefect_block.foo will be created + resource "prefect_block" "foo" { + created = (known after apply) + data = (sensitive value) + id = (known after apply) + name = "foo" + type_slug = "secret" + updated = (known after apply) + workspace_id = "45cfa7c6-e136-471c-859b-3be89d0a99ce" } # prefect_block_access.access will be created + resource "prefect_block_access" "access" { + block_id = (known after apply) + manage_actor_ids = [ + (known after apply), ] + manage_team_ids = [ + "8e82d7bd-f7c5-41df-a849-a45a33241972", ] + view_actor_ids = [ + "f08daf4c-804f-4bae-80cf-19a6590cc2fe", ] + view_team_ids = [] + workspace_id = "45cfa7c6-e136-471c-859b-3be89d0a99ce" } # prefect_service_account.bot will be created + resource "prefect_service_account" "bot" { + account_id = (known after apply) + account_role_name = "Member" + actor_id = (known after apply) + api_key = (sensitive value) + api_key_created = (known after apply) + api_key_id = (known after apply) + api_key_name = (known after apply) + created = (known after apply) + id = (known after apply) + name = "bot" + updated = (known after apply) } # prefect_workspace_access.bot_developer will be created + resource "prefect_workspace_access" "bot_developer" { + accessor_id = (known after apply) + accessor_type = "SERVICE_ACCOUNT" + id = (known after apply) + workspace_id = "45cfa7c6-e136-471c-859b-3be89d0a99ce" + workspace_role_id = "b75a2218-b485-426e-8bf2-de6499532d26" } # prefect_workspace_access.team_developer will be created + resource "prefect_workspace_access" "team_developer" { + accessor_id = "8e82d7bd-f7c5-41df-a849-a45a33241972" + accessor_type = "TEAM" + id = (known after apply) + workspace_id = "45cfa7c6-e136-471c-859b-3be89d0a99ce" + workspace_role_id = "b75a2218-b485-426e-8bf2-de6499532d26" } # prefect_workspace_access.user_developer will be created + resource "prefect_workspace_access" "user_developer" { + accessor_id = "7f2d563e-ca3c-45bd-ad80-572302dab5ba" + accessor_type = "USER" + id = (known after apply) + workspace_id = "45cfa7c6-e136-471c-859b-3be89d0a99ce" + workspace_role_id = "b75a2218-b485-426e-8bf2-de6499532d26" } Plan: 6 to add, 0 to change, 0 to destroy. prefect_workspace_access.team_developer: Creating... prefect_service_account.bot: Creating... prefect_workspace_access.user_developer: Creating... prefect_block.foo: Creating... prefect_service_account.bot: Creation complete after 1s [id=e3b841d4-64dc-4892-a9ed-36771bc677f4] prefect_workspace_access.bot_developer: Creating... prefect_workspace_access.user_developer: Creation complete after 1s [id=cffefd61-ce1b-4759-8cbc-594ba7dc4b97] prefect_workspace_access.team_developer: Creation complete after 1s [id=75e9c6c0-f8ff-4821-aeef-e50d897c2ba8] prefect_workspace_access.bot_developer: Creation complete after 0s [id=d3c02770-980a-43fb-bb58-ecd4991322a1] prefect_block.foo: Creation complete after 1s [id=e947c7fa-0e2f-4499-be06-d5e380b18041] prefect_block_access.access: Creating... prefect_block_access.access: Creation complete after 0s Apply complete! Resources: 6 added, 0 changed, 0 destroyed. ``` here's the block that was created, as well as the access levels ![image](https://github.com/PrefectHQ/terraform-provider-prefect/assets/19556538/01796164-74f4-4419-a0d3-44d4577c1b31) ![image](https://github.com/PrefectHQ/terraform-provider-prefect/assets/19556538/145ed82e-2bb6-4f53-8898-eb004625093e)
Testing Deletes ```shell Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the following symbols: - destroy Terraform will perform the following actions: # prefect_block_access.access will be destroyed # (because prefect_block_access.access is not in configuration) - resource "prefect_block_access" "access" { - block_id = "3a9f46d3-d607-4f1d-9319-9f458561bf35" -> null - manage_actor_ids = [ - "d6b331d5-16e1-46a5-a7cb-fd050fbc10e9", ] -> null - manage_team_ids = [ - "8e82d7bd-f7c5-41df-a849-a45a33241972", ] -> null - view_actor_ids = [ - "32dfad8c-9242-44cb-8c1e-050032b25e08", ] -> null - view_team_ids = [] -> null - workspace_id = "45cfa7c6-e136-471c-859b-3be89d0a99ce" -> null } Plan: 0 to add, 0 to change, 1 to destroy. prefect_block_access.access: Destroying... prefect_block_access.access: Destruction complete after 0s Apply complete! Resources: 0 added, 0 changed, 1 destroyed. ``` image