@@ -120,6 +120,31 @@ static int cb_firehose_init(struct flb_output_instance *ins,
120
120
ctx -> sts_endpoint = (char * ) tmp ;
121
121
}
122
122
123
+ /*
124
+ * Sets the port number for the Kinesis output plugin.
125
+ *
126
+ * This function uses the port number already set in the output instance's host structure.
127
+ * If the port is not set (0), the default HTTPS port is used.
128
+ *
129
+ * @param ins The output instance.
130
+ * @param ctx The Kinesis output plugin context.
131
+ */
132
+ flb_plg_debug (ins , "Retrieved port from ins->host.port: %d" , ins -> host .port );
133
+
134
+ if (ins -> host .port >= FLB_KINESIS_MIN_PORT && ins -> host .port <= FLB_KINESIS_MAX_PORT ) {
135
+ ctx -> port = ins -> host .port ;
136
+ flb_plg_debug (ins , "Setting port to: %d" , ctx -> port );
137
+ }
138
+ else if (ins -> host .port == 0 ) {
139
+ ctx -> port = FLB_KINESIS_DEFAULT_HTTPS_PORT ;
140
+ flb_plg_debug (ins , "Port not set. Using default HTTPS port: %d" , ctx -> port );
141
+ }
142
+ else {
143
+ flb_plg_error (ins , "Invalid port number: %d. Must be between %d and %d" ,
144
+ ins -> host .port , FLB_KINESIS_MIN_PORT , FLB_KINESIS_MAX_PORT );
145
+ goto error ;
146
+ }
147
+
123
148
tmp = flb_output_get_property ("compression" , ins );
124
149
if (tmp ) {
125
150
ret = flb_aws_compression_get_type (tmp );
@@ -259,14 +284,14 @@ static int cb_firehose_init(struct flb_output_instance *ins,
259
284
ctx -> firehose_client -> region = (char * ) ctx -> region ;
260
285
ctx -> firehose_client -> retry_requests = ctx -> retry_requests ;
261
286
ctx -> firehose_client -> service = "firehose" ;
262
- ctx -> firehose_client -> port = 443 ;
287
+ ctx -> firehose_client -> port = ctx -> port ;
263
288
ctx -> firehose_client -> flags = 0 ;
264
289
ctx -> firehose_client -> proxy = NULL ;
265
290
ctx -> firehose_client -> static_headers = & content_type_header ;
266
291
ctx -> firehose_client -> static_headers_len = 1 ;
267
292
268
293
struct flb_upstream * upstream = flb_upstream_create (config , ctx -> endpoint ,
269
- 443 , FLB_IO_TLS ,
294
+ ctx -> port , FLB_IO_TLS ,
270
295
ctx -> client_tls );
271
296
if (!upstream ) {
272
297
flb_plg_error (ctx -> ins , "Connection initialization error" );
0 commit comments