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

docs: add example for: awscc_pipes_pipe #1210

Merged
merged 1 commit into from
Sep 21, 2023
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
162 changes: 160 additions & 2 deletions docs/resources/pipes_pipe.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
---
# generated by https://github.com/hashicorp/terraform-plugin-docs
page_title: "awscc_pipes_pipe Resource - terraform-provider-awscc"
subcategory: ""
description: |-
Expand All @@ -10,7 +9,166 @@ description: |-

Definition of AWS::Pipes::Pipe Resource Type

## Example Usage

### Basic Usage

Create a pipe with SQS queues as the source and destination:

```terraform
data "aws_caller_identity" "example" {}

resource "awscc_sqs_queue" "source" {}

resource "awscc_sqs_queue" "target" {}

resource "awscc_iam_role" "example" {
assume_role_policy_document = jsonencode({
Version = "2012-10-17"
Statement = [
{
Action = "sts:AssumeRole"
Effect = "Allow"
Principal = {
Service = "pipes.amazonaws.com"
}
Condition = {
StringEquals = {
"aws:SourceAccount" = data.aws_caller_identity.example.account_id
}
}
},
]
})
policies = [{
policy_name = "SQSAccess"
policy_document = jsonencode({
Version = "2012-10-17"
Statement = [
{
Action = [
"sqs:DeleteMessage",
"sqs:GetQueueAttributes",
"sqs:ReceiveMessage",
],
Effect = "Allow",
Resource = [
awscc_sqs_queue.source.arn
]
},
{
Action = [
"sqs:SendMessage",
],
Effect = "Allow",
Resource = [
awscc_sqs_queue.target.arn
]
},
]
})
}]
}

resource "awscc_pipes_pipe" "example" {
name = "example-pipe"
role_arn = awscc_iam_role.example.arn
source = awscc_sqs_queue.source.arn
target = awscc_sqs_queue.target.arn
tags = {
"Modified by" = "AWSCC"
}
}
```

### Pipe with Enrichment

Create a pipe with enrichment:

```terraform
data "aws_iam_role" "example" {
name = "awscc_example"
}

data "aws_cloudwatch_event_connection" "example" {
name = "awscc-example"
}

resource "awscc_sqs_queue" "source" {}

resource "awscc_sqs_queue" "target" {}

resource "awscc_events_api_destination" "example" {
connection_arn = data.aws_cloudwatch_event_connection.example.arn
http_method = "GET"
invocation_endpoint = "https://example.com"
}

resource "awscc_pipes_pipe" "example" {
name = "example-pipe"
role_arn = data.aws_iam_role.example.arn
source = awscc_sqs_queue.source.arn
target = awscc_sqs_queue.target.arn
enrichment = awscc_events_api_destination.example.arn
enrichment_parameters = {
http_parameters = {
path_parameter_values = ["example-path-param"]
header_parameters = {
"example-header" = "example-value"
"second-example-header" = "second-example-value"
}
query_string_parameteres = {
"example-query-string" = "example-value"
"second-example-query-string" = "second-example-value"
}
}
}
}
```

### Pipe with Source and Target Parameters

Create a pipe with source filtering and custom parameters for source and target
locations:

```terraform
data "aws_iam_role" "example" {
name = "awscc_example"
}

resource "awscc_sqs_queue" "source" {
fifo_queue = true
}

resource "awscc_sqs_queue" "target" {
fifo_queue = true
}

resource "awscc_pipes_pipe" "example" {
name = "example-pipe"
role_arn = data.aws_iam_role.example.arn
source = awscc_sqs_queue.source.arn
target = awscc_sqs_queue.target.arn
source_parameters = {
filter_criteria = {
filters = [{
pattern = jsonencode({
source = ["event-source"]
})
}]
}
sqs_queue_parameters = {
batch_size = 1
}
}
target_parameters = {
sqs_queue_parameters = {
message_deduplication_id = "example-dedupe"
message_group_id = "example-group"
}
}
}
```

<!-- schema generated by tfplugindocs -->
## Schema
Expand Down Expand Up @@ -612,4 +770,4 @@ Import is supported using the following syntax:

```shell
$ terraform import awscc_pipes_pipe.example <resource ID>
```
```
63 changes: 63 additions & 0 deletions examples/resources/awscc_pipes_pipe/pipe_basic.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
data "aws_caller_identity" "example" {}

resource "awscc_sqs_queue" "source" {}

resource "awscc_sqs_queue" "target" {}

resource "awscc_iam_role" "example" {
assume_role_policy_document = jsonencode({
Version = "2012-10-17"
Statement = [
{
Action = "sts:AssumeRole"
Effect = "Allow"
Principal = {
Service = "pipes.amazonaws.com"
}
Condition = {
StringEquals = {
"aws:SourceAccount" = data.aws_caller_identity.example.account_id
}
}
},
]
})
policies = [{
policy_name = "SQSAccess"
policy_document = jsonencode({
Version = "2012-10-17"
Statement = [
{
Action = [
"sqs:DeleteMessage",
"sqs:GetQueueAttributes",
"sqs:ReceiveMessage",
],
Effect = "Allow",
Resource = [
awscc_sqs_queue.source.arn
]
},
{
Action = [
"sqs:SendMessage",
],
Effect = "Allow",
Resource = [
awscc_sqs_queue.target.arn
]
},
]
})
}]
}

resource "awscc_pipes_pipe" "example" {
name = "example-pipe"
role_arn = awscc_iam_role.example.arn
source = awscc_sqs_queue.source.arn
target = awscc_sqs_queue.target.arn
tags = {
"Modified by" = "AWSCC"
}
}
38 changes: 38 additions & 0 deletions examples/resources/awscc_pipes_pipe/pipe_enrichment.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
data "aws_iam_role" "example" {
name = "awscc_example"
}

data "aws_cloudwatch_event_connection" "example" {
name = "awscc-example"
}

resource "awscc_sqs_queue" "source" {}

resource "awscc_sqs_queue" "target" {}

resource "awscc_events_api_destination" "example" {
connection_arn = data.aws_cloudwatch_event_connection.example.arn
http_method = "GET"
invocation_endpoint = "https://example.com"
}

resource "awscc_pipes_pipe" "example" {
name = "example-pipe"
role_arn = data.aws_iam_role.example.arn
source = awscc_sqs_queue.source.arn
target = awscc_sqs_queue.target.arn
enrichment = awscc_events_api_destination.example.arn
enrichment_parameters = {
http_parameters = {
path_parameter_values = ["example-path-param"]
header_parameters = {
"example-header" = "example-value"
"second-example-header" = "second-example-value"
}
query_string_parameteres = {
"example-query-string" = "example-value"
"second-example-query-string" = "second-example-value"
}
}
}
}
36 changes: 36 additions & 0 deletions examples/resources/awscc_pipes_pipe/pipe_parameters.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
data "aws_iam_role" "example" {
name = "awscc_example"
}

resource "awscc_sqs_queue" "source" {
fifo_queue = true
}

resource "awscc_sqs_queue" "target" {
fifo_queue = true
}

resource "awscc_pipes_pipe" "example" {
name = "example-pipe"
role_arn = data.aws_iam_role.example.arn
source = awscc_sqs_queue.source.arn
target = awscc_sqs_queue.target.arn
source_parameters = {
filter_criteria = {
filters = [{
pattern = jsonencode({
source = ["event-source"]
})
}]
}
sqs_queue_parameters = {
batch_size = 1
}
}
target_parameters = {
sqs_queue_parameters = {
message_deduplication_id = "example-dedupe"
message_group_id = "example-group"
}
}
}
42 changes: 42 additions & 0 deletions templates/resources/pipes_pipe.md.tmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
---
page_title: "{{.Name}} {{.Type}} - {{.ProviderName}}"
subcategory: ""
description: |-
{{ .Description | plainmarkdown | trimspace | prefixlines " " }}
---

# {{.Name}} ({{.Type}})

{{ .Description | trimspace }}

## Example Usage

### Basic Usage

Create a pipe with SQS queues as the source and destination:

{{ tffile (printf "examples/resources/%s/pipe_basic.tf" .Name)}}

### Pipe with Enrichment

Create a pipe with enrichment:

{{ tffile (printf "examples/resources/%s/pipe_enrichment.tf" .Name)}}

### Pipe with Source and Target Parameters

Create a pipe with source filtering and custom parameters for source and target
locations:

{{ tffile (printf "examples/resources/%s/pipe_parameters.tf" .Name)}}

{{ .SchemaMarkdown | trimspace }}
{{- if .HasImport }}

## Import

Import is supported using the following syntax:

{{ codefile "shell" .ImportFile }}

{{- end }}