Skip to content

Commit 2c5bf24

Browse files
toptobesbdunn313
andauthored
feat: PCU operations support (#483)
Adds support for the following: - `pcu_group` data source - `pcu_groups` data source - `pcu_group_associations` data source - `resolve_datacenter` function **(warning: requires terraform v1.8+)** - `pcu_group` resource - `pcu_group_association` resource Co-authored-by: Brad Dunn <[email protected]>
1 parent 6907fdc commit 2c5bf24

35 files changed

+2581
-143
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ The [examples diretory](./examples) contains example configuration for the vario
7272
7373
### Build the provider from source
7474
75-
The build requires [Go](https://golang.org/doc/install) >= 1.23
75+
The build requires [Go](https://golang.org/doc/install) >= 1.24
7676
7777
In order to develop and test this provider, you'll need to configure your local environment
7878
with a custom Terraform [config file](https://developer.hashicorp.com/terraform/cli/config/config-file).

docs/data-sources/pcu_group.md

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
---
2+
# generated by https://github.com/hashicorp/terraform-plugin-docs
3+
page_title: "astra_pcu_group Data Source - terraform-provider-astra"
4+
subcategory: ""
5+
description: |-
6+
Retrieves details for a specific PCU (Provisioned Capacity Units) group by its ID.
7+
---
8+
9+
# astra_pcu_group (Data Source)
10+
11+
Retrieves details for a specific PCU (Provisioned Capacity Units) group by its ID.
12+
13+
## Example Usage
14+
15+
```terraform
16+
data "astra_pcu_group" "example" {
17+
pcu_group_id = "6c57916e-7bd8-4bb6-b264-bae906c8859f"
18+
}
19+
20+
output "pcu_group_info" {
21+
value = {
22+
title = data.astra_pcu_group.example.title
23+
cloud_provider = data.astra_pcu_group.example.cloud_provider
24+
region = data.astra_pcu_group.example.region
25+
min_capacity = data.astra_pcu_group.example.min_capacity
26+
max_capacity = data.astra_pcu_group.example.max_capacity
27+
status = data.astra_pcu_group.example.status
28+
}
29+
}
30+
```
31+
32+
<!-- schema generated by tfplugindocs -->
33+
## Schema
34+
35+
### Required
36+
37+
- `pcu_group_id` (String) The unique identifier of the PCU group to retrieve.
38+
39+
### Read-Only
40+
41+
- `cache_type` (String) The instance type/cache type for the PCU group.
42+
- `cloud_provider` (String) The cloud provider where the PCU group is provisioned (e.g., AWS, GCP, AZURE).
43+
- `created_at` (String) Timestamp when the PCU group was created.
44+
- `created_by` (String) The user who created the PCU group.
45+
- `description` (String) The user-defined description of the PCU group.
46+
- `id` (String) The unique identifier of the PCU group.
47+
- `max_capacity` (Number) The maximum capacity units the PCU group may scale to.
48+
- `min_capacity` (Number) The minimum capacity units the PCU must be scaled to.
49+
- `org_id` (String) The organization ID that owns this PCU group.
50+
- `provision_type` (String) The provisioning type for the PCU group (i.e., SHARED, DEDICATED).
51+
- `region` (String) The cloud region where the PCU group is provisioned.
52+
- `reserved_capacity` (Number) The reserved (committed) capacity units for the PCU group.
53+
- `status` (String) The current status of the PCU group (e.g., ACTIVE, CREATED, INITIALIZING).
54+
- `title` (String) The user-defined title/name of the PCU group.
55+
- `updated_at` (String) Timestamp when the PCU group was last updated.
56+
- `updated_by` (String) The user who last updated the PCU group.
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
---
2+
# generated by https://github.com/hashicorp/terraform-plugin-docs
3+
page_title: "astra_pcu_group_associations Data Source - terraform-provider-astra"
4+
subcategory: ""
5+
description: |-
6+
Gets all of the associations for a given PCU group.
7+
---
8+
9+
# astra_pcu_group_associations (Data Source)
10+
11+
Gets all of the associations for a given PCU group.
12+
13+
## Example Usage
14+
15+
```terraform
16+
data "astra_pcu_group" "pcu_group" {
17+
# ...
18+
}
19+
20+
data "astra_pcu_group_associations" "assocs" {
21+
pcu_group_id = data.astra_pcu_group.pcu_group.id
22+
}
23+
24+
output "datacenters" {
25+
value = data.astra_pcu_group_associations.assocs.results[*].datacenter_id
26+
}
27+
```
28+
29+
<!-- schema generated by tfplugindocs -->
30+
## Schema
31+
32+
### Required
33+
34+
- `pcu_group_id` (String) The PCU group to retrieve associations for.
35+
36+
### Read-Only
37+
38+
- `results` (Attributes List) (see [below for nested schema](#nestedatt--results))
39+
40+
<a id="nestedatt--results"></a>
41+
### Nested Schema for `results`
42+
43+
Read-Only:
44+
45+
- `datacenter_id` (String) The datacenter that is associated with the PCU Group.
46+
- `provisioning_status` (String) The provisioning status of the PCU group association. This will likely always be 'CREATED'.

docs/data-sources/pcu_groups.md

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
---
2+
# generated by https://github.com/hashicorp/terraform-plugin-docs
3+
page_title: "astra_pcu_groups Data Source - terraform-provider-astra"
4+
subcategory: ""
5+
description: |-
6+
Retrieves a list of PCU (Provisioned Capacity Units) groups. If no IDs are specified, returns all PCU groups in the organization.
7+
---
8+
9+
# astra_pcu_groups (Data Source)
10+
11+
Retrieves a list of PCU (Provisioned Capacity Units) groups. If no IDs are specified, returns all PCU groups in the organization.
12+
13+
## Example Usage
14+
15+
```terraform
16+
# Get all PCU groups in the organization
17+
data "astra_pcu_groups" "all" {
18+
}
19+
20+
output "all_pcu_groups" {
21+
value = data.astra_pcu_groups.all.results[*].title
22+
}
23+
24+
# Get specific PCU groups by ID
25+
data "astra_pcu_groups" "specific" {
26+
pcu_group_ids = [
27+
"6c57916e-7bd8-4bb6-b264-bae906c8859f",
28+
"7d68027f-8ce9-5cc7-c375-cbf017d9960g"
29+
]
30+
}
31+
32+
output "specific_pcu_groups" {
33+
value = {
34+
for group in data.astra_pcu_groups.specific.results : group.id => {
35+
title = group.title
36+
cloud_provider = group.cloud_provider
37+
region = group.region
38+
status = group.status
39+
}
40+
}
41+
}
42+
```
43+
44+
<!-- schema generated by tfplugindocs -->
45+
## Schema
46+
47+
### Optional
48+
49+
- `pcu_group_ids` (List of String) Optional list of PCU group IDs to retrieve. If not provided, all PCU groups in the organization will be returned.
50+
51+
### Read-Only
52+
53+
- `results` (Attributes List) The list of PCU groups matching the specified criteria or all PCU groups if no IDs were provided. (see [below for nested schema](#nestedatt--results))
54+
55+
<a id="nestedatt--results"></a>
56+
### Nested Schema for `results`
57+
58+
Read-Only:
59+
60+
- `cache_type` (String) The instance type/cache type for the PCU group.
61+
- `cloud_provider` (String) The cloud provider where the PCU group is provisioned (e.g., AWS, GCP, AZURE).
62+
- `created_at` (String) Timestamp when the PCU group was created.
63+
- `created_by` (String) The user who created the PCU group.
64+
- `description` (String) The user-defined description of the PCU group.
65+
- `id` (String) The unique identifier of the PCU group.
66+
- `max_capacity` (Number) The maximum capacity units the PCU group may scale to.
67+
- `min_capacity` (Number) The minimum capacity units the PCU must be scaled to.
68+
- `org_id` (String) The organization ID that owns this PCU group.
69+
- `provision_type` (String) The provisioning type for the PCU group (i.e., SHARED, DEDICATED).
70+
- `region` (String) The cloud region where the PCU group is provisioned.
71+
- `reserved_capacity` (Number) The reserved (committed) capacity units for the PCU group.
72+
- `status` (String) The current status of the PCU group (e.g., ACTIVE, CREATED, INITIALIZING).
73+
- `title` (String) The user-defined title/name of the PCU group.
74+
- `updated_at` (String) Timestamp when the PCU group was last updated.
75+
- `updated_by` (String) The user who last updated the PCU group.
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
---
2+
# generated by https://github.com/hashicorp/terraform-plugin-docs
3+
page_title: "resolve_datacenter function - terraform-provider-astra"
4+
subcategory: ""
5+
description: |-
6+
7+
---
8+
9+
# function: resolve_datacenter
10+
11+
Resolves the datacenter ID for a given database and optional region (if the database has multiple regions). Helpful for components that require a datacenter ID such as PCU group associations and private links.
12+
13+
## Example Usage
14+
15+
```terraform
16+
data "astra_database" "example_db" {
17+
# ...
18+
}
19+
20+
locals {
21+
# If the database has multiple regions, you can specify the desired one explicitly
22+
dc_id1 = provider::astra::resolve_datacenter(data.astra_database.example_db, "us-central1")
23+
24+
# Or, if the database has only one region, you can omit the second argument
25+
dc_id2 = provider::astra::resolve_datacenter(data.astra_database.example_db)
26+
27+
# This is all shorthand for the following much longer expression:
28+
dc_id3 = data.astra_database.example_db.datacenters["${data.astra_database.example_db.cloud_provider}.${data.astra_database.example_db.regions[0]}"]
29+
}
30+
```
31+
32+
## Signature
33+
34+
<!-- signature generated by tfplugindocs -->
35+
```text
36+
resolve_datacenter(database object, region string...) string
37+
```
38+
39+
## Arguments
40+
41+
<!-- arguments generated by tfplugindocs -->
42+
1. `database` (Object) The database object to resolve the datacenter from. This should be the result of an "astra_database" resource or data source.
43+
<!-- variadic argument generated by tfplugindocs -->
44+
1. `region` (Variadic, String) The region to resolve the datacenter for. If not provided, the function will attempt to resolve the datacenter if there is only one configured.

docs/resources/pcu_group.md

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
---
2+
# generated by https://github.com/hashicorp/terraform-plugin-docs
3+
page_title: "astra_pcu_group Resource - terraform-provider-astra"
4+
subcategory: ""
5+
description: |-
6+
Creates and manages a PCU (Provisioned Capacity Units) group. PCU groups provide dedicated compute capacity for databases in a specific cloud provider and region.
7+
---
8+
9+
# astra_pcu_group (Resource)
10+
11+
Creates and manages a PCU (Provisioned Capacity Units) group. PCU groups provide dedicated compute capacity for databases in a specific cloud provider and region.
12+
13+
## Example Usage
14+
15+
```terraform
16+
# Create a basic PCU group
17+
# NOTE: This creates a committed reserved-capacity group! Make sure this is what you want!
18+
resource "astra_pcu_group" "example" {
19+
title = "production-pcu-group"
20+
cloud_provider = "AWS"
21+
region = "us-east-1"
22+
min_capacity = 2
23+
max_capacity = 10
24+
reserved_capacity = 2
25+
description = "PCU group for production databases"
26+
# You can uncomment the line below to park the group
27+
# The group must be created first as a resource before parking can be performed successfully
28+
# parked = true
29+
}
30+
31+
# Create a PCU group with custom settings
32+
resource "astra_pcu_group" "custom" {
33+
title = "dev-pcu-group"
34+
cloud_provider = "GCP"
35+
region = "us-central1"
36+
cache_type = "STANDARD"
37+
provision_type = "SHARED"
38+
min_capacity = 1
39+
max_capacity = 5
40+
description = "PCU group for development environment"
41+
42+
# Disable deletion protection for dev environment
43+
deletion_protection = false
44+
45+
# Enable reserved capacity protection
46+
reserved_protection = true
47+
}
48+
49+
output "pcu_group_id" {
50+
value = astra_pcu_group.example.id
51+
}
52+
53+
output "pcu_group_status" {
54+
value = astra_pcu_group.example.status
55+
}
56+
```
57+
58+
<!-- schema generated by tfplugindocs -->
59+
## Schema
60+
61+
### Required
62+
63+
- `cloud_provider` (String) The cloud provider where the PCU group will be provisioned (e.g., AWS, GCP, AZURE). This cannot be changed after creation.
64+
- `max_capacity` (Number) The maximum capacity units the PCU group may scale to. Must be at least 1 and greater than or equal to min_capacity.
65+
- `min_capacity` (Number) The minimum capacity units the PCU must be scaled to. Must be at least 1 and greater than or equal to reserved_capacity.
66+
- `region` (String) The cloud region where the PCU group will be provisioned. This cannot be changed after creation.
67+
- `title` (String) The user-defined title/name of the PCU group.
68+
69+
### Optional
70+
71+
- `cache_type` (String) The instance type/cache type for the PCU group. Defaults to 'STANDARD'. Changing this value requires replacement.
72+
- `deletion_protection` (Boolean) When enabled, prevents accidental deletion of the PCU group. Defaults to true.
73+
- `description` (String) A user-defined description for the PCU group.
74+
- `park` (Boolean) When set to true, parks the PCU group and any associated databases, reducing costs. When set to false, unparks the group. Defaults to false.
75+
- `provision_type` (String) The provisioning type for the PCU group (e.g., SHARED, DEDICATED). Defaults to 'SHARED'. Changing this value requires replacement.
76+
- `reserved_capacity` (Number) The reserved (committed) capacity units for the PCU group. Must be at least 0. Changing this value when reserved_protection is enabled will result in an error.
77+
- `reserved_protection` (Boolean) When enabled, prevents accidental reserved capacity unit increases. Defaults to true.
78+
- `timeouts` (Block, Optional) (see [below for nested schema](#nestedblock--timeouts))
79+
80+
### Read-Only
81+
82+
- `created_at` (String) Timestamp when the PCU group was created.
83+
- `created_by` (String) The user who created the PCU group.
84+
- `id` (String) The unique identifier of the PCU group.
85+
- `org_id` (String) The organization ID that owns this PCU group.
86+
- `status` (String) The current status of the PCU group (e.g., ACTIVE, PARKED, CREATING, TERMINATING).
87+
- `updated_at` (String) Timestamp when the PCU group was last updated.
88+
- `updated_by` (String) The user who last updated the PCU group.
89+
90+
<a id="nestedblock--timeouts"></a>
91+
### Nested Schema for `timeouts`
92+
93+
Optional:
94+
95+
- `create` (String) A string that can be [parsed as a duration](https://pkg.go.dev/time#ParseDuration) consisting of numbers and unit suffixes, such as "30s" or "2h45m". Valid time units are "s" (seconds), "m" (minutes), "h" (hours).
96+
- `update` (String) A string that can be [parsed as a duration](https://pkg.go.dev/time#ParseDuration) consisting of numbers and unit suffixes, such as "30s" or "2h45m". Valid time units are "s" (seconds), "m" (minutes), "h" (hours).
97+
98+
## Import
99+
100+
Import is supported using the following syntax:
101+
102+
```shell
103+
# Import an existing PCU group by its ID
104+
terraform import astra_pcu_group.example 6c57916e-7bd8-4bb6-b264-bae906c8859f
105+
```

0 commit comments

Comments
 (0)