Skip to content

Commit 0fb3762

Browse files
committed
chore: example for building_block_v2
includes adaptations from PR remarks
1 parent 433bbbb commit 0fb3762

File tree

8 files changed

+152
-16
lines changed

8 files changed

+152
-16
lines changed

client/buildingblock_v2.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ func (c *MeshStackProviderClient) waitForBuildingBlockV2DeletionFunc(uuid string
205205

206206
// If building block is in FAILED state during deletion, consider it a terminal state
207207
if current.Status.Status == "FAILED" {
208-
return retry.NonRetryableError(fmt.Errorf("building block %s reached FAILED state during deletion", uuid))
208+
return retry.NonRetryableError(fmt.Errorf("building block %s reached FAILED state during deletion. For more details, check the building block run logs in meshStack", uuid))
209209
}
210210

211211
// Not done yet, continue polling

docs/data-sources/building_block_v2.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,15 @@ Single building block by UUID.
1313

1414
~> **Note:** This resource is in preview. It's incomplete and will change in the near future.
1515

16-
16+
## Example Usage
17+
18+
```terraform
19+
data "meshstack_building_block_v2" "example" {
20+
metadata = {
21+
uuid = "e2cc9cbb-cf1d-4dc0-8461-64140110b6dc" # Building block UUID
22+
}
23+
}
24+
```
1725

1826
<!-- schema generated by tfplugindocs -->
1927
## Schema

docs/resources/building_block_v2.md

Lines changed: 63 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,68 @@ Manage a workspace or tenant building block.
1313

1414
~> **Note:** This resource is in preview. It's incomplete and will change in the near future.
1515

16-
16+
## Example Usage
17+
18+
```terraform
19+
# Workspace Building Block
20+
resource "meshstack_building_block_v2" "example_workspace" {
21+
spec = {
22+
building_block_definition_version_ref = {
23+
uuid = "00000000-0000-0000-0000-000000000000" # Replace with actual definition version UUID
24+
}
25+
26+
display_name = "my-building-block"
27+
target_ref = {
28+
kind = "meshWorkspace"
29+
identifier = "my-workspace-identifier" # Replace with actual workspace identifier
30+
}
31+
32+
inputs = {
33+
name = { value_string = "my-name" }
34+
size = { value_int = 16 }
35+
}
36+
}
37+
}
38+
39+
# Tenant Building Block
40+
data "meshstack_project" "example" {
41+
metadata = {
42+
name = "my-project-identifier"
43+
owned_by_workspace = "my-workspace-identifier"
44+
}
45+
}
46+
47+
resource "meshstack_tenant_v4" "example" {
48+
metadata = {
49+
owned_by_workspace = data.meshstack_project.example.metadata.owned_by_workspace
50+
owned_by_project = data.meshstack_project.example.metadata.name
51+
}
52+
53+
spec = {
54+
platform_identifier = "my-platform-identifier"
55+
landing_zone_identifier = "platform-landing-zone-identifier"
56+
}
57+
}
58+
59+
resource "meshstack_building_block_v2" "example_tenant" {
60+
spec = {
61+
building_block_definition_version_ref = {
62+
uuid = "00000000-0000-0000-0000-000000000001" # Replace with actual definition version UUID
63+
}
64+
65+
display_name = "my-tenant-building-block"
66+
target_ref = {
67+
kind = "meshTenant"
68+
uuid = meshstack_tenant_v4.example.metadata.uuid
69+
}
70+
71+
inputs = {
72+
name = { value_string = "my-name" }
73+
size = { value_int = 16 }
74+
}
75+
}
76+
}
77+
```
1778

1879
<!-- schema generated by tfplugindocs -->
1980
## Schema
@@ -24,7 +85,7 @@ Manage a workspace or tenant building block.
2485

2586
### Optional
2687

27-
- `wait_for_completion` (Boolean) Whether to wait for the Building Block to reach a terminal state (SUCCEEDED or FAILED) before completing the resource creation. If false, the resource creation completes immediately after the Building Block is created. (Defaults to `true`)
88+
- `wait_for_completion` (Boolean) Whether to wait for the Building Block to reach a terminal state (SUCCEEDED or FAILED) before completing the resource creation or deletion. If false, the resource creation completes immediately after the Building Block is created. (Defaults to `true`)
2889

2990
### Read-Only
3091

docs/resources/tenant_v4.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ resource "meshstack_tenant_v4" "example" {
4646

4747
### Optional
4848

49-
- `wait_for_completion` (Boolean) Wait for tenant creation/deletion to complete before considering the resource created. Defaults to `true`.
49+
- `wait_for_completion` (Boolean) Wait for tenant creation/deletion to complete. Note that tenant creation is considered complete when `spec.platformTenantId` is set and not necessarily when replication is finished. Defaults to `true`.
5050

5151
### Read-Only
5252

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
data "meshstack_building_block_v2" "example" {
2+
metadata = {
3+
uuid = "e2cc9cbb-cf1d-4dc0-8461-64140110b6dc" # Building block UUID
4+
}
5+
}
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
# Workspace Building Block
2+
resource "meshstack_building_block_v2" "example_workspace" {
3+
spec = {
4+
building_block_definition_version_ref = {
5+
uuid = "00000000-0000-0000-0000-000000000000" # Replace with actual definition version UUID
6+
}
7+
8+
display_name = "my-building-block"
9+
target_ref = {
10+
kind = "meshWorkspace"
11+
identifier = "my-workspace-identifier" # Replace with actual workspace identifier
12+
}
13+
14+
inputs = {
15+
name = { value_string = "my-name" }
16+
size = { value_int = 16 }
17+
}
18+
}
19+
}
20+
21+
# Tenant Building Block
22+
data "meshstack_project" "example" {
23+
metadata = {
24+
name = "my-project-identifier"
25+
owned_by_workspace = "my-workspace-identifier"
26+
}
27+
}
28+
29+
resource "meshstack_tenant_v4" "example" {
30+
metadata = {
31+
owned_by_workspace = data.meshstack_project.example.metadata.owned_by_workspace
32+
owned_by_project = data.meshstack_project.example.metadata.name
33+
}
34+
35+
spec = {
36+
platform_identifier = "my-platform-identifier"
37+
landing_zone_identifier = "platform-landing-zone-identifier"
38+
}
39+
}
40+
41+
resource "meshstack_building_block_v2" "example_tenant" {
42+
spec = {
43+
building_block_definition_version_ref = {
44+
uuid = "00000000-0000-0000-0000-000000000001" # Replace with actual definition version UUID
45+
}
46+
47+
display_name = "my-tenant-building-block"
48+
target_ref = {
49+
kind = "meshTenant"
50+
uuid = meshstack_tenant_v4.example.metadata.uuid
51+
}
52+
53+
inputs = {
54+
name = { value_string = "my-name" }
55+
size = { value_int = 16 }
56+
}
57+
}
58+
}

internal/provider/building_block_v2_resource.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@ func (r *buildingBlockV2Resource) Schema(ctx context.Context, req resource.Schem
280280
},
281281
},
282282
"wait_for_completion": schema.BoolAttribute{
283-
MarkdownDescription: "Whether to wait for the Building Block to reach a terminal state (SUCCEEDED or FAILED) before completing the resource creation. If false, the resource creation completes immediately after the Building Block is created. (Defaults to `true`)",
283+
MarkdownDescription: "Whether to wait for the Building Block to reach a terminal state (SUCCEEDED or FAILED) before completing the resource creation or deletion. If false, the resource creation completes immediately after the Building Block is created. (Defaults to `true`)",
284284
Optional: true,
285285
Computed: true,
286286
Default: booldefault.StaticBool(true),
@@ -290,9 +290,8 @@ func (r *buildingBlockV2Resource) Schema(ctx context.Context, req resource.Schem
290290
}
291291

292292
type buildingBlockV2ResourceModel struct {
293-
WaitForCompletion types.Bool `tfsdk:"wait_for_completion"`
294-
ApiVersion types.String `tfsdk:"api_version"`
295-
Kind types.String `tfsdk:"kind"`
293+
ApiVersion types.String `tfsdk:"api_version"`
294+
Kind types.String `tfsdk:"kind"`
296295

297296
Spec struct {
298297
DisplayName types.String `tfsdk:"display_name"`
@@ -306,6 +305,9 @@ type buildingBlockV2ResourceModel struct {
306305
// Metadata and Status are unused when creating the resource
307306
Metadata types.Object `tfsdk:"metadata"`
308307
Status types.Object `tfsdk:"status"`
308+
309+
// additional attributes not part of the API
310+
WaitForCompletion types.Bool `tfsdk:"wait_for_completion"`
309311
}
310312

311313
type buildingBlockV2DefinitionVersionRefResourceModel struct {

internal/provider/tenant_v4_resource.go

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,14 @@ var (
2828
)
2929

3030
type tenantV4ResourceModel struct {
31-
ApiVersion types.String `tfsdk:"api_version"`
32-
Kind types.String `tfsdk:"kind"`
33-
Metadata tenantV4ResourceMetadataModel `tfsdk:"metadata"`
34-
Spec tenantV4ResourceSpecModel `tfsdk:"spec"`
35-
Status types.Object `tfsdk:"status"`
36-
WaitForCompletion types.Bool `tfsdk:"wait_for_completion"`
31+
ApiVersion types.String `tfsdk:"api_version"`
32+
Kind types.String `tfsdk:"kind"`
33+
Metadata tenantV4ResourceMetadataModel `tfsdk:"metadata"`
34+
Spec tenantV4ResourceSpecModel `tfsdk:"spec"`
35+
Status types.Object `tfsdk:"status"`
36+
37+
// additional attributes not part of the API
38+
WaitForCompletion types.Bool `tfsdk:"wait_for_completion"`
3739
}
3840

3941
type tenantV4ResourceMetadataModel struct {
@@ -213,7 +215,7 @@ func (r *tenantV4Resource) Schema(_ context.Context, _ resource.SchemaRequest, r
213215
},
214216

215217
"wait_for_completion": schema.BoolAttribute{
216-
MarkdownDescription: "Wait for tenant creation/deletion to complete before considering the resource created. Defaults to `true`.",
218+
MarkdownDescription: "Wait for tenant creation/deletion to complete. Note that tenant creation is considered complete when `spec.platformTenantId` is set and not necessarily when replication is finished. Defaults to `true`.",
217219
Optional: true,
218220
Computed: true,
219221
Default: booldefault.StaticBool(true),

0 commit comments

Comments
 (0)