Skip to content

Commit 2497139

Browse files
committed
Introduce port parameter for Kinesis Firehose output plugin
This mirrors the same for Kinesis Streams in #9317 Signed-off-by: Ryan Underwood <[email protected]>
1 parent 7e7433c commit 2497139

File tree

2 files changed

+32
-2
lines changed

2 files changed

+32
-2
lines changed

plugins/out_kinesis_firehose/firehose.c

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,31 @@ static int cb_firehose_init(struct flb_output_instance *ins,
120120
ctx->sts_endpoint = (char *) tmp;
121121
}
122122

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+
123148
tmp = flb_output_get_property("compression", ins);
124149
if (tmp) {
125150
ret = flb_aws_compression_get_type(tmp);
@@ -259,14 +284,14 @@ static int cb_firehose_init(struct flb_output_instance *ins,
259284
ctx->firehose_client->region = (char *) ctx->region;
260285
ctx->firehose_client->retry_requests = ctx->retry_requests;
261286
ctx->firehose_client->service = "firehose";
262-
ctx->firehose_client->port = 443;
287+
ctx->firehose_client->port = ctx->port;
263288
ctx->firehose_client->flags = 0;
264289
ctx->firehose_client->proxy = NULL;
265290
ctx->firehose_client->static_headers = &content_type_header;
266291
ctx->firehose_client->static_headers_len = 1;
267292

268293
struct flb_upstream *upstream = flb_upstream_create(config, ctx->endpoint,
269-
443, FLB_IO_TLS,
294+
ctx->port, FLB_IO_TLS,
270295
ctx->client_tls);
271296
if (!upstream) {
272297
flb_plg_error(ctx->ins, "Connection initialization error");

plugins/out_kinesis_firehose/firehose.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@
2929

3030
#define DEFAULT_TIME_KEY_FORMAT "%Y-%m-%dT%H:%M:%S"
3131

32+
#define FLB_KINESIS_DEFAULT_HTTPS_PORT 443
33+
#define FLB_KINESIS_MIN_PORT 1
34+
#define FLB_KINESIS_MAX_PORT 65535
35+
3236
/* buffers used for each flush */
3337
struct flush {
3438
/* temporary buffer for storing the serialized event messages */
@@ -87,6 +91,7 @@ struct flb_firehose {
8791
const char *log_key;
8892
const char *external_id;
8993
char *sts_endpoint;
94+
int port;
9095
char *profile;
9196
int custom_endpoint;
9297
int retry_requests;

0 commit comments

Comments
 (0)