Skip to content

Commit 096459a

Browse files
authored
Merge pull request #31607 from jordanfinners/f-pipes-update
Support Eventbridge Pipes parameters
2 parents 469939e + 969b6a4 commit 096459a

17 files changed

+7523
-981
lines changed

.changelog/31607.txt

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
```release-note:enhancement
2+
resource/aws_pipes_pipe: Add `enrichment_parameters` argument
3+
```
4+
5+
```release-note:enhancement
6+
resource/aws_pipes_pipe: Add `activemq_broker_parameters`, `dynamodb_stream_parameters`, `kinesis_stream_parameters`, `managed_streaming_kafka_parameters`, `rabbitmq_broker_parameters`, `self_managed_kafka_parameters` and `sqs_queue_parameters` attributes to the `source_parameters` configuration block. NOTE: Because we cannot easily test all this functionality, it is best effort and we ask for community help in testing
7+
```
8+
9+
```release-note:enhancement
10+
resource/aws_pipes_pipe: Add `batch_job_parameters`, `cloudwatch_logs_parameters`, `ecs_task_parameters`, `eventbridge_event_bus_parameters`, `http_parameters`, `kinesis_stream_parameters`, `lambda_function_parameters`, `redshift_data_parameters`, `sagemaker_pipeline_parameters`, `sqs_queue_parameters` and `step_function_state_machine_parameters` attributes to the `target_parameters` configuration block. NOTE: Because we cannot easily test all this functionality, it is best effort and we ask for community help in testing
11+
```
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
1+
package pipes
2+
3+
import (
4+
"github.com/aws/aws-sdk-go-v2/aws"
5+
"github.com/aws/aws-sdk-go-v2/service/pipes/types"
6+
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
7+
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"
8+
"github.com/hashicorp/terraform-provider-aws/internal/flex"
9+
)
10+
11+
func enrichmentParametersSchema() *schema.Schema {
12+
return &schema.Schema{
13+
Type: schema.TypeList,
14+
Optional: true,
15+
MaxItems: 1,
16+
Elem: &schema.Resource{
17+
Schema: map[string]*schema.Schema{
18+
"http_parameters": {
19+
Type: schema.TypeList,
20+
Optional: true,
21+
MaxItems: 1,
22+
Elem: &schema.Resource{
23+
Schema: map[string]*schema.Schema{
24+
"header_parameters": {
25+
Type: schema.TypeMap,
26+
Optional: true,
27+
Elem: &schema.Schema{Type: schema.TypeString},
28+
},
29+
"path_parameter_values": {
30+
Type: schema.TypeList,
31+
Optional: true,
32+
MaxItems: 1,
33+
Elem: &schema.Schema{
34+
Type: schema.TypeString,
35+
},
36+
},
37+
"query_string_parameters": {
38+
Type: schema.TypeMap,
39+
Optional: true,
40+
Elem: &schema.Schema{Type: schema.TypeString},
41+
},
42+
},
43+
},
44+
},
45+
"input_template": {
46+
Type: schema.TypeString,
47+
Optional: true,
48+
ValidateFunc: validation.StringLenBetween(0, 8192),
49+
},
50+
},
51+
},
52+
}
53+
}
54+
55+
func expandPipeEnrichmentParameters(tfMap map[string]interface{}) *types.PipeEnrichmentParameters {
56+
if tfMap == nil {
57+
return nil
58+
}
59+
60+
apiObject := &types.PipeEnrichmentParameters{}
61+
62+
if v, ok := tfMap["http_parameters"].([]interface{}); ok && len(v) > 0 && v[0] != nil {
63+
apiObject.HttpParameters = expandPipeEnrichmentHTTPParameters(v[0].(map[string]interface{}))
64+
}
65+
66+
if v, ok := tfMap["input_template"].(string); ok && v != "" {
67+
apiObject.InputTemplate = aws.String(v)
68+
}
69+
70+
return apiObject
71+
}
72+
73+
func expandPipeEnrichmentHTTPParameters(tfMap map[string]interface{}) *types.PipeEnrichmentHttpParameters {
74+
if tfMap == nil {
75+
return nil
76+
}
77+
78+
apiObject := &types.PipeEnrichmentHttpParameters{}
79+
80+
if v, ok := tfMap["header_parameters"].(map[string]interface{}); ok && len(v) > 0 {
81+
apiObject.HeaderParameters = flex.ExpandStringValueMap(v)
82+
}
83+
84+
if v, ok := tfMap["path_parameter_values"].([]interface{}); ok && len(v) > 0 {
85+
apiObject.PathParameterValues = flex.ExpandStringValueList(v)
86+
}
87+
88+
if v, ok := tfMap["query_string_parameters"].(map[string]interface{}); ok && len(v) > 0 {
89+
apiObject.QueryStringParameters = flex.ExpandStringValueMap(v)
90+
}
91+
92+
return apiObject
93+
}
94+
95+
func flattenPipeEnrichmentParameters(apiObject *types.PipeEnrichmentParameters) map[string]interface{} {
96+
if apiObject == nil {
97+
return nil
98+
}
99+
100+
tfMap := map[string]interface{}{}
101+
102+
if v := apiObject.HttpParameters; v != nil {
103+
tfMap["http_parameters"] = []interface{}{flattenPipeEnrichmentHTTPParameters(v)}
104+
}
105+
106+
if v := apiObject.InputTemplate; v != nil {
107+
tfMap["input_template"] = aws.ToString(v)
108+
}
109+
110+
return tfMap
111+
}
112+
113+
func flattenPipeEnrichmentHTTPParameters(apiObject *types.PipeEnrichmentHttpParameters) map[string]interface{} {
114+
if apiObject == nil {
115+
return nil
116+
}
117+
118+
tfMap := map[string]interface{}{}
119+
120+
if v := apiObject.HeaderParameters; v != nil {
121+
tfMap["header_parameters"] = v
122+
}
123+
124+
if v := apiObject.PathParameterValues; v != nil {
125+
tfMap["path_parameter_values"] = v
126+
}
127+
128+
if v := apiObject.QueryStringParameters; v != nil {
129+
tfMap["query_string_parameters"] = v
130+
}
131+
132+
return tfMap
133+
}
+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
package pipes
2+
3+
// Exports for use in tests only.
4+
var (
5+
FindPipeByName = findPipeByName
6+
7+
ResourcePipe = resourcePipe
8+
)

internal/service/pipes/find.go

-37
This file was deleted.

internal/service/pipes/flex.go

-146
This file was deleted.

0 commit comments

Comments
 (0)