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

aws: Add external_id support in output plugins #4625

Merged
merged 4 commits into from
Jan 21, 2022
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
9 changes: 8 additions & 1 deletion plugins/out_cloudwatch_logs/cloudwatch_logs.c
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ static int cb_cloudwatch_init(struct flb_output_instance *ins,
ctx->aws_provider = flb_sts_provider_create(config,
ctx->sts_tls,
ctx->base_aws_provider,
NULL,
(char *) ctx->external_id,
(char *) ctx->role_arn,
session_name,
(char *) ctx->region,
Expand Down Expand Up @@ -592,6 +592,13 @@ static struct flb_config_map config_map[] = {
"Specify a custom endpoint for the STS API, can be used with the role_arn parameter"
},

{
FLB_CONFIG_MAP_STR, "external_id", NULL,
0, FLB_TRUE, offsetof(struct flb_cloudwatch, external_id),
"Specify an external ID for the STS API, can be used with the role_arn parameter if your role "
"requires an external ID."
},

{
FLB_CONFIG_MAP_STR, "metric_namespace", NULL,
0, FLB_FALSE, 0,
Expand Down
1 change: 1 addition & 0 deletions plugins/out_cloudwatch_logs/cloudwatch_logs.h
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ struct flb_cloudwatch {
const char *role_arn;
const char *log_key;
const char *extra_user_agent;
const char *external_id;
int custom_endpoint;
/* Should the plugin create the log group */
int create_group;
Expand Down
9 changes: 8 additions & 1 deletion plugins/out_kinesis_firehose/firehose.c
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ static int cb_firehose_init(struct flb_output_instance *ins,
ctx->aws_provider = flb_sts_provider_create(config,
ctx->sts_tls,
ctx->base_aws_provider,
NULL,
ctx->external_id,
(char *) ctx->role_arn,
session_name,
(char *) ctx->region,
Expand Down Expand Up @@ -428,6 +428,13 @@ static struct flb_config_map config_map[] = {
"Custom endpoint for the STS API."
},

{
FLB_CONFIG_MAP_STR, "external_id", NULL,
0, FLB_TRUE, offsetof(struct flb_firehose, external_id),
"Specify an external ID for the STS API, can be used with the role_arn parameter if your role "
"requires an external ID."
},

{
FLB_CONFIG_MAP_STR, "log_key", NULL,
0, FLB_TRUE, offsetof(struct flb_firehose, log_key),
Expand Down
1 change: 1 addition & 0 deletions plugins/out_kinesis_firehose/firehose.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ struct flb_firehose {
const char *region;
const char *role_arn;
const char *log_key;
const char *external_id;
char *sts_endpoint;
int custom_endpoint;
int retry_requests;
Expand Down
9 changes: 8 additions & 1 deletion plugins/out_kinesis_streams/kinesis.c
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ static int cb_kinesis_init(struct flb_output_instance *ins,
ctx->aws_provider = flb_sts_provider_create(config,
ctx->sts_tls,
ctx->base_aws_provider,
NULL,
(char *) ctx->external_id,
(char *) ctx->role_arn,
session_name,
(char *) ctx->region,
Expand Down Expand Up @@ -443,6 +443,13 @@ static struct flb_config_map config_map[] = {
"Custom endpoint for the STS API."
},

{
FLB_CONFIG_MAP_STR, "external_id", NULL,
0, FLB_TRUE, offsetof(struct flb_kinesis, external_id),
"Specify an external ID for the STS API, can be used with the role_arn parameter if your role "
"requires an external ID."
},

{
FLB_CONFIG_MAP_STR, "log_key", NULL,
0, FLB_TRUE, offsetof(struct flb_kinesis, log_key),
Expand Down
1 change: 1 addition & 0 deletions plugins/out_kinesis_streams/kinesis.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ struct flb_kinesis {
const char *region;
const char *role_arn;
const char *log_key;
const char *external_id;
int retry_requests;
char *sts_endpoint;
int custom_endpoint;
Expand Down
14 changes: 8 additions & 6 deletions plugins/out_s3/s3.c
Original file line number Diff line number Diff line change
Expand Up @@ -493,7 +493,6 @@ static int cb_s3_init(struct flb_output_instance *ins,
int async_flags;
int len;
char *role_arn = NULL;
char *external_id = NULL;
char *session_name;
const char *tmp;
struct flb_s3 *ctx = NULL;
Expand Down Expand Up @@ -795,10 +794,6 @@ static int cb_s3_init(struct flb_output_instance *ins,
/* Use the STS Provider */
ctx->base_provider = ctx->provider;
role_arn = (char *) tmp;
tmp = flb_output_get_property("external_id", ins);
if (tmp) {
external_id = (char *) tmp;
}

/* STS provider needs yet another separate TLS instance */
ctx->sts_provider_tls = flb_tls_create(FLB_TRUE,
Expand Down Expand Up @@ -826,7 +821,7 @@ static int cb_s3_init(struct flb_output_instance *ins,
ctx->provider = flb_sts_provider_create(config,
ctx->sts_provider_tls,
ctx->base_provider,
external_id,
ctx->external_id,
role_arn,
session_name,
ctx->region,
Expand Down Expand Up @@ -2391,6 +2386,13 @@ static struct flb_config_map config_map[] = {
"that key will be sent to S3."
},

{
FLB_CONFIG_MAP_STR, "external_id", NULL,
0, FLB_TRUE, offsetof(struct flb_s3, external_id),
"Specify an external ID for the STS API, can be used with the role_arn parameter if your role "
"requires an external ID."
},

{
FLB_CONFIG_MAP_BOOL, "static_file_path", "false",
0, FLB_TRUE, offsetof(struct flb_s3, static_file_path),
Expand Down
1 change: 1 addition & 0 deletions plugins/out_s3/s3.h
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ struct flb_s3 {
char *canned_acl;
char *content_type;
char *log_key;
char *external_id;
int free_endpoint;
int retry_requests;
int use_put_object;
Expand Down