Skip to content

Commit 22fb765

Browse files
PettitWesleyedsiper
authored andcommitted
aws: http_credentials: support EKS Pod Identity
This change brings the http credential provider in line with the latest spec and adds support for: - EKS Pod Identity - validate/support EKS credential link local IP 169.254.170.23 - Latest HTTP Provider spec: - AWS_CONTAINER_CREDENTIALS_RELATIVE_URI - AWS_CONTAINER_CREDENTIALS_FULL_URI - AWS_CONTAINER_AUTHORIZATION_TOKEN - AWS_CONTAINER_AUTHORIZATION_TOKEN_FILE Signed-off-by: Wesley Pettit <[email protected]>
1 parent e9fc0d1 commit 22fb765

File tree

5 files changed

+279
-65
lines changed

5 files changed

+279
-65
lines changed

include/fluent-bit/flb_aws_credentials.h

Lines changed: 31 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -256,19 +256,21 @@ struct flb_aws_provider *flb_aws_env_provider_create();
256256
* Calling flb_aws_provider_destroy on this provider frees the memory
257257
* used by host and path.
258258
*/
259-
struct flb_aws_provider *flb_http_provider_create(struct flb_config *config,
260-
flb_sds_t host,
261-
flb_sds_t path,
262-
struct
263-
flb_aws_client_generator
264-
*generator);
259+
struct flb_aws_provider *flb_endpoint_provider_create(struct flb_config *config,
260+
flb_sds_t host,
261+
flb_sds_t path,
262+
int port,
263+
int insecure,
264+
struct
265+
flb_aws_client_generator
266+
*generator);
265267

266268
/*
267-
* ECS Provider
269+
* HTTP Provider for EKS and ECS
268270
* The ECS Provider is just a wrapper around the HTTP Provider
269271
* with the ECS credentials endpoint.
270272
*/
271-
struct flb_aws_provider *flb_ecs_provider_create(struct flb_config *config,
273+
struct flb_aws_provider *flb_http_provider_create(struct flb_config *config,
272274
struct
273275
flb_aws_client_generator
274276
*generator);
@@ -350,5 +352,26 @@ int try_lock_provider(struct flb_aws_provider *provider);
350352
void unlock_provider(struct flb_aws_provider *provider);
351353

352354

355+
/*
356+
* HTTP Credentials Provider - retrieve credentials from a local http server
357+
* Used to implement the ECS Credentials provider.
358+
* Equivalent to:
359+
* https://github.com/aws/aws-sdk-go/tree/master/aws/credentials/endpointcreds
360+
*/
361+
362+
struct flb_aws_provider_http {
363+
struct flb_aws_credentials *creds;
364+
time_t next_refresh;
365+
366+
struct flb_aws_client *client;
367+
368+
/* Host and Path to request credentials */
369+
flb_sds_t host;
370+
flb_sds_t path;
371+
372+
flb_sds_t auth_token; /* optional */
373+
};
374+
375+
353376
#endif
354377
#endif /* FLB_HAVE_AWS */

include/fluent-bit/flb_aws_util.h

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,17 @@ struct flb_aws_client {
104104
int debug_only;
105105
};
106106

107+
/* frees dynamic_headers */
108+
struct flb_http_client *flb_aws_client_request_basic_auth(
109+
struct flb_aws_client *aws_client,
110+
int method, const char *uri,
111+
const char *body, size_t body_len,
112+
struct flb_aws_header
113+
*dynamic_headers,
114+
size_t dynamic_headers_len,
115+
char *header_name,
116+
char* auth_token);
117+
107118
/*
108119
* Frees the aws_client, the internal flb_http_client, error_code,
109120
* and flb_upstream.
@@ -144,13 +155,20 @@ flb_sds_t flb_aws_xml_error(char *response, size_t response_len);
144155
flb_sds_t flb_aws_error(char *response, size_t response_len);
145156

146157
/*
147-
* Similar to 'flb_aws_error', except it prints the JSON error type and message
148-
* to the user in a error log.
158+
* Similar to 'flb_aws_error', except it prints the JSON error __type and message
159+
* field values to the user in a error log.
149160
* 'api' is the name of the API that was called; this is used in the error log.
150161
*/
151162
void flb_aws_print_error(char *response, size_t response_len,
152163
char *api, struct flb_output_instance *ins);
153164

165+
/*
166+
* Error parsing for json APIs that respond with a
167+
* Code and Message fields for error responses.
168+
*/
169+
void flb_aws_print_error_code(char *response, size_t response_len,
170+
char *api);
171+
154172
/* Similar to 'flb_aws_print_error', but for APIs that return XML */
155173
void flb_aws_print_xml_error(char *response, size_t response_len,
156174
char *api, struct flb_output_instance *ins);

src/aws/flb_aws_credentials.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -581,7 +581,7 @@ static struct flb_aws_provider *standard_chain_create(struct flb_config
581581
}
582582
}
583583

584-
sub_provider = flb_ecs_provider_create(config, generator);
584+
sub_provider = flb_http_provider_create(config, generator);
585585
if (sub_provider) {
586586
/* ECS Provider will fail creation if we are not running in ECS */
587587
mk_list_add(&sub_provider->_head, &implementation->sub_providers);

0 commit comments

Comments
 (0)