Skip to content

Conversation

@kabakakao
Copy link

@kabakakao kabakakao commented Jan 8, 2026

Use European Souvereign Cloud specific Endpoints if neccessary

Fixes: aws/aws-for-fluent-bit#1057

Testing
Before we can approve your change; please submit the following in a comment:

  • Added a TestCase

If this is a change to packaging of containers or native binaries then please confirm it works for all targets.

Backporting

  • Backport to latest stable release.

Fluent Bit is licensed under Apache 2.0, by submitting this pull request I understand that this code will be released under the terms of that license.

Summary by CodeRabbit

  • New Features

    • Improved AWS endpoint construction to support multiple regional domains, including China regions and EU Sovereign Cloud, ensuring correct domain suffixes for regional endpoints and more reliable endpoint formatting.
  • Tests

    • Added tests validating EU Sovereign Cloud and China regional endpoint behavior to ensure correct domain routing.
  • Bug Fixes

    • Strengthened endpoint construction validation to reduce failures from insufficient buffer sizing.

✏️ Tip: You can customize this high-level summary in your review settings.

@kabakakao kabakakao requested a review from a team as a code owner January 8, 2026 06:44
@coderabbitai
Copy link

coderabbitai bot commented Jan 8, 2026

📝 Walkthrough

Walkthrough

Endpoint construction now selects a domain suffix dynamically: standard ".amazonaws.com", China ".amazonaws.com.cn" for cn-north-1/cn-northwest-1, and EU Sovereign Cloud ".amazonaws.eu" for regions starting with eusc-. Length calculation and snprintf usage updated; tests extended for EU suffix.

Changes

Cohort / File(s) Summary
AWS Endpoint Configuration
src/aws/flb_aws_util.c
Replaced hardcoded ".amazonaws.com" with selectable domain suffixes (.amazonaws.com, .amazonaws.com.cn, .amazonaws.eu); added region checks for China and EU sovereign cloud (cn-*, eusc-*); recomputed buffer length and updated snprintf and error handling.
Endpoint Test Coverage
tests/internal/aws_util.c
Added test for EU Sovereign Cloud region (eusc-de-east-1cloudwatch.eusc-de-east-1.amazonaws.eu); retained existing ap-south-1 and cn-north-1 tests and proper endpoint memory management.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐇 I nibbled at a hostname string,

swapped a suffix, gave it wing.
From .com to .cn to .eu's hue,
endpoints now know what to do.

🚥 Pre-merge checks | ✅ 4 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: switching AWS endpoints for European Sovereign Cloud regions, which is the primary objective of this PR.
Linked Issues check ✅ Passed The PR implementation addresses issue #1057 by adding EU Sovereign Cloud endpoint handling: detecting eusc- regions and applying .amazonaws.eu suffix instead of .amazonaws.com.
Out of Scope Changes check ✅ Passed All changes are directly related to fixing AWS endpoint URLs for European Sovereign Cloud. The modifications to endpoint formatting and domain suffix handling align with the linked issue requirements.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

📜 Recent review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 86807e7 and 452e01e.

📒 Files selected for processing (1)
  • src/aws/flb_aws_util.c
🧰 Additional context used
🧬 Code graph analysis (1)
src/aws/flb_aws_util.c (1)
include/fluent-bit/flb_mem.h (1)
  • flb_calloc (84-96)
🔇 Additional comments (5)
src/aws/flb_aws_util.c (5)

36-39: LGTM! Clean constant definitions.

The new format string and domain suffix constants correctly implement support for multiple AWS endpoint domains. The format change from a hardcoded .amazonaws.com to a dynamic suffix placeholder is the right approach.


76-76: LGTM! Comment accurately reflects the new endpoint format.


81-93: LGTM! Region detection logic is correct and aligns with PR objectives.

The implementation correctly identifies:

  • China regions by exact name match (cn-north-1, cn-northwest-1)
  • EU Sovereign Cloud regions by prefix match (eusc-*)
  • Standard regions by default

The use of strncmp(region, "eusc-", 5) for EU region detection appropriately matches the pattern described in the linked issue.


95-99: LGTM! Length calculation is correct.

The buffer size calculation properly accounts for all components:

  • Service name
  • Dot separator (from format string)
  • Region name
  • Domain suffix (including its leading dot)
  • Null terminator

107-112: LGTM! Endpoint construction and error handling are correct.

The snprintf usage correctly formats the endpoint with the dynamic domain suffix, and the error checking follows the standard pattern for detecting both encoding errors (bytes < 0) and insufficient buffer size (bytes >= len). Proper cleanup is performed on the error path.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (2)
src/aws/flb_aws_util.c (2)

86-93: Region-to-suffix mapping correctly implements EU Sovereign Cloud support.

The logic properly routes:

  • China regions (cn-north-1, cn-northwest-1) → .amazonaws.com.cn
  • EU Sovereign Cloud (eusc-de-east-1) → .amazonaws.eu
  • All other regions → .amazonaws.com (default)
💡 Optional: Consider a lookup table for future scalability

If additional EU Sovereign Cloud regions are added in the future, a lookup table or pattern-based approach could improve maintainability:

+static const char* get_domain_suffix(const char* region) {
+    if (strcmp(region, "cn-north-1") == 0 || strcmp(region, "cn-northwest-1") == 0) {
+        return AWS_SERVICE_ENDPOINT_SUFFIX_COM_CN;
+    }
+    if (strncmp(region, "eusc-", 5) == 0) {  /* Match all eusc-* regions */
+        return AWS_SERVICE_ENDPOINT_SUFFIX_EU;
+    }
+    return AWS_SERVICE_ENDPOINT_SUFFIX_COM;
+}

However, the current hardcoded approach is acceptable for the known regions.


107-112: Consider checking for snprintf truncation.

The current error handling only checks for encoding errors (bytes < 0). While truncation shouldn't occur due to the correct length calculation, defensive coding would also verify that bytes < len to catch any unexpected truncation.

🛡️ More robust snprintf error handling
-    bytes = snprintf(endpoint, len, AWS_SERVICE_ENDPOINT_FORMAT, service, region, domain_suffix);
-    if (bytes < 0) {
+    bytes = snprintf(endpoint, len, AWS_SERVICE_ENDPOINT_FORMAT, service, region, domain_suffix);
+    if (bytes < 0 || bytes >= len) {
         flb_errno();
         flb_free(endpoint);
         return NULL;
     }

This guards against both encoding errors and unexpected truncation.

📜 Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e19e07e and c77dc5a.

📒 Files selected for processing (2)
  • src/aws/flb_aws_util.c
  • tests/internal/aws_util.c
🧰 Additional context used
🧬 Code graph analysis (2)
src/aws/flb_aws_util.c (1)
include/fluent-bit/flb_mem.h (1)
  • flb_calloc (84-96)
tests/internal/aws_util.c (2)
src/aws/flb_aws_util.c (1)
  • flb_aws_endpoint (78-116)
include/fluent-bit/flb_mem.h (1)
  • flb_free (126-128)
🔇 Additional comments (3)
src/aws/flb_aws_util.c (2)

36-39: LGTM! Clear parameterization of endpoint format.

The new constants cleanly separate the endpoint format from domain suffixes, enabling support for standard (.com), China (.com.cn), and EU Sovereign Cloud (.eu) regions.


95-99: LGTM! Length calculation is accurate.

The calculation correctly accounts for all components in the format "%s.%s%s":

  • Service name length
  • Dot separator (1 byte)
  • Region name length
  • Domain suffix length
  • Null terminator (1 byte)
tests/internal/aws_util.c (1)

166-172: LGTM! Test case properly validates EU Sovereign Cloud endpoint.

The test correctly verifies that region eusc-de-east-1 produces the endpoint cloudwatch.eusc-de-east-1.amazonaws.eu, directly addressing the issue described in #1057. Memory management and test structure follow the established pattern.

Signed-off-by: Stephan <Stephan.Telahr@bertelsmann.de>
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (1)
src/aws/flb_aws_util.c (1)

91-93: Consider prefix-based matching for EU Sovereign Cloud regions.

The current implementation correctly handles the eusc-de-east-1 region as specified in the issue. However, if AWS introduces additional EU Sovereign Cloud regions (which would likely follow the eusc-* naming pattern), each would require a code change.

♻️ Proposed refactor for scalability
-    else if (strcmp("eusc-de-east-1", region) == 0) {
+    else if (strncmp(region, "eusc-", 5) == 0) {
         domain_suffix = AWS_SERVICE_ENDPOINT_SUFFIX_EU;
     }

This approach would automatically support any future EU Sovereign Cloud regions without requiring code changes.

📜 Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between c77dc5a and 86807e7.

📒 Files selected for processing (2)
  • src/aws/flb_aws_util.c
  • tests/internal/aws_util.c
🧰 Additional context used
🧬 Code graph analysis (2)
src/aws/flb_aws_util.c (1)
include/fluent-bit/flb_mem.h (1)
  • flb_calloc (84-96)
tests/internal/aws_util.c (2)
src/aws/flb_aws_util.c (1)
  • flb_aws_endpoint (78-116)
include/fluent-bit/flb_mem.h (1)
  • flb_free (126-128)
🔇 Additional comments (7)
src/aws/flb_aws_util.c (6)

36-39: LGTM! Clean constant definitions for domain suffixes.

The introduction of separate domain suffix constants and the updated format string enables flexible endpoint construction for different AWS partitions (standard, China, EU Sovereign Cloud).


76-77: LGTM! Comment accurately reflects the updated endpoint format.


87-90: LGTM! China region handling is correct and complete.

The code properly handles both China regions (cn-north-1 and cn-northwest-1) by using the .amazonaws.com.cn domain suffix.


95-99: LGTM! Length calculation is correct and clear.

The calculation properly accounts for all endpoint components (service, dot separator, region, domain suffix, and null terminator).


101-105: LGTM! Memory allocation and error handling are correct.


107-112: LGTM! Endpoint construction and error handling are correct.

The snprintf call properly formats the endpoint using the selected domain suffix, and error handling ensures memory is freed on failure.

tests/internal/aws_util.c (1)

166-171: LGTM! Test coverage for EU Sovereign Cloud endpoint is excellent.

The new test case properly validates that the eusc-de-east-1 region generates the correct endpoint with the .amazonaws.eu domain suffix, as required by issue #1057. The test follows the established pattern and includes proper memory management.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Endpoint URL for European Souvereign Cloud incorrect

1 participant