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

Update Documentations and add Schema Submodule #6

Merged
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
52 changes: 51 additions & 1 deletion .github/workflows/release-tagging.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,54 @@ jobs:
with:
tag: ${{ needs.release-tag.outputs.RELEASE_TAG }}
name: Release ${{ needs.release-tag.outputs.RELEASE_TAG }}
body: ${{ needs.release-tag.outputs.RELEASE_TAG }}
generateReleaseNotes: true

release-notifier:
runs-on: ubuntu-latest
needs: ['release-tag', 'create-release']
name: 'Release Notifier'
steps:
- name: Send Notification
uses: slackapi/slack-github-action@v1.27.0
env:
SLACK_BOT_TOKEN: ${{ secrets.RELEASE_SLACKBOT_TOKEN }}
with:
channel-id: release
payload: |
{
"blocks": [
{
"type": "header",
"text": {
"type": "plain_text",
"text": ":terraform: ${{github.event.repository.name}} release",
"emoji": true
}
},
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "*${{github.event.repository.name}}* release."
},
"accessory": {
"type": "button",
"text": {
"type": "plain_text",
"text": "${{needs.release-tag.outputs.RELEASE_TAG}}",
"emoji": true
},
"url": "https://github.com/deseretdigital/${{github.event.repository.name}}/releases/tag/${{needs.release-tag.outputs.RELEASE_TAG}}"
}
},
{
"type": "context",
"elements": [
{
"type": "mrkdwn",
"text": "_This is an automated message. It does not indicate the deploy was successful, and it will not post here if it has failed. Please check the action run for more details._"
}
]
}
]
}
94 changes: 55 additions & 39 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,42 +4,58 @@ This module creates a Google PubSub Topic.

The primary point is to make the creation of these resources repeatable.

# Terraform-Docs

## Requirements

| Name | Version |
|------|---------|
| <a name="requirement_google"></a> [google](#requirement\_google) | 6.5.0 |

## Providers

| Name | Version |
|------|---------|
| <a name="provider_google"></a> [google](#provider\_google) | 6.5.0 |

## Modules

No modules.

## Resources

| Name | Type |
|------|------|
| [google_pubsub_topic.topic](https://registry.terraform.io/providers/hashicorp/google/6.5.0/docs/resources/pubsub_topic) | resource |

## Inputs

| Name | Description | Type | Default | Required |
|------|-------------|------|---------|:--------:|
| <a name="input_labels"></a> [labels](#input\_labels) | A set of key/value label pairs to assign to this Topic. | `map(string)` | n/a | yes |
| <a name="input_message_retention_duration"></a> [message\_retention\_duration](#input\_message\_retention\_duration) | Indicates the minimum duration to retain a message after it is published to the topic. If this field is set, messages published to the topic in the last messageRetentionDuration are always available to subscribers. For instance, it allows any attached subscription to seek to a timestamp that is up to messageRetentionDuration in the past. If this field is not set, message retention is controlled by settings on individual subscriptions. | `string` | `null` | no |
| <a name="input_schema"></a> [schema](#input\_schema) | The name of the schema that messages published should be validated against. | `string` | n/a | yes |
| <a name="input_schema_encoding"></a> [schema\_encoding](#input\_schema\_encoding) | The encoding of messages validated against schema. Default value is ENCODING\_UNSPECIFIED. Possible values are: ENCODING\_UNSPECIFIED, JSON, BINARY. | `string` | n/a | yes |
| <a name="input_topic_name"></a> [topic\_name](#input\_topic\_name) | Name of the topic. | `string` | n/a | yes |

## Outputs

| Name | Description |
|------|-------------|
| <a name="output_topic_id"></a> [topic\_id](#output\_topic\_id) | The ID of the created Pub/Sub Topic. |
## Usage

### Basic Configuration:

```hcl
module "pubsub_topic_module" {
source = "deseretdigital/ddm-pubsub-topic/google"
version = "~> 1.0.0"

# Required
topic_name = {YOUR_TOPIC_NAME}

# Optional
labels = {
env = "prod"
region = {REGION}
# etc...
}

message_retention_duration = {DEFAULT_2678400s}
}
```

This module creates a Google PubSub Topic.

#### Example Usage

```hcl
terraform {
required_providers {
google = {
source = "hashicorp/google"
version = "~> 6.0"
}
}
}

provider "google" {
# Configuration options
}

module "pubsub_topic_module" {
source = "deseretdigital/ddm-pubsub-topic/google"
version = "~> 1.0.0"
topic_name = "Example_TopicName"

labels = {
date = "2024-10-11"
region = "us-west3"
env = "prod"
}

message_retention_duration = "84000s"
}
```
71 changes: 71 additions & 0 deletions modules/topic-schema/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
# Google PubSub Topic with Schema

This module creates a Google PubSub Topic with a provided schema.

## Usage

### Basic Configuration:

```hcl
module "pubsub_topic_module" {
source = "deseretdigital/ddm-pubsub-topic/google"
version = "~> 1.0.0"

# Required
topic_name = {YOUR_TOPIC_NAME}
schema = {YOUR_SCHEMA}
schema_encoding = {SCHEMA_ENCODING}

# Optional
labels = {
env = "prod"
region = {REGION}
# etc...
}

message_retention_duration = {DEFAULT_2678400s}
}
```

This module creates a Google PubSub Topic.

#### Example Usage

```hcl
terraform {
required_providers {
google = {
source = "hashicorp/google"
version = "~> 6.0"
}
}
}

provider "google" {
# Configuration options
}

resource "google_pubsub_schema" "example" {
name = "example"
type = "AVRO"
definition = "{\n \"type\" : \"record\",\n \"name\" : \"Avro\",\n \"fields\" : [\n {\n \"name\" : \"StringField\",\n \"type\" : \"string\"\n },\n {\n \"name\" : \"IntField\",\n \"type\" : \"int\"\n }\n ]\n}\n"
}

module "pubsub_topic_module" {
source = "deseretdigital/ddm-pubsub-topic/google"
version = "~> 1.0.0"
topic_name = "Example_TopicName"
schema = "projects/{PROJECT_NAME}/schemas/example"
schema_encoding = "JSON"

labels = {
date = "2024-10-11"
region = "us-west3"
env = "prod"
}

message_retention_duration = "84000s"

depends_on = [google_pubsub_schema.example]
}
```
Empty file added modules/topic-schema/data.tf
Empty file.
8 changes: 8 additions & 0 deletions modules/topic-schema/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
terraform {
required_providers {
google = {
source = "hashicorp/google"
version = "6.5.0"
}
}
}
9 changes: 9 additions & 0 deletions modules/topic-schema/outputs.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
output "topic_id" {
description = "The ID of the created Pub/Sub Topic."
value = google_pubsub_topic.topic.id
}

output "topic_name" {
description = "The name of the created Pub/Sub Topic."
value = google_pubsub_topic.topic.name
}
6 changes: 6 additions & 0 deletions modules/topic-schema/resources.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
resource "google_pubsub_topic" "topic" {
name = var.topic_name
labels = var.labels

message_retention_duration = var.message_retention_duration
}
38 changes: 38 additions & 0 deletions modules/topic-schema/terraform-docs.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
## Requirements

| Name | Version |
|------|---------|
| <a name="requirement_google"></a> [google](#requirement\_google) | 6.5.0 |

## Providers

| Name | Version |
|------|---------|
| <a name="provider_google"></a> [google](#provider\_google) | 6.5.0 |

## Modules

No modules.

## Resources

| Name | Type |
|------|------|
| [google_pubsub_topic.topic](https://registry.terraform.io/providers/hashicorp/google/6.5.0/docs/resources/pubsub_topic) | resource |

## Inputs

| Name | Description | Type | Default | Required |
|------|-------------|------|---------|:--------:|
| <a name="input_labels"></a> [labels](#input\_labels) | A set of key/value label pairs to assign to this Topic. | `map(string)` | `{}` | no |
| <a name="input_message_retention_duration"></a> [message\_retention\_duration](#input\_message\_retention\_duration) | Indicates the minimum duration to retain a message after it is published to the topic. If this field is set, messages published to the topic in the last messageRetentionDuration are always available to subscribers. For instance, it allows any attached subscription to seek to a timestamp that is up to messageRetentionDuration in the past. If this field is not set, message retention is controlled by settings on individual subscriptions. | `string` | `"2678400s"` | no |
| <a name="input_schema"></a> [schema](#input\_schema) | The name of the schema that messages published should be validated against. Format is projects/{project}/schemas/{schema}. The value of this field will be deleted-schema if the schema has been deleted. | `string` | n/a | yes |
| <a name="input_schema_encoding"></a> [schema\_encoding](#input\_schema\_encoding) | The encoding of the messages validated against schema. Only JSON is supported. If this is not set, the encoding will be defaulted to JSON. | `string` | `"ENCODING_UNSPECIFIED"` | no |
| <a name="input_topic_name"></a> [topic\_name](#input\_topic\_name) | Name of the topic. | `string` | n/a | yes |

## Outputs

| Name | Description |
|------|-------------|
| <a name="output_topic_id"></a> [topic\_id](#output\_topic\_id) | The ID of the created Pub/Sub Topic. |
| <a name="output_topic_name"></a> [topic\_name](#output\_topic\_name) | The name of the created Pub/Sub Topic. |
42 changes: 42 additions & 0 deletions modules/topic-schema/variables.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
variable "labels" {
description = "A set of key/value label pairs to assign to this Topic."
type = map(string)
default = {}
}

variable "message_retention_duration" {
default = "2678400s"
description = "Indicates the minimum duration to retain a message after it is published to the topic. If this field is set, messages published to the topic in the last messageRetentionDuration are always available to subscribers. For instance, it allows any attached subscription to seek to a timestamp that is up to messageRetentionDuration in the past. If this field is not set, message retention is controlled by settings on individual subscriptions."
type = string

validation {
condition = can(regex("^\\d+s$", var.message_retention_duration))
error_message = "Value must be a duration represented in seconds. Example: 86400s"
}
}

variable "schema" {
description = "The name of the schema that messages published should be validated against. Format is projects/{project}/schemas/{schema}. The value of this field will be deleted-schema if the schema has been deleted."
type = string

validation {
condition = can(regex("^projects/[^/]+/schemas/[^/]+$", var.schema))
error_message = "Value must be in the format projects/{project}/schemas/{schema}."
}
}

variable "schema_encoding" {
description = "The encoding of the messages validated against schema. Only JSON is supported. If this is not set, the encoding will be defaulted to JSON."
type = string
default = "ENCODING_UNSPECIFIED"

validation {
condition = contains(["BINARY", "JSON", "ENCODING_UNSPECIFIED"], var.schema_encoding)
error_message = "Value must be one of: BINARY, JSON, ENCODING_UNSPECIFIED"
}
}

variable "topic_name" {
description = "Name of the topic."
type = string
}
36 changes: 36 additions & 0 deletions terraform-docs.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
## Requirements

| Name | Version |
|------|---------|
| <a name="requirement_google"></a> [google](#requirement\_google) | 6.5.0 |

## Providers

| Name | Version |
|------|---------|
| <a name="provider_google"></a> [google](#provider\_google) | 6.5.0 |

## Modules

No modules.

## Resources

| Name | Type |
|------|------|
| [google_pubsub_topic.topic](https://registry.terraform.io/providers/hashicorp/google/6.5.0/docs/resources/pubsub_topic) | resource |

## Inputs

| Name | Description | Type | Default | Required |
|------|-------------|------|---------|:--------:|
| <a name="input_labels"></a> [labels](#input\_labels) | A set of key/value label pairs to assign to this Topic. | `map(string)` | `{}` | no |
| <a name="input_message_retention_duration"></a> [message\_retention\_duration](#input\_message\_retention\_duration) | Indicates the minimum duration to retain a message after it is published to the topic. If this field is set, messages published to the topic in the last messageRetentionDuration are always available to subscribers. For instance, it allows any attached subscription to seek to a timestamp that is up to messageRetentionDuration in the past. If this field is not set, message retention is controlled by settings on individual subscriptions. | `string` | `"2678400s"` | no |
| <a name="input_topic_name"></a> [topic\_name](#input\_topic\_name) | Name of the topic. | `string` | n/a | yes |

## Outputs

| Name | Description |
|------|-------------|
| <a name="output_topic_id"></a> [topic\_id](#output\_topic\_id) | The ID of the created Pub/Sub Topic. |
| <a name="output_topic_name"></a> [topic\_name](#output\_topic\_name) | The name of the created Pub/Sub Topic. |
1 change: 1 addition & 0 deletions variables.tf
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
variable "labels" {
description = "A set of key/value label pairs to assign to this Topic."
type = map(string)
default = {}
}

variable "message_retention_duration" {
Expand Down
Loading