generated from hashicorp/terraform-provider-scaffolding-framework
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
1,214 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,232 @@ | ||
--- | ||
# generated by https://github.com/hashicorp/terraform-plugin-docs | ||
page_title: "astronomer_deployment_options Data Source - astronomer" | ||
subcategory: "" | ||
description: |- | ||
Deployment options data source | ||
--- | ||
|
||
# astronomer_deployment_options (Data Source) | ||
|
||
Deployment options data source | ||
|
||
## Example Usage | ||
|
||
```terraform | ||
data "astronomer_deployment_options" "example" {} | ||
data "astronomer_deployment_options" "example_with_deployment_id_query_param" { | ||
deployment_id = "clozc036j01to01jrlgvueo8t" | ||
} | ||
data "astronomer_deployment_options" "example_with_deployment_type_query_param" { | ||
deployment_type = "DEDICATED" | ||
} | ||
data "astronomer_deployment_options" "example_with_executor_query_param" { | ||
executor = "CELERY" | ||
} | ||
data "astronomer_deployment_options" "example_with_cloud_provider_query_param" { | ||
cloud_provider = "AWS" | ||
} | ||
``` | ||
|
||
<!-- schema generated by tfplugindocs --> | ||
## Schema | ||
|
||
### Optional | ||
|
||
- `cloud_provider` (String) Cloud provider | ||
- `deployment_id` (String) Deployment ID | ||
- `deployment_type` (String) Deployment type | ||
- `executor` (String) Executor | ||
|
||
### Read-Only | ||
|
||
- `executors` (List of String) Available executors | ||
- `resource_quotas` (Attributes) Resource quota options (see [below for nested schema](#nestedatt--resource_quotas)) | ||
- `runtime_releases` (List of Object) Available Astro Runtime versions (see [below for nested schema](#nestedatt--runtime_releases)) | ||
- `scheduler_machines` (List of Object) Available scheduler sizes (see [below for nested schema](#nestedatt--scheduler_machines)) | ||
- `worker_machines` (List of Object) Available worker machine types (see [below for nested schema](#nestedatt--worker_machines)) | ||
- `worker_queues` (Attributes) Available worker queue options (see [below for nested schema](#nestedatt--worker_queues)) | ||
- `workload_identity_options` (List of Object) Available workload identity options (see [below for nested schema](#nestedatt--workload_identity_options)) | ||
|
||
<a id="nestedatt--resource_quotas"></a> | ||
### Nested Schema for `resource_quotas` | ||
|
||
Read-Only: | ||
|
||
- `default_pod_size` (Attributes) Default pod size options (see [below for nested schema](#nestedatt--resource_quotas--default_pod_size)) | ||
- `resource_quota` (Attributes) Resource quota options (see [below for nested schema](#nestedatt--resource_quotas--resource_quota)) | ||
|
||
<a id="nestedatt--resource_quotas--default_pod_size"></a> | ||
### Nested Schema for `resource_quotas.default_pod_size` | ||
|
||
Read-Only: | ||
|
||
- `cpu` (Attributes) CPU resource range (see [below for nested schema](#nestedatt--resource_quotas--default_pod_size--cpu)) | ||
- `memory` (Attributes) Memory resource range (see [below for nested schema](#nestedatt--resource_quotas--default_pod_size--memory)) | ||
|
||
<a id="nestedatt--resource_quotas--default_pod_size--cpu"></a> | ||
### Nested Schema for `resource_quotas.default_pod_size.cpu` | ||
|
||
Read-Only: | ||
|
||
- `ceiling` (String) Resource range ceiling | ||
- `default` (String) Resource range default | ||
- `floor` (String) Resource range floor | ||
|
||
|
||
<a id="nestedatt--resource_quotas--default_pod_size--memory"></a> | ||
### Nested Schema for `resource_quotas.default_pod_size.memory` | ||
|
||
Read-Only: | ||
|
||
- `ceiling` (String) Resource range ceiling | ||
- `default` (String) Resource range default | ||
- `floor` (String) Resource range floor | ||
|
||
|
||
|
||
<a id="nestedatt--resource_quotas--resource_quota"></a> | ||
### Nested Schema for `resource_quotas.resource_quota` | ||
|
||
Read-Only: | ||
|
||
- `cpu` (Attributes) CPU resource range (see [below for nested schema](#nestedatt--resource_quotas--resource_quota--cpu)) | ||
- `memory` (Attributes) Memory resource range (see [below for nested schema](#nestedatt--resource_quotas--resource_quota--memory)) | ||
|
||
<a id="nestedatt--resource_quotas--resource_quota--cpu"></a> | ||
### Nested Schema for `resource_quotas.resource_quota.cpu` | ||
|
||
Read-Only: | ||
|
||
- `ceiling` (String) Resource range ceiling | ||
- `default` (String) Resource range default | ||
- `floor` (String) Resource range floor | ||
|
||
|
||
<a id="nestedatt--resource_quotas--resource_quota--memory"></a> | ||
### Nested Schema for `resource_quotas.resource_quota.memory` | ||
|
||
Read-Only: | ||
|
||
- `ceiling` (String) Resource range ceiling | ||
- `default` (String) Resource range default | ||
- `floor` (String) Resource range floor | ||
|
||
|
||
|
||
|
||
<a id="nestedatt--runtime_releases"></a> | ||
### Nested Schema for `runtime_releases` | ||
|
||
Read-Only: | ||
|
||
- `airflow_database_migration` (Boolean) | ||
- `airflow_version` (String) | ||
- `channel` (String) | ||
- `release_date` (String) | ||
- `stellar_database_migration` (Boolean) | ||
- `version` (String) | ||
|
||
|
||
<a id="nestedatt--scheduler_machines"></a> | ||
### Nested Schema for `scheduler_machines` | ||
|
||
Read-Only: | ||
|
||
- `name` (String) | ||
- `spec` (Object) (see [below for nested schema](#nestedobjatt--scheduler_machines--spec)) | ||
|
||
<a id="nestedobjatt--scheduler_machines--spec"></a> | ||
### Nested Schema for `scheduler_machines.spec` | ||
|
||
Read-Only: | ||
|
||
- `concurrency` (String) | ||
- `cpu` (String) | ||
- `ephemeral_storage` (String) | ||
- `memory` (String) | ||
|
||
|
||
|
||
<a id="nestedatt--worker_machines"></a> | ||
### Nested Schema for `worker_machines` | ||
|
||
Read-Only: | ||
|
||
- `concurrency` (Object) (see [below for nested schema](#nestedobjatt--worker_machines--concurrency)) | ||
- `name` (String) | ||
- `spec` (Object) (see [below for nested schema](#nestedobjatt--worker_machines--spec)) | ||
|
||
<a id="nestedobjatt--worker_machines--concurrency"></a> | ||
### Nested Schema for `worker_machines.concurrency` | ||
|
||
Read-Only: | ||
|
||
- `ceiling` (String) | ||
- `default` (String) | ||
- `floor` (String) | ||
|
||
|
||
<a id="nestedobjatt--worker_machines--spec"></a> | ||
### Nested Schema for `worker_machines.spec` | ||
|
||
Read-Only: | ||
|
||
- `concurrency` (String) | ||
- `cpu` (String) | ||
- `ephemeral_storage` (String) | ||
- `memory` (String) | ||
|
||
|
||
|
||
<a id="nestedatt--worker_queues"></a> | ||
### Nested Schema for `worker_queues` | ||
|
||
Read-Only: | ||
|
||
- `max_workers` (Attributes) Worker queue maximum workers (see [below for nested schema](#nestedatt--worker_queues--max_workers)) | ||
- `min_workers` (Attributes) Worker queue minimum workers (see [below for nested schema](#nestedatt--worker_queues--min_workers)) | ||
- `worker_concurrency` (Attributes) Worker queue worker concurrency (see [below for nested schema](#nestedatt--worker_queues--worker_concurrency)) | ||
|
||
<a id="nestedatt--worker_queues--max_workers"></a> | ||
### Nested Schema for `worker_queues.max_workers` | ||
|
||
Read-Only: | ||
|
||
- `ceiling` (String) Resource range ceiling | ||
- `default` (String) Resource range default | ||
- `floor` (String) Resource range floor | ||
|
||
|
||
<a id="nestedatt--worker_queues--min_workers"></a> | ||
### Nested Schema for `worker_queues.min_workers` | ||
|
||
Read-Only: | ||
|
||
- `ceiling` (String) Resource range ceiling | ||
- `default` (String) Resource range default | ||
- `floor` (String) Resource range floor | ||
|
||
|
||
<a id="nestedatt--worker_queues--worker_concurrency"></a> | ||
### Nested Schema for `worker_queues.worker_concurrency` | ||
|
||
Read-Only: | ||
|
||
- `ceiling` (String) Resource range ceiling | ||
- `default` (String) Resource range default | ||
- `floor` (String) Resource range floor | ||
|
||
|
||
|
||
<a id="nestedatt--workload_identity_options"></a> | ||
### Nested Schema for `workload_identity_options` | ||
|
||
Read-Only: | ||
|
||
- `label` (String) | ||
- `role` (String) |
17 changes: 17 additions & 0 deletions
17
examples/data-sources/astronomer_deployment_options/data-source.tf
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,17 @@ | ||
data "astronomer_deployment_options" "example" {} | ||
|
||
data "astronomer_deployment_options" "example_with_deployment_id_query_param" { | ||
deployment_id = "clozc036j01to01jrlgvueo8t" | ||
} | ||
|
||
data "astronomer_deployment_options" "example_with_deployment_type_query_param" { | ||
deployment_type = "DEDICATED" | ||
} | ||
|
||
data "astronomer_deployment_options" "example_with_executor_query_param" { | ||
executor = "CELERY" | ||
} | ||
|
||
data "astronomer_deployment_options" "example_with_cloud_provider_query_param" { | ||
cloud_provider = "AWS" | ||
} |
136 changes: 136 additions & 0 deletions
136
internal/provider/datasources/data_source_deployment_options.go
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,136 @@ | ||
package datasources | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
|
||
"github.com/astronomer/astronomer-terraform-provider/internal/clients" | ||
"github.com/astronomer/astronomer-terraform-provider/internal/clients/platform" | ||
"github.com/astronomer/astronomer-terraform-provider/internal/provider/models" | ||
"github.com/astronomer/astronomer-terraform-provider/internal/provider/schemas" | ||
"github.com/astronomer/astronomer-terraform-provider/internal/utils" | ||
"github.com/hashicorp/terraform-plugin-framework/datasource" | ||
"github.com/hashicorp/terraform-plugin-framework/datasource/schema" | ||
"github.com/hashicorp/terraform-plugin-log/tflog" | ||
) | ||
|
||
// Ensure provider defined types fully satisfy framework interfaces. | ||
var _ datasource.DataSource = &deploymentOptionsDataSource{} | ||
var _ datasource.DataSourceWithConfigure = &deploymentOptionsDataSource{} | ||
|
||
func NewDeploymentOptionsDataSource() datasource.DataSource { | ||
return &deploymentOptionsDataSource{} | ||
} | ||
|
||
// deploymentOptionsDataSource defines the data source implementation. | ||
type deploymentOptionsDataSource struct { | ||
PlatformClient platform.ClientWithResponsesInterface | ||
OrganizationId string | ||
} | ||
|
||
func (d *deploymentOptionsDataSource) Metadata( | ||
ctx context.Context, | ||
req datasource.MetadataRequest, | ||
resp *datasource.MetadataResponse, | ||
) { | ||
resp.TypeName = req.ProviderTypeName + "_deployment_options" | ||
} | ||
|
||
func (d *deploymentOptionsDataSource) Schema( | ||
ctx context.Context, | ||
req datasource.SchemaRequest, | ||
resp *datasource.SchemaResponse, | ||
) { | ||
resp.Schema = schema.Schema{ | ||
// This description is used by the documentation generator and the language server. | ||
MarkdownDescription: "Deployment options data source", | ||
Attributes: schemas.DeploymentOptionsDataSourceSchemaAttributes(), | ||
} | ||
} | ||
|
||
func (d *deploymentOptionsDataSource) Configure( | ||
ctx context.Context, | ||
req datasource.ConfigureRequest, | ||
resp *datasource.ConfigureResponse, | ||
) { | ||
// Prevent panic if the provider has not been configured. | ||
if req.ProviderData == nil { | ||
return | ||
} | ||
|
||
apiClients, ok := req.ProviderData.(models.ApiClientsModel) | ||
if !ok { | ||
utils.DataSourceApiClientConfigureError(ctx, req, resp) | ||
return | ||
} | ||
|
||
d.PlatformClient = apiClients.PlatformClient | ||
d.OrganizationId = apiClients.OrganizationId | ||
} | ||
|
||
func (d *deploymentOptionsDataSource) Read( | ||
ctx context.Context, | ||
req datasource.ReadRequest, | ||
resp *datasource.ReadResponse, | ||
) { | ||
var data models.DeploymentOptions | ||
|
||
// Read Terraform configuration data into the model | ||
resp.Diagnostics.Append(req.Config.Get(ctx, &data)...) | ||
if resp.Diagnostics.HasError() { | ||
return | ||
} | ||
|
||
params := platform.GetDeploymentOptionsParams{} | ||
|
||
deploymentIdParam := data.DeploymentId.ValueString() | ||
if len(deploymentIdParam) > 0 { | ||
params.DeploymentId = &deploymentIdParam | ||
} | ||
deploymentTypeParam := data.DeploymentType.ValueString() | ||
if len(deploymentTypeParam) > 0 { | ||
params.DeploymentType = (*platform.GetDeploymentOptionsParamsDeploymentType)(&deploymentTypeParam) | ||
} | ||
executorParam := data.Executor.ValueString() | ||
if len(executorParam) > 0 { | ||
params.Executor = (*platform.GetDeploymentOptionsParamsExecutor)(&executorParam) | ||
} | ||
cloudProviderParam := data.CloudProvider.ValueString() | ||
if len(cloudProviderParam) > 0 { | ||
params.CloudProvider = (*platform.GetDeploymentOptionsParamsCloudProvider)(&cloudProviderParam) | ||
} | ||
|
||
options, err := d.PlatformClient.GetDeploymentOptionsWithResponse( | ||
ctx, | ||
d.OrganizationId, | ||
¶ms, | ||
) | ||
if err != nil { | ||
tflog.Error(ctx, "failed to get deployment options", map[string]interface{}{"error": err}) | ||
resp.Diagnostics.AddError( | ||
"Client Error", | ||
fmt.Sprintf("Unable to read deployment options, got error: %s", err), | ||
) | ||
return | ||
} | ||
_, diagnostic := clients.NormalizeAPIError(ctx, options.HTTPResponse, options.Body) | ||
if diagnostic != nil { | ||
resp.Diagnostics.Append(diagnostic) | ||
return | ||
} | ||
if options.JSON200 == nil { | ||
tflog.Error(ctx, "failed to get deployment options", map[string]interface{}{"error": "nil response"}) | ||
resp.Diagnostics.AddError("Client Error", "Unable to read deployment options, got nil response") | ||
return | ||
} | ||
|
||
// Populate the model with the response data | ||
diags := data.ReadFromResponse(ctx, options.JSON200) | ||
if diags.HasError() { | ||
resp.Diagnostics.Append(diags...) | ||
return | ||
} | ||
|
||
// Save data into Terraform state | ||
resp.Diagnostics.Append(resp.State.Set(ctx, &data)...) | ||
} |
Oops, something went wrong.