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 new configuration document for connection slack #127

Merged
merged 2 commits into from
Sep 10, 2024
Merged
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
73 changes: 73 additions & 0 deletions docs/reference/config-files/connection/slack.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
---
title: slack
sidebar_label: slack
---

# slack

The `slack` connection can be used to access Slack resources.

```hcl
connection "slack" "my_slack" {
token = "xoxp-234567890"
}
```

## Arguments

| Name | Type | Required? | Description |
| ------- | ------ | --------- | ----------------------- |
| `token` | String | Optional | An API token for slack. |

All arguments are optional, and a `slack` connection with no arguments will behave the same as the [Slack default connection](#default-connection).

## Attributes (Read-Only)

| Attribute | Type | Description |
| --------- | ---- | ------------------------------------------------------------------------------ |
| `env` | Map | A map of the resolved connection-related environment variables (`SLACK_TOKEN`) |

## Default Connection

The Slack connection type includes an implicit, default connection (`connection.slack.default`) that will be configured to set the `token` to the `SLACK_TOKEN` environment variable.

```hcl
connection "slack" "default" {
token = env("SLACK_TOKEN")
}
```

## Examples

### Static Connections

```hcl
connection "slack" "my_slack" {
token = "xoxp-234567890"
}
```

### Using Slack Connections in HTTP Step

```hcl
pipeline "gcp_test" {
param "connection" {
type = string
default = "default"
}

step "http" "list_channels" {
url = "https://slack.com/api/conversations.list"
method = "get"

request_headers = {
Content-Type = "application/json; charset=utf-8"
Authorization = "Bearer ${connections.slack[param.connection].token}"
}

request_body = jsonencode({
types = "public_channel"
})
}
}
```
Loading