diff --git a/docs/resources/pipes_pipe.md b/docs/resources/pipes_pipe.md index 5e2ceed048..bb0028ec5b 100644 --- a/docs/resources/pipes_pipe.md +++ b/docs/resources/pipes_pipe.md @@ -1,5 +1,4 @@ --- -# generated by https://github.com/hashicorp/terraform-plugin-docs page_title: "awscc_pipes_pipe Resource - terraform-provider-awscc" subcategory: "" description: |- @@ -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 @@ -612,4 +770,4 @@ Import is supported using the following syntax: ```shell $ terraform import awscc_pipes_pipe.example -``` +``` \ No newline at end of file diff --git a/examples/resources/awscc_pipes_pipe/pipe_basic.tf b/examples/resources/awscc_pipes_pipe/pipe_basic.tf new file mode 100644 index 0000000000..4c3cfbc7d4 --- /dev/null +++ b/examples/resources/awscc_pipes_pipe/pipe_basic.tf @@ -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" + } +} \ No newline at end of file diff --git a/examples/resources/awscc_pipes_pipe/pipe_enrichment.tf b/examples/resources/awscc_pipes_pipe/pipe_enrichment.tf new file mode 100644 index 0000000000..f6dd44a939 --- /dev/null +++ b/examples/resources/awscc_pipes_pipe/pipe_enrichment.tf @@ -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" + } + } + } +} \ No newline at end of file diff --git a/examples/resources/awscc_pipes_pipe/pipe_parameters.tf b/examples/resources/awscc_pipes_pipe/pipe_parameters.tf new file mode 100644 index 0000000000..f9499257fb --- /dev/null +++ b/examples/resources/awscc_pipes_pipe/pipe_parameters.tf @@ -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" + } + } +} \ No newline at end of file diff --git a/templates/resources/pipes_pipe.md.tmpl b/templates/resources/pipes_pipe.md.tmpl new file mode 100644 index 0000000000..7aef3784f2 --- /dev/null +++ b/templates/resources/pipes_pipe.md.tmpl @@ -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 }} \ No newline at end of file