Skip to content

Commit

Permalink
GCLOUD2-17301 - sqs triggers (#181)
Browse files Browse the repository at this point in the history
* GCLOUD2-17301 - sqs triggers
  • Loading branch information
alexk53 authored Feb 10, 2025
1 parent 96a8008 commit 84b401a
Show file tree
Hide file tree
Showing 15 changed files with 628 additions and 124 deletions.
62 changes: 31 additions & 31 deletions docs/resources/baremetal.md
Original file line number Diff line number Diff line change
Expand Up @@ -236,64 +236,64 @@ resource "gcore_baremetal" "baremetal_windows_with_userdata" {

### Required

- `flavor_id` (String)
- `flavor_id` (String) The ID of the flavor (type of server configuration). This field is required. Example: 'bm1-hf-medium-4x1nic'
- `interface` (Block List, Min: 1) (see [below for nested schema](#nestedblock--interface))

### Optional

- `app_config` (Map of String)
- `apptemplate_id` (String)
- `image_id` (String)
- `keypair_name` (String)
- `last_updated` (String)
- `app_config` (Map of String) Parameters for the application template from the marketplace. This could include parameters required for app setup. Example: {'shadowsocks_method': 'chacha20-ietf-poly1305', 'shadowsocks_password': '123'}
- `apptemplate_id` (String) The ID of the application template to use. Provide either 'apptemplate_id' or 'image_id', but not both
- `image_id` (String) The ID of the image to use. The image will be used to provision the bare metal server. Provide either 'image_id' or 'apptemplate_id', but not both
- `keypair_name` (String) The name of the SSH keypair to use for the baremetal
- `last_updated` (String) The date and time when the baremetal server was last updated
- `metadata` (Block List, Deprecated) (see [below for nested schema](#nestedblock--metadata))
- `metadata_map` (Map of String)
- `name` (String)
- `name_template` (String)
- `name_templates` (List of String, Deprecated)
- `password` (String)
- `project_id` (Number)
- `project_name` (String)
- `region_id` (Number)
- `region_name` (String)
- `metadata_map` (Map of String) A map of metadata items. Key-value pairs for instance metadata. Example: {'environment': 'production', 'owner': 'user'}
- `name` (String) The name of the baremetal server. If not provided, it will be generated automatically. Example: 'bm-server-01'
- `name_template` (String) The template used to generate server names. You can use forms 'ip_octets', 'two_ip_octets', 'one_ip_octet'. Example: 'server-${ip_octets}'
- `name_templates` (List of String, Deprecated) Deprecated. List of baremetal names which will be changed by template
- `password` (String) The password for accessing the baremetal server. This parameter is used to set a password for the 'Admin' user on a Windows instance, a default user or a new user on a Linux instance
- `project_id` (Number) Project ID, only one of project_id or project_name should be set
- `project_name` (String) Project name, only one of project_id or project_name should be set
- `region_id` (Number) Region ID, only one of region_id or region_name should be set
- `region_name` (String) Region name, only one of region_id or region_name should be set
- `timeouts` (Block, Optional) (see [below for nested schema](#nestedblock--timeouts))
- `user_data` (String)
- `username` (String)
- `user_data` (String) User data string in base64 format. This is passed to the instance at launch. For Linux instances, 'user_data' is ignored when 'password' field is provided. For Windows instances, Admin user password is set by 'password' field and cannot be updated via 'user_data'
- `username` (String) A name of a new user in the Linux instance. It may be passed with a 'password' parameter

### Read-Only

- `addresses` (List of Object) (see [below for nested schema](#nestedatt--addresses))
- `flavor` (Map of String)
- `flavor` (Map of String) Details about the flavor (server configuration) including RAM, vCPU, etc.
- `id` (String) The ID of this resource.
- `status` (String)
- `vm_state` (String)
- `status` (String) The current status of the baremetal server.
- `vm_state` (String) The state of the virtual machine

<a id="nestedblock--interface"></a>
### Nested Schema for `interface`

Required:

- `type` (String) Available value is 'subnet', 'any_subnet', 'external', 'reserved_fixed_ip'
- `type` (String) The type of the network interface. Available value is 'subnet', 'any_subnet', 'external', 'reserved_fixed_ip'

Optional:

- `existing_fip_id` (String)
- `fip_source` (String)
- `ip_address` (String)
- `is_parent` (Boolean) If not set will be calculated after creation. Trunk interface always attached first. Can't detach interface if is_parent true. Fields affect only on creation
- `network_id` (String) required if type is 'subnet' or 'any_subnet'
- `order` (Number) Order of attaching interface. Trunk interface always attached first, fields affect only on creation
- `port_id` (String) required if type is 'reserved_fixed_ip'
- `subnet_id` (String) required if type is 'subnet'
- `existing_fip_id` (String) The ID of the existing floating IP that will be attached to the interface
- `fip_source` (String) The source of floating IP. Can be 'new' or 'existing'
- `ip_address` (String) The IP address for the interface
- `is_parent` (Boolean) Indicates whether this interface is the parent. If not set will be calculated after creation. Trunk interface always attached first. Can't detach interface if is_parent true. Fields affect only on creation
- `network_id` (String) The network ID to attach the interface to. Required if type is 'subnet' or 'any_subnet'
- `order` (Number) Order of attaching interface. Trunk (parent) interface always attached first, fields affect only on creation
- `port_id` (String) The port ID for reserved fixed IP. Required if type is 'reserved_fixed_ip'
- `subnet_id` (String) The subnet ID to attach the interface to. Required if type is 'subnet'


<a id="nestedblock--metadata"></a>
### Nested Schema for `metadata`

Required:

- `key` (String)
- `value` (String)
- `key` (String) Metadata key
- `value` (String) Metadata value


<a id="nestedblock--timeouts"></a>
Expand Down
79 changes: 67 additions & 12 deletions docs/resources/inference_deployment.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,52 @@ resource "gcore_inference_deployment" "inf" {
}
```

#### Creating inference deployment with sqs trigger

```terraform
resource "gcore_inference_secret" "aws" {
project_id = data.gcore_project.project.id
name = "my-aws-iam-secret"
data_aws_access_key_id = "my-aws-access-key-id"
data_aws_secret_access_key = "my-aws-access-key"
}
resource "gcore_inference_deployment" "inf" {
project_id = data.gcore_project.project.id
name = "my-inference-deployment"
image = "nginx:latest"
listening_port = 80
flavor_name = "inference-1vcpu-1gib"
timeout = 60
containers {
region_id = data.gcore_region.region.id
cooldown_period = 60
polling_interval = 60
scale_min = 0
scale_max = 2
triggers_cpu_threshold = 80
triggers_sqs_secret_name = gcore_inference_secret.aws.name
triggers_sqs_aws_region = "us-west-2"
triggers_sqs_queue_url = "https://sqs.us-west-2.amazonaws.com/1234567890/my-queue"
triggers_sqs_queue_length = 5
triggers_sqs_activation_queue_length = 2
}
liveness_probe {
enabled = false
}
readiness_probe {
enabled = false
}
startup_probe {
enabled = false
}
}
```

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

Expand Down Expand Up @@ -110,24 +156,33 @@ resource "gcore_inference_deployment" "inf" {

Required:

- `cooldown_period` (Number)
- `region_id` (Number)
- `scale_max` (Number)
- `scale_min` (Number)
- `cooldown_period` (Number) Cooldown period between scaling actions in seconds
- `region_id` (Number) Region id for the container
- `scale_max` (Number) Maximum scale for the container
- `scale_min` (Number) Minimum scale for the container

Optional:

- `triggers_cpu_threshold` (Number)
- `triggers_gpu_memory_threshold` (Number)
- `triggers_gpu_utilization_threshold` (Number)
- `triggers_http_rate` (Number)
- `triggers_http_window` (Number)
- `triggers_memory_threshold` (Number)
- `polling_interval` (Number) Polling interval for scaling triggers in seconds
- `triggers_cpu_threshold` (Number) CPU trigger threshold configuration
- `triggers_gpu_memory_threshold` (Number) GPU memory trigger threshold configuration. Calculated by DCGM_FI_DEV_MEM_COPY_UTIL metric
- `triggers_gpu_utilization_threshold` (Number) GPU utilization trigger threshold configuration. Calculated by DCGM_FI_DEV_GPU_UTIL metric
- `triggers_http_rate` (Number) Request count per 'window' seconds for the http trigger. Required if you use http trigger
- `triggers_http_window` (Number) Time window for rate calculation in seconds. Required if you use http trigger
- `triggers_memory_threshold` (Number) Memory trigger threshold configuration
- `triggers_sqs_activation_queue_length` (Number) Number of messages for activation
- `triggers_sqs_aws_endpoint` (String) Custom AWS endpoint, left empty to use default aws endpoint
- `triggers_sqs_aws_region` (String) AWS region. Required if you use SQS trigger
- `triggers_sqs_queue_length` (Number) Number of messages for one replica
- `triggers_sqs_queue_url` (String) URL of the SQS queue. Required if you use SQS trigger
- `triggers_sqs_scale_on_delayed` (Boolean) Scale on delayed messages
- `triggers_sqs_scale_on_flight` (Boolean) Scale on in-flight messages
- `triggers_sqs_secret_name` (String) Name of the secret with AWS credentials. Required if you use SQS trigger

Read-Only:

- `ready_containers` (Number)
- `total_containers` (Number)
- `ready_containers` (Number) Status of the containers deployment. Number of ready instances
- `total_containers` (Number) Status of the containers deployment. Total number of instances


<a id="nestedblock--liveness_probe"></a>
Expand Down
58 changes: 58 additions & 0 deletions docs/resources/inference_secret.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
---
# generated by https://github.com/hashicorp/terraform-plugin-docs
page_title: "gcore_inference_secret Resource - terraform-provider-gcore"
subcategory: ""
description: |-
Represent inference secret
---

# gcore_inference_secret (Resource)

Represent inference secret

## Example Usage

```terraform
provider gcore {
permanent_api_token = "251$d3361.............1b35f26d8"
}
data "gcore_project" "project" {
name = "Default"
}
resource "gcore_inference_secret" "aws" {
project_id = data.gcore_project.project.id
name = "my-aws-iam-secret"
data_aws_access_key_id = "my-aws-access-key-id"
data_aws_secret_access_key = "my-aws-access-key"
}
```

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

### Required

- `data_aws_access_key_id` (String)
- `data_aws_secret_access_key` (String)
- `name` (String)

### Optional

- `project_id` (Number)
- `project_name` (String)

### Read-Only

- `id` (String) The ID of this resource.
- `type` (String)

## Import

Import is supported using the following syntax:

```shell
# import using <project_id>:<secret_name> format
terraform import gcore_inference_secret.aws 1:my-secret-name
```
17 changes: 12 additions & 5 deletions docs/resources/registry_credential.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,19 @@ Represent inference registry credential
## Example Usage

```terraform
provider gcore {
permanent_api_token = "251$d3361.............1b35f26d8"
}
data "gcore_project" "project" {
name = "Default"
}
resource "gcore_registry_credential" "creds" {
project_id = 184550
name = "docker-io"
username = "username"
password = "passwd"
registry_url = "docker.io"
name = "docker-io"
username = "username"
password = "passwd"
registry_url = "docker.io"
}
```

Expand Down
41 changes: 41 additions & 0 deletions examples/resources/gcore_inference_deployment/with-sqs-trigger.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
resource "gcore_inference_secret" "aws" {
project_id = data.gcore_project.project.id
name = "my-aws-iam-secret"
data_aws_access_key_id = "my-aws-access-key-id"
data_aws_secret_access_key = "my-aws-access-key"
}

resource "gcore_inference_deployment" "inf" {
project_id = data.gcore_project.project.id
name = "my-inference-deployment"
image = "nginx:latest"
listening_port = 80
flavor_name = "inference-1vcpu-1gib"
timeout = 60
containers {
region_id = data.gcore_region.region.id
cooldown_period = 60
polling_interval = 60
scale_min = 0
scale_max = 2
triggers_cpu_threshold = 80

triggers_sqs_secret_name = gcore_inference_secret.aws.name
triggers_sqs_aws_region = "us-west-2"
triggers_sqs_queue_url = "https://sqs.us-west-2.amazonaws.com/1234567890/my-queue"
triggers_sqs_queue_length = 5
triggers_sqs_activation_queue_length = 2
}

liveness_probe {
enabled = false
}

readiness_probe {
enabled = false
}

startup_probe {
enabled = false
}
}
2 changes: 2 additions & 0 deletions examples/resources/gcore_inference_secret/import.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# import using <project_id>:<secret_name> format
terraform import gcore_inference_secret.aws 1:my-secret-name
14 changes: 14 additions & 0 deletions examples/resources/gcore_inference_secret/resource.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
provider gcore {
permanent_api_token = "251$d3361.............1b35f26d8"
}

data "gcore_project" "project" {
name = "Default"
}

resource "gcore_inference_secret" "aws" {
project_id = data.gcore_project.project.id
name = "my-aws-iam-secret"
data_aws_access_key_id = "my-aws-access-key-id"
data_aws_secret_access_key = "my-aws-access-key"
}
17 changes: 12 additions & 5 deletions examples/resources/gcore_registry_credential/resource.tf
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
provider gcore {
permanent_api_token = "251$d3361.............1b35f26d8"
}

data "gcore_project" "project" {
name = "Default"
}

resource "gcore_registry_credential" "creds" {
project_id = 184550
name = "docker-io"
username = "username"
password = "passwd"
registry_url = "docker.io"
name = "docker-io"
username = "username"
password = "passwd"
registry_url = "docker.io"
}
1 change: 1 addition & 0 deletions gcore/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ func Provider() *schema.Provider {
lifecyclePolicyResource: resourceLifecyclePolicy(),
"gcore_ddos_protection": resourceDDoSProtection(),
"gcore_inference_deployment": resourceInferenceDeployment(),
"gcore_inference_secret": resourceInferenceSecrets(),
"gcore_registry_credential": resourceRegistryCredential(),
},
DataSourcesMap: map[string]*schema.Resource{
Expand Down
Loading

0 comments on commit 84b401a

Please sign in to comment.