-
Notifications
You must be signed in to change notification settings - Fork 1.9k
aws: switch AWS Endpoints for European Souvereign Cloud #11356
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -33,8 +33,10 @@ | |
| #include <sys/stat.h> | ||
| #include <fcntl.h> | ||
|
|
||
| #define AWS_SERVICE_ENDPOINT_FORMAT "%s.%s.amazonaws.com" | ||
| #define AWS_SERVICE_ENDPOINT_BASE_LEN 15 | ||
| #define AWS_SERVICE_ENDPOINT_FORMAT "%s.%s%s" | ||
| #define AWS_SERVICE_ENDPOINT_SUFFIX_COM ".amazonaws.com" | ||
| #define AWS_SERVICE_ENDPOINT_SUFFIX_COM_CN ".amazonaws.com.cn" | ||
| #define AWS_SERVICE_ENDPOINT_SUFFIX_EU ".amazonaws.eu" | ||
|
|
||
| #define TAG_PART_DESCRIPTOR "$TAG[%d]" | ||
| #define TAG_DESCRIPTOR "$TAG" | ||
|
|
@@ -71,48 +73,44 @@ struct flb_http_client *request_do(struct flb_aws_client *aws_client, | |
| size_t dynamic_headers_len); | ||
|
|
||
| /* | ||
| * https://service.region.amazonaws.com(.cn) | ||
| * https://service.region.amazonaws.[com(.cn)|eu] | ||
| */ | ||
| char *flb_aws_endpoint(char* service, char* region) | ||
| { | ||
| char *endpoint = NULL; | ||
| size_t len = AWS_SERVICE_ENDPOINT_BASE_LEN; | ||
| int is_cn = FLB_FALSE; | ||
| const char *domain_suffix = AWS_SERVICE_ENDPOINT_SUFFIX_COM; | ||
| size_t len; | ||
| int bytes; | ||
|
|
||
|
|
||
| /* In the China regions, ".cn" is appended to the URL */ | ||
| if (strcmp("cn-north-1", region) == 0) { | ||
| len += 3; | ||
| is_cn = FLB_TRUE; | ||
| /* China regions end with amazonaws.com.cn */ | ||
| if (strcmp("cn-north-1", region) == 0 || | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Outside scope of this PR, but we should probably change these to just check for the
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I will likely take this up with the larger add more regional mappings PR |
||
| strcmp("cn-northwest-1", region) == 0) { | ||
| domain_suffix = AWS_SERVICE_ENDPOINT_SUFFIX_COM_CN; | ||
| } | ||
| if (strcmp("cn-northwest-1", region) == 0) { | ||
| len += 3; | ||
| is_cn = FLB_TRUE; | ||
| else if (strncmp(region, "eusc-", 5) == 0) { | ||
| domain_suffix = AWS_SERVICE_ENDPOINT_SUFFIX_EU; | ||
| } | ||
|
|
||
| len += strlen(service); | ||
| len = strlen(service); | ||
| len += 1; /* dot between service and region */ | ||
| len += strlen(region); | ||
| len++; /* null byte */ | ||
| len += strlen(domain_suffix); | ||
| len += 1; /* null byte */ | ||
|
|
||
| endpoint = flb_calloc(len, sizeof(char)); | ||
| if (!endpoint) { | ||
| flb_errno(); | ||
| return NULL; | ||
| } | ||
|
|
||
| bytes = snprintf(endpoint, len, AWS_SERVICE_ENDPOINT_FORMAT, service, region); | ||
| 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; | ||
| } | ||
|
|
||
| if (is_cn) { | ||
| memcpy(endpoint + bytes, ".cn", 3); | ||
| endpoint[bytes + 3] = '\0'; | ||
| } | ||
|
|
||
| return endpoint; | ||
|
|
||
| } | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.