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

Nexus Endpoint resource #221

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
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
126 changes: 126 additions & 0 deletions docs/resources/nexus_endpoint.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
---
# generated by https://github.com/hashicorp/terraform-plugin-docs
page_title: "temporalcloud_nexus_endpoint Resource - terraform-provider-temporalcloud"
subcategory: ""
description: |-
Provisions a Temporal Cloud Nexus endpoint.
---

# temporalcloud_nexus_endpoint (Resource)

Provisions a Temporal Cloud Nexus endpoint.

## Example Usage

```terraform
terraform {
required_providers {
temporalcloud = {
source = "temporalio/temporalcloud"
}
}
}

resource "temporalcloud_namespace" "target_namespace" {
name = "terraform-target-namespace"
regions = ["aws-us-west-2"]
api_key_auth = true
retention_days = 14
timeouts {
create = "10m"
delete = "10m"
}
}

resource "temporalcloud_namespace" "caller_namespace" {
name = "terraform-caller-namespace"
regions = ["aws-us-east-1"]
api_key_auth = true
retention_days = 14
timeouts {
create = "10m"
delete = "10m"
}
}

resource "temporalcloud_namespace" "caller_namespace_2" {
name = "terraform-caller-namespace-2"
regions = ["gcp-us-central1"]
api_key_auth = true
retention_days = 14
timeouts {
create = "10m"
delete = "10m"
}
}

resource "temporalcloud_nexus_endpoint" "nexus_endpoint" {
name = "terraform-nexus-endpoint"
description = <<-EOT
Service Name:
my-hello-service
Operation Names:
echo
say-hello

Input / Output arguments are in the following repository:
https://github.com/temporalio/samples-go/blob/main/nexus/service/api.go
EOT
worker_target_spec = {
namespace_id = temporalcloud_namespace.target_namespace.id
task_queue = "terraform-task-queue"
}
allowed_caller_namespaces = [
temporalcloud_namespace.caller_namespace.id,
temporalcloud_namespace.caller_namespace_2.id,
]
}
```

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

### Required

- `allowed_caller_namespaces` (Set of String) Namespace(s) that are allowed to call this Endpoint.
- `name` (String) The name of the endpoint. Must be unique within an account and match `^[a-zA-Z][a-zA-Z0-9\-]*[a-zA-Z0-9]$`
- `worker_target_spec` (Attributes) A target spec for routing nexus requests to a specific cloud namespace worker. (see [below for nested schema](#nestedatt--worker_target_spec))

### Optional

- `description` (String, Sensitive) The description for the Nexus endpoint.
- `timeouts` (Block, Optional) (see [below for nested schema](#nestedblock--timeouts))

### Read-Only

- `id` (String) The unique identifier of the Nexus endpoint.

<a id="nestedatt--worker_target_spec"></a>
### Nested Schema for `worker_target_spec`

Required:

- `namespace_id` (String) The target cloud namespace to route requests to. Namespace must be in same account as the endpoint.
- `task_queue` (String) The task queue on the cloud namespace to route requests to.


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

Optional:

- `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).
- `delete` (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). Setting a timeout for a Delete operation is only applicable if changes are saved into state before the destroy operation occurs.

## Import

Import is supported using the following syntax:

```shell
# Nexus Endpoints can be imported to incorporate existing Nexus Endpoints into your Terraform pipeline.
# To import a Nexus Endpoint, you need
# - a resource configuration in your Terraform configuration file/module to accept the imported Nexus Endpoint. In the example below, the placeholder is "temporalcloud_nexus_endpoint" "nexus_endpoint"
# - the Nexus Endpoint's ID, which is found using the Temporal Cloud CLI tcld nexus endpoint list. In the example below, this is 405f7da4224a43d99c211904ed9b3819

terraform import temporalcloud_nexus_endpoint.nexus_endpoint 405f7da4224a43d99c211904ed9b3819
```
6 changes: 6 additions & 0 deletions examples/resources/temporalcloud_nexus_endpoint/import.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Nexus Endpoints can be imported to incorporate existing Nexus Endpoints into your Terraform pipeline.
# To import a Nexus Endpoint, you need
# - a resource configuration in your Terraform configuration file/module to accept the imported Nexus Endpoint. In the example below, the placeholder is "temporalcloud_nexus_endpoint" "nexus_endpoint"
# - the Nexus Endpoint's ID, which is found using the Temporal Cloud CLI tcld nexus endpoint list. In the example below, this is 405f7da4224a43d99c211904ed9b3819

terraform import temporalcloud_nexus_endpoint.nexus_endpoint 405f7da4224a43d99c211904ed9b3819
62 changes: 62 additions & 0 deletions examples/resources/temporalcloud_nexus_endpoint/resource.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
terraform {
required_providers {
temporalcloud = {
source = "temporalio/temporalcloud"
}
}
}

resource "temporalcloud_namespace" "target_namespace" {
name = "terraform-target-namespace"
regions = ["aws-us-west-2"]
api_key_auth = true
retention_days = 14
timeouts {
create = "10m"
delete = "10m"
}
}

resource "temporalcloud_namespace" "caller_namespace" {
name = "terraform-caller-namespace"
regions = ["aws-us-east-1"]
api_key_auth = true
retention_days = 14
timeouts {
create = "10m"
delete = "10m"
}
}

resource "temporalcloud_namespace" "caller_namespace_2" {
name = "terraform-caller-namespace-2"
regions = ["gcp-us-central1"]
api_key_auth = true
retention_days = 14
timeouts {
create = "10m"
delete = "10m"
}
}

resource "temporalcloud_nexus_endpoint" "nexus_endpoint" {
name = "terraform-nexus-endpoint"
description = <<-EOT
Service Name:
my-hello-service
Operation Names:
echo
say-hello

Input / Output arguments are in the following repository:
https://github.com/temporalio/samples-go/blob/main/nexus/service/api.go
EOT
worker_target_spec = {
namespace_id = temporalcloud_namespace.target_namespace.id
task_queue = "terraform-task-queue"
}
allowed_caller_namespaces = [
temporalcloud_namespace.caller_namespace.id,
temporalcloud_namespace.caller_namespace_2.id,
]
Comment on lines +54 to +61
Copy link
Member

Choose a reason for hiding this comment

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

This is fine but I'm wondering if it'd be better to make the API a little more future-proof. Here's an example:

target = {
  type = "worker"
  namespace_id = temporalcloud_namespace.target_namespace.id
  task_queue   = "terraform-task-queue"
}

allowed_callers = [
  {
    type = "namespace"
    namespace_id = "..."
  }
]

But what you have is probably better for type safety.
Let's keep it as is.

}
Loading
Loading