Skip to content

Commit 2289b8b

Browse files
committed
aws_credentials: add IoT provider support and related credentials definitions
This update introduces the IoT provider creation function and adds necessary environment variable definitions for IoT credentials in the AWS module. Additionally, the CMake configuration is updated to include the new IoT credentials source file. Signed-off-by: Eduardo Silva <[email protected]> Signed-off-by: SagiROosto <[email protected]>
1 parent 329cba4 commit 2289b8b

File tree

4 files changed

+678
-0
lines changed

4 files changed

+678
-0
lines changed

include/fluent-bit/flb_aws_credentials.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,11 @@ struct flb_aws_provider *flb_eks_provider_create(struct flb_config *config,
225225
flb_aws_client_generator
226226
*generator);
227227

228+
/*
229+
* IoT Provider
230+
*/
231+
struct flb_aws_provider *flb_iot_provider_create(struct flb_config *config,
232+
struct flb_aws_client_generator *generator);
228233

229234
/*
230235
* STS Assume Role Provider.

src/aws/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ set(src
1515
"flb_aws_imds.c"
1616
"flb_aws_credentials_http.c"
1717
"flb_aws_credentials_profile.c"
18+
"flb_aws_credentials_iot.c"
1819
)
1920

2021
message(STATUS "=== AWS Credentials ===")

src/aws/flb_aws_credentials.c

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,14 @@
3838

3939
#define EKS_POD_EXECUTION_ROLE "EKS_POD_EXECUTION_ROLE"
4040

41+
/* IoT Credentials Environment Variables */
42+
#define AWS_IOT_KEY_FILE "AWS_IOT_KEY_FILE"
43+
#define AWS_IOT_CERT_FILE "AWS_IOT_CERT_FILE"
44+
#define AWS_IOT_CA_CERT_FILE "AWS_IOT_CA_CERT_FILE"
45+
#define AWS_IOT_CREDENTIALS_ENDPOINT "AWS_IOT_CREDENTIALS_ENDPOINT"
46+
#define AWS_IOT_THING_NAME "AWS_IOT_THING_NAME"
47+
#define AWS_IOT_ROLE_ALIAS "AWS_IOT_ROLE_ALIAS"
48+
4149
/* declarations */
4250
static struct flb_aws_provider *standard_chain_create(struct flb_config
4351
*config,
@@ -51,6 +59,10 @@ static struct flb_aws_provider *standard_chain_create(struct flb_config
5159
int eks_irsa,
5260
char *profile);
5361

62+
/* IoT Provider declaration */
63+
struct flb_aws_provider *flb_iot_provider_create(struct flb_config *config,
64+
struct flb_aws_client_generator *generator);
65+
5466

5567
/*
5668
* The standard credential provider chain:
@@ -59,6 +71,7 @@ static struct flb_aws_provider *standard_chain_create(struct flb_config
5971
* 3. EKS OIDC
6072
* 4. EC2 IMDS
6173
* 5. ECS HTTP credentials endpoint
74+
* 6. IoT credentials endpoint
6275
*
6376
* This provider will evaluate each provider in order, returning the result
6477
* from the first provider that returns valid credentials.
@@ -566,6 +579,14 @@ static struct flb_aws_provider *standard_chain_create(struct flb_config
566579

567580
mk_list_add(&sub_provider->_head, &implementation->sub_providers);
568581

582+
/* IoT Provider - check early since it requires specific environment variables */
583+
sub_provider = flb_iot_provider_create(config, generator);
584+
if (sub_provider) {
585+
/* IoT provider can fail if we are not running in IoT */
586+
mk_list_add(&sub_provider->_head, &implementation->sub_providers);
587+
flb_debug("[aws_credentials] Initialized IoT Provider in standard chain");
588+
}
589+
569590
flb_debug("[aws_credentials] creating profile %s provider", profile);
570591
sub_provider = flb_profile_provider_create(profile);
571592
if (sub_provider) {

0 commit comments

Comments
 (0)