Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add original astro runtime version to deployment resource creation #58

Merged
merged 16 commits into from
May 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ OAPI_CODEGEN ?= $(ENVTEST_ASSETS_DIR)/oapi-codegen
# Run acceptance tests
.PHONY: testacc
testacc:
TF_ACC=1 go test ./... -v -run TestAcc $(TESTARGS) -timeout 120m
TF_ACC=1 go test ./... -v -run TestAcc $(TESTARGS) -timeout 180m

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just curious about the increase here, is this due to the resource tests being added?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Screenshot 2024-05-14 at 10 21 02 PM
Seems like the tests take 2.5 hours to run (and pass) so I upped it


# Run unit tests
.PHONY: test
Expand Down
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ make build
## Adding Dependencies

This provider uses [Go modules](https://github.com/golang/go/wiki/Modules).
Please see the Go documentation for the most up to date information about using Go modules.
Please see the Go documentation for the most up-to-date information about using Go modules.

To add a new dependency `github.com/author/dependency` to your Terraform provider:

Expand Down Expand Up @@ -90,7 +90,6 @@ terraform {
# provider configuration
provider "astro" {
organization_id = "<cuid>"
host = "https://api.astronomer-dev.io"
}

# get information on an existing workspace
Expand Down
4 changes: 2 additions & 2 deletions docs/resources/cluster.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
page_title: "astro_cluster Resource - astro"
subcategory: ""
description: |-
Cluster resource
Cluster resource. If creating multiple clusters, add a delay between each cluster creation to avoid cluster creation limiting errors.
---

# astro_cluster (Resource)

Cluster resource
Cluster resource. If creating multiple clusters, add a delay between each cluster creation to avoid cluster creation limiting errors.

## Example Usage

Expand Down
98 changes: 51 additions & 47 deletions docs/resources/deployment.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,23 @@ Deployment resource

```terraform
resource "astro_deployment" "dedicated" {
name = "my dedicated deployment"
description = "an example deployment"
type = "DEDICATED"
cluster_id = "clv17vgft000801kkydsws63x"
contact_emails = ["[email protected]"]
default_task_pod_cpu = "0.25"
default_task_pod_memory = "0.5Gi"
executor = "KUBERNETES"
is_cicd_enforced = true
is_dag_deploy_enabled = true
is_development_mode = false
is_high_availability = true
resource_quota_cpu = "10"
resource_quota_memory = "20Gi"
scheduler_size = "SMALL"
workspace_id = "clnp86ly5000401ndaga21g81"
original_astro_runtime_version = "11.3.0"
name = "my dedicated deployment"
description = "an example deployment"
type = "DEDICATED"
cluster_id = "clv17vgft000801kkydsws63x"
contact_emails = ["[email protected]"]
default_task_pod_cpu = "0.25"
default_task_pod_memory = "0.5Gi"
executor = "KUBERNETES"
is_cicd_enforced = true
is_dag_deploy_enabled = true
is_development_mode = false
is_high_availability = true
resource_quota_cpu = "10"
resource_quota_memory = "20Gi"
scheduler_size = "SMALL"
workspace_id = "clnp86ly5000401ndaga21g81"
environment_variables = [{
key = "key1"
value = "value1"
Expand All @@ -38,24 +39,25 @@ resource "astro_deployment" "dedicated" {
}

resource "astro_deployment" "standard" {
name = "my standard deployment"
description = "an example deployment"
type = "STANDARD"
cloud_provider = "AWS"
region = "us-east-1"
contact_emails = []
default_task_pod_cpu = "0.25"
default_task_pod_memory = "0.5Gi"
executor = "CELERY"
is_cicd_enforced = true
is_dag_deploy_enabled = true
is_development_mode = false
is_high_availability = false
resource_quota_cpu = "10"
resource_quota_memory = "20Gi"
scheduler_size = "SMALL"
workspace_id = "clnp86ly500a401ndaga20g81"
environment_variables = []
original_astro_runtime_version = "11.3.0"
name = "my standard deployment"
description = "an example deployment"
type = "STANDARD"
cloud_provider = "AWS"
region = "us-east-1"
contact_emails = []
default_task_pod_cpu = "0.25"
default_task_pod_memory = "0.5Gi"
executor = "CELERY"
is_cicd_enforced = true
is_dag_deploy_enabled = true
is_development_mode = false
is_high_availability = false
resource_quota_cpu = "10"
resource_quota_memory = "20Gi"
scheduler_size = "SMALL"
workspace_id = "clnp86ly500a401ndaga20g81"
environment_variables = []
worker_queues = [{
name = "default"
is_default = true
Expand All @@ -67,18 +69,19 @@ resource "astro_deployment" "standard" {
}

resource "astro_deployment" "hybrid" {
name = "my hybrid deployment"
description = "an example deployment"
type = "HYBRID"
cluster_id = "clnp86ly5000401ndagu20g81"
task_pod_node_pool_id = "clnp86ly5000301ndzfxz895w"
contact_emails = ["[email protected]"]
executor = "KUBERNETES"
is_cicd_enforced = true
is_dag_deploy_enabled = true
scheduler_replicas = 1
scheduler_au = 5
workspace_id = "clnp86ly5000401ndaga20g81"
original_astro_runtime_version = "11.3.0"
name = "my hybrid deployment"
description = "an example deployment"
type = "HYBRID"
cluster_id = "clnp86ly5000401ndagu20g81"
task_pod_node_pool_id = "clnp86ly5000301ndzfxz895w"
contact_emails = ["[email protected]"]
executor = "KUBERNETES"
is_cicd_enforced = true
is_dag_deploy_enabled = true
scheduler_replicas = 1
scheduler_au = 5
workspace_id = "clnp86ly5000401ndaga20g81"
environment_variables = [{
key = "key1"
value = "value1"
Expand Down Expand Up @@ -110,6 +113,7 @@ resource "astro_deployment" "hybrid" {
- `default_task_pod_memory` (String) Deployment default task pod memory - required for 'STANDARD' and 'DEDICATED' deployments
- `is_development_mode` (Boolean) Deployment development mode - required for 'STANDARD' and 'DEDICATED' deployments. If changing from 'False' to 'True', the deployment will be recreated
- `is_high_availability` (Boolean) Deployment high availability - required for 'STANDARD' and 'DEDICATED' deployments
- `original_astro_runtime_version` (String) Deployment's original Astro Runtime version. The Terraform provider will use this provided Astro runtime version to create the Deployment. The Astro runtime version can be updated with your Astro project Dockerfile, but if this value is changed, the Deployment will be recreated with this new Astro runtime version.
- `region` (String) Deployment region - required for 'STANDARD' deployments. If changing this value, the deployment will be recreated in the new region
- `resource_quota_cpu` (String) Deployment resource quota CPU - required for 'STANDARD' and 'DEDICATED' deployments
- `resource_quota_memory` (String) Deployment resource quota memory - required for 'STANDARD' and 'DEDICATED' deployments
Expand All @@ -123,7 +127,7 @@ resource "astro_deployment" "hybrid" {
### Read-Only

- `airflow_version` (String) Deployment Airflow version
- `astro_runtime_version` (String) Deployment Astro Runtime version. The terraform provider will use the latest Astro runtime version for the Deployment. The Astro runtime version can be updated with your Astro project Dockerfile
- `astro_runtime_version` (String) Deployment's current Astro Runtime version
- `created_at` (String) Deployment creation timestamp
- `created_by` (Attributes) Deployment creator (see [below for nested schema](#nestedatt--created_by))
- `dag_tarball_version` (String) Deployment DAG tarball version
Expand Down
95 changes: 49 additions & 46 deletions examples/resources/astro_deployment/resource.tf
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
resource "astro_deployment" "dedicated" {
name = "my dedicated deployment"
description = "an example deployment"
type = "DEDICATED"
cluster_id = "clv17vgft000801kkydsws63x"
contact_emails = ["[email protected]"]
default_task_pod_cpu = "0.25"
default_task_pod_memory = "0.5Gi"
executor = "KUBERNETES"
is_cicd_enforced = true
is_dag_deploy_enabled = true
is_development_mode = false
is_high_availability = true
resource_quota_cpu = "10"
resource_quota_memory = "20Gi"
scheduler_size = "SMALL"
workspace_id = "clnp86ly5000401ndaga21g81"
original_astro_runtime_version = "11.3.0"
name = "my dedicated deployment"
description = "an example deployment"
type = "DEDICATED"
cluster_id = "clv17vgft000801kkydsws63x"
contact_emails = ["[email protected]"]
default_task_pod_cpu = "0.25"
default_task_pod_memory = "0.5Gi"
executor = "KUBERNETES"
is_cicd_enforced = true
is_dag_deploy_enabled = true
is_development_mode = false
is_high_availability = true
resource_quota_cpu = "10"
resource_quota_memory = "20Gi"
scheduler_size = "SMALL"
workspace_id = "clnp86ly5000401ndaga21g81"
environment_variables = [{
key = "key1"
value = "value1"
Expand All @@ -23,24 +24,25 @@ resource "astro_deployment" "dedicated" {
}

resource "astro_deployment" "standard" {
name = "my standard deployment"
description = "an example deployment"
type = "STANDARD"
cloud_provider = "AWS"
region = "us-east-1"
contact_emails = []
default_task_pod_cpu = "0.25"
default_task_pod_memory = "0.5Gi"
executor = "CELERY"
is_cicd_enforced = true
is_dag_deploy_enabled = true
is_development_mode = false
is_high_availability = false
resource_quota_cpu = "10"
resource_quota_memory = "20Gi"
scheduler_size = "SMALL"
workspace_id = "clnp86ly500a401ndaga20g81"
environment_variables = []
original_astro_runtime_version = "11.3.0"
name = "my standard deployment"
description = "an example deployment"
type = "STANDARD"
cloud_provider = "AWS"
region = "us-east-1"
contact_emails = []
default_task_pod_cpu = "0.25"
default_task_pod_memory = "0.5Gi"
executor = "CELERY"
is_cicd_enforced = true
is_dag_deploy_enabled = true
is_development_mode = false
is_high_availability = false
resource_quota_cpu = "10"
resource_quota_memory = "20Gi"
scheduler_size = "SMALL"
workspace_id = "clnp86ly500a401ndaga20g81"
environment_variables = []
worker_queues = [{
name = "default"
is_default = true
Expand All @@ -52,18 +54,19 @@ resource "astro_deployment" "standard" {
}

resource "astro_deployment" "hybrid" {
name = "my hybrid deployment"
description = "an example deployment"
type = "HYBRID"
cluster_id = "clnp86ly5000401ndagu20g81"
task_pod_node_pool_id = "clnp86ly5000301ndzfxz895w"
contact_emails = ["[email protected]"]
executor = "KUBERNETES"
is_cicd_enforced = true
is_dag_deploy_enabled = true
scheduler_replicas = 1
scheduler_au = 5
workspace_id = "clnp86ly5000401ndaga20g81"
original_astro_runtime_version = "11.3.0"
name = "my hybrid deployment"
description = "an example deployment"
type = "HYBRID"
cluster_id = "clnp86ly5000401ndagu20g81"
task_pod_node_pool_id = "clnp86ly5000301ndzfxz895w"
contact_emails = ["[email protected]"]
executor = "KUBERNETES"
is_cicd_enforced = true
is_dag_deploy_enabled = true
scheduler_replicas = 1
scheduler_au = 5
workspace_id = "clnp86ly5000401ndaga20g81"
environment_variables = [{
key = "key1"
value = "value1"
Expand Down
4 changes: 2 additions & 2 deletions internal/provider/datasources/data_source_deployment.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ func (d *deploymentDataSource) Read(
req datasource.ReadRequest,
resp *datasource.ReadResponse,
) {
var data models.Deployment
var data models.DeploymentDataSource

// Read Terraform configuration data into the model
resp.Diagnostics.Append(req.Config.Get(ctx, &data)...)
Expand Down Expand Up @@ -106,7 +106,7 @@ func (d *deploymentDataSource) Read(
}

// Populate the model with the response data
diags := data.ReadFromResponse(ctx, deployment.JSON200, false)
diags := data.ReadFromResponse(ctx, deployment.JSON200)
if diags.HasError() {
resp.Diagnostics.Append(diags...)
return
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,10 @@ resource "astro_workspace" "test_workspace" {
cicd_enforced_default = true
}

data "astro_deployment_options" "deployment_options" {}

resource "astro_deployment" "test_deployment_kubernetes" {
original_astro_runtime_version = tolist(data.astro_deployment_options.deployment_options.runtime_releases)[0].version
name = "%v-1"
description = "%v"
type = "STANDARD"
Expand All @@ -143,6 +146,7 @@ resource "astro_deployment" "test_deployment_kubernetes" {
}

resource "astro_deployment" "test_deployment_celery" {
original_astro_runtime_version = tolist(data.astro_deployment_options.deployment_options.runtime_releases)[0].version
name = "%v-2"
description = "%v"
type = "STANDARD"
Expand Down
Loading