Skip to content

Commit

Permalink
Implement connection and subscription resources for jira and slack. (#…
Browse files Browse the repository at this point in the history
…1116)

Implement connection and subscription resources for jira and slack.
  • Loading branch information
trentdibacco authored Oct 15, 2024
1 parent cd7cff2 commit b52e294
Show file tree
Hide file tree
Showing 26 changed files with 1,715 additions and 7 deletions.
7 changes: 7 additions & 0 deletions .changelog/1116.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
```release-note:feature
Add preview of the following Vault Radar connections and subscriptions:
hcp_vault_radar_integration_jira_connection
hcp_vault_radar_integration_jira_subscription
hcp_vault_radar_integration_slack_connection
hcp_vault_radar_integration_slack_subscription
```
47 changes: 47 additions & 0 deletions docs/resources/vault_radar_integration_jira_connection.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
---
page_title: "hcp_vault_radar_integration_jira_connection Resource - terraform-provider-hcp"
subcategory: ""
description: |-
This terraform resource manages an Integration Jira Connection in Vault Radar.
---

# hcp_vault_radar_integration_jira_connection (Resource)

-> **Note:** HCP Vault Radar Terraform resources are in preview.

This terraform resource manages an Integration Jira Connection in Vault Radar.

## Example Usage

```terraform
variable "jira_token" {
type = string
sensitive = true
}
resource "hcp_vault_radar_integration_jira_connection" "jira_connection" {
name = "example connection to jira"
email = "[email protected]"
token = var.jira_token
base_url = "https://example.atlassian.net"
}
```


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

### Required

- `base_url` (String) The Jira base URL. Example: https://acme.atlassian.net
- `email` (String, Sensitive) Jira user's email.
- `name` (String) Name of connection. Name must be unique.
- `token` (String, Sensitive) A Jira API token.

### Optional

- `project_id` (String) The ID of the HCP project where Vault Radar is located. If not specified, the project specified in the HCP Provider config block will be used, if configured.

### Read-Only

- `id` (String) The ID of this resource.
59 changes: 59 additions & 0 deletions docs/resources/vault_radar_integration_jira_subscription.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
---
page_title: "hcp_vault_radar_integration_jira_subscription Resource - terraform-provider-hcp"
subcategory: ""
description: |-
This terraform resource manages an Integration Jira Subscription in Vault Radar.
---

# hcp_vault_radar_integration_jira_subscription (Resource)

-> **Note:** HCP Vault Radar Terraform resources are in preview.

This terraform resource manages an Integration Jira Subscription in Vault Radar.

## Example Usage

```terraform
variable "jira_token" {
type = string
sensitive = true
}
# A Jira subscription requires a Jira connection.
resource "hcp_vault_radar_integration_jira_connection" "jira_connection" {
name = "example integration jira connection"
email = "[email protected]"
token = var.jira_token
base_url = "https://example.atlassian.net"
}
resource "hcp_vault_radar_integration_jira_subscription" "jira_subscription" {
name = "example integration jira subscription"
connection_id = hcp_vault_radar_integration_jira_connection.jira_connection.id
jira_project_key = "SEC"
issue_type = "Task"
assignee = "71509:11bb945b-c0de-4bac-9d57-9f09db2f7bc9"
message = "Example message"
}
```


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

### Required

- `connection_id` (String) id of the integration jira connection to use for the subscription.
- `issue_type` (String) The type of issue to be created from the event(s). Example: Task
- `jira_project_key` (String) The name of the project under which the jira issue will be created. Example: OPS
- `name` (String) Name of subscription. Name must be unique.

### Optional

- `assignee` (String) The identifier of the Jira user who will be assigned the ticket. In case of Jira Cloud, this will be the Atlassian Account ID of the user. Example: 71509:11bb945b-c0de-4bac-9d57-9f09db2f7bc9
- `message` (String) This message will be included in the ticket description.
- `project_id` (String) The ID of the HCP project where Vault Radar is located. If not specified, the project specified in the HCP Provider config block will be used, if configured.

### Read-Only

- `id` (String) The ID of this resource.
43 changes: 43 additions & 0 deletions docs/resources/vault_radar_integration_slack_connection.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
---
page_title: "hcp_vault_radar_integration_slack_connection Resource - terraform-provider-hcp"
subcategory: ""
description: |-
This terraform resource manages an Integration Slack Connection in Vault Radar.
---

# hcp_vault_radar_integration_slack_connection (Resource)

-> **Note:** HCP Vault Radar Terraform resources are in preview.

This terraform resource manages an Integration Slack Connection in Vault Radar.

## Example Usage

```terraform
variable "slack_token" {
type = string
sensitive = true
}
resource "hcp_vault_radar_integration_slack_connection" "slack_connection" {
name = "example connection to slack"
token = var.slack_token
}
```


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

### Required

- `name` (String) Name of connection. Name must be unique.
- `token` (String, Sensitive) Slack bot user OAuth token. Example: Bot token strings begin with 'xoxb'.

### Optional

- `project_id` (String) The ID of the HCP project where Vault Radar is located. If not specified, the project specified in the HCP Provider config block will be used, if configured.

### Read-Only

- `id` (String) The ID of this resource.
51 changes: 51 additions & 0 deletions docs/resources/vault_radar_integration_slack_subscription.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
---
page_title: "hcp_vault_radar_integration_slack_subscription Resource - terraform-provider-hcp"
subcategory: ""
description: |-
This terraform resource manages an Integration Slack Subscription in Vault Radar.
---

# hcp_vault_radar_integration_slack_subscription (Resource)

-> **Note:** HCP Vault Radar Terraform resources are in preview.

This terraform resource manages an Integration Slack Subscription in Vault Radar.

## Example Usage

```terraform
variable "slack_token" {
type = string
sensitive = true
}
# A Slack subscription requires a Slack connection.
resource "hcp_vault_radar_integration_slack_connection" "slack_connection" {
name = "example connection to slack"
token = var.slack_token
}
resource "hcp_vault_radar_integration_slack_subscription" "slack_subscription" {
name = "example integration slack subscription"
connection_id = hcp_vault_radar_integration_slack_connection.slack_connection.id
channel = "sec-ops-team"
}
```


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

### Required

- `channel` (String) Name of the Slack channel that messages should be sent to. Note that HashiCorp Vault Radar will send a test message to verify the channel. Example: dev-ops-team
- `connection_id` (String) id of the integration slack connection to use for the subscription.
- `name` (String) Name of subscription. Name must be unique.

### Optional

- `project_id` (String) The ID of the HCP project where Vault Radar is located. If not specified, the project specified in the HCP Provider config block will be used, if configured.

### Read-Only

- `id` (String) The ID of this resource.
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
variable "jira_token" {
type = string
sensitive = true
}

resource "hcp_vault_radar_integration_jira_connection" "jira_connection" {
name = "example connection to jira"
email = "[email protected]"
token = var.jira_token
base_url = "https://example.atlassian.net"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
variable "jira_token" {
type = string
sensitive = true
}

# A Jira subscription requires a Jira connection.
resource "hcp_vault_radar_integration_jira_connection" "jira_connection" {
name = "example integration jira connection"
email = "[email protected]"
token = var.jira_token
base_url = "https://example.atlassian.net"
}

resource "hcp_vault_radar_integration_jira_subscription" "jira_subscription" {
name = "example integration jira subscription"
connection_id = hcp_vault_radar_integration_jira_connection.jira_connection.id
jira_project_key = "SEC"
issue_type = "Task"
assignee = "71509:11bb945b-c0de-4bac-9d57-9f09db2f7bc9"
message = "Example message"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
variable "slack_token" {
type = string
sensitive = true
}

resource "hcp_vault_radar_integration_slack_connection" "slack_connection" {
name = "example connection to slack"
token = var.slack_token
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
variable "slack_token" {
type = string
sensitive = true
}

# A Slack subscription requires a Slack connection.
resource "hcp_vault_radar_integration_slack_connection" "slack_connection" {
name = "example connection to slack"
token = var.slack_token
}

resource "hcp_vault_radar_integration_slack_subscription" "slack_subscription" {
name = "example integration slack subscription"
connection_id = hcp_vault_radar_integration_slack_connection.slack_connection.id
channel = "sec-ops-team"
}
6 changes: 6 additions & 0 deletions internal/clients/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ import (

cloud_vault_radar "github.com/hashicorp/hcp-sdk-go/clients/cloud-vault-radar/preview/2023-05-01/client"
radar_src_registration_service "github.com/hashicorp/hcp-sdk-go/clients/cloud-vault-radar/preview/2023-05-01/client/data_source_registration_service"
radar_connection_service "github.com/hashicorp/hcp-sdk-go/clients/cloud-vault-radar/preview/2023-05-01/client/integration_connection_service"
radar_subscription_service "github.com/hashicorp/hcp-sdk-go/clients/cloud-vault-radar/preview/2023-05-01/client/integration_subscription_service"

hcpConfig "github.com/hashicorp/hcp-sdk-go/config"
sdk "github.com/hashicorp/hcp-sdk-go/httpclient"
Expand Down Expand Up @@ -92,6 +94,8 @@ type Client struct {
LogService log_service.ClientService
ResourceService resource_service.ClientService
RadarSourceRegistrationService radar_src_registration_service.ClientService
RadarConnectionService radar_connection_service.ClientService
RadarSubscriptionService radar_subscription_service.ClientService
}

// ClientConfig specifies configuration for the client that interacts with HCP
Expand Down Expand Up @@ -182,6 +186,8 @@ func NewClient(config ClientConfig) (*Client, error) {
Webhook: cloud_webhook.New(httpClient, nil).WebhookService,
ResourceService: cloud_resource_manager.New(httpClient, nil).ResourceService,
RadarSourceRegistrationService: cloud_vault_radar.New(httpClient, nil).DataSourceRegistrationService,
RadarConnectionService: cloud_vault_radar.New(httpClient, nil).IntegrationConnectionService,
RadarSubscriptionService: cloud_vault_radar.New(httpClient, nil).IntegrationSubscriptionService,
}

return client, nil
Expand Down
Loading

0 comments on commit b52e294

Please sign in to comment.