fix: use aws http buildable client for add_cloud_metadata#44189
fix: use aws http buildable client for add_cloud_metadata#44189Kavindu-Dodan merged 3 commits intoelastic:mainfrom
Conversation
867e446 to
a18f8e2
Compare
|
Pinging @elastic/obs-ds-hosted-services (Team:obs-ds-hosted-services) |
a0d1ca0 to
4f68877
Compare
| awsRegion := instanceIdentity.Region | ||
| accountID := instanceIdentity.AccountID | ||
| instanceID := instanceIdentity.InstanceID | ||
|
|
||
| _, _ = result.metadata.Put("cloud.instance.id", instanceIdentity.InstanceIdentityDocument.InstanceID) | ||
| _, _ = result.metadata.Put("cloud.machine.type", instanceIdentity.InstanceIdentityDocument.InstanceType) | ||
| _, _ = result.metadata.Put("cloud.instance.id", instanceIdentity.InstanceID) | ||
| _, _ = result.metadata.Put("cloud.machine.type", instanceIdentity.InstanceType) | ||
| _, _ = result.metadata.Put("cloud.region", awsRegion) | ||
| _, _ = result.metadata.Put("cloud.availability_zone", instanceIdentity.InstanceIdentityDocument.AvailabilityZone) | ||
| _, _ = result.metadata.Put("cloud.availability_zone", instanceIdentity.AvailabilityZone) | ||
| _, _ = result.metadata.Put("cloud.account.id", accountID) | ||
| _, _ = result.metadata.Put("cloud.image.id", instanceIdentity.InstanceIdentityDocument.ImageID) | ||
| _, _ = result.metadata.Put("cloud.image.id", instanceIdentity.ImageID) |
There was a problem hiding this comment.
Note - these are lint fixes and not related to core change.
| // generate AWS specific client with overriding requirements | ||
| var awsHTTPClient awshttp.BuildableClient | ||
| awsHTTPClient = *awsHTTPClient.WithTimeout(client.Timeout) | ||
| awsHTTPClient = *awsHTTPClient.WithTransportOptions(func(tr *http.Transport) { |
There was a problem hiding this comment.
Do we need both awsHTTPClient.WithTimeout and awsHTTPClient.WithTransportOptions here?
There was a problem hiding this comment.
Good point, I did this here to match the derived client to the client we parsed into this function. And this generic client is derived here [1] and have some overriding options :)
There was a problem hiding this comment.
Maybe something like this then?
awsHTTPClient := *awshttp.NewBuildableClient().WithTimeout(client.Timeout).WithTransportOptions(func(tr *http.Transport) {
transport, ok := client.Transport.(*http.Transport)
if ok {
tr.TLSClientConfig = transport.TLSClientConfig
}
tr.DisableKeepAlives = true
})
There was a problem hiding this comment.
Yeah that's a nice formatting. I have adopted it - 14fb736 :)
| tr.TLSClientConfig = transport.TLSClientConfig | ||
| } | ||
|
|
||
| tr.DisableCompression = true |
There was a problem hiding this comment.
Why are we setting tr.DisableCompression = true?
There was a problem hiding this comment.
ahh sorry, already updated this :) should have been DisableKeepAlives and matches with generic client. Also related to this discussion #44189 (comment)
4f68877 to
82aaa3d
Compare
Signed-off-by: Kavindu Dodanduwa <kavindu.dodanduwa@elastic.co>
Signed-off-by: Kavindu Dodanduwa <kavindu.dodanduwa@elastic.co>
Signed-off-by: Kavindu Dodanduwa <kavindu.dodanduwa@elastic.co>
14fb736 to
ef860c7
Compare
* use aws http client Signed-off-by: Kavindu Dodanduwa <kavindu.dodanduwa@elastic.co> * add changelog entry Signed-off-by: Kavindu Dodanduwa <kavindu.dodanduwa@elastic.co> * review change : use chaining Signed-off-by: Kavindu Dodanduwa <kavindu.dodanduwa@elastic.co> --------- Signed-off-by: Kavindu Dodanduwa <kavindu.dodanduwa@elastic.co> (cherry picked from commit f54c496)
* use aws http client Signed-off-by: Kavindu Dodanduwa <kavindu.dodanduwa@elastic.co> * add changelog entry Signed-off-by: Kavindu Dodanduwa <kavindu.dodanduwa@elastic.co> * review change : use chaining Signed-off-by: Kavindu Dodanduwa <kavindu.dodanduwa@elastic.co> --------- Signed-off-by: Kavindu Dodanduwa <kavindu.dodanduwa@elastic.co> (cherry picked from commit f54c496)
* use aws http client Signed-off-by: Kavindu Dodanduwa <kavindu.dodanduwa@elastic.co> * add changelog entry Signed-off-by: Kavindu Dodanduwa <kavindu.dodanduwa@elastic.co> * review change : use chaining Signed-off-by: Kavindu Dodanduwa <kavindu.dodanduwa@elastic.co> --------- Signed-off-by: Kavindu Dodanduwa <kavindu.dodanduwa@elastic.co> (cherry picked from commit f54c496)
* use aws http client Signed-off-by: Kavindu Dodanduwa <kavindu.dodanduwa@elastic.co> * add changelog entry Signed-off-by: Kavindu Dodanduwa <kavindu.dodanduwa@elastic.co> * review change : use chaining Signed-off-by: Kavindu Dodanduwa <kavindu.dodanduwa@elastic.co> --------- Signed-off-by: Kavindu Dodanduwa <kavindu.dodanduwa@elastic.co> (cherry picked from commit f54c496)
* upstream/main: bk: use OIDC to create AWS cloud resources (elastic#44202) jenkins: remove references to the Jenkins pipelines and old packaging (elastic#41625) fix: use aws http buildable client for add_cloud_metadata (elastic#44189) [main](backport elastic#44166) docs: Prepare Changelog for 8.18.1 (elastic#44237)
Proposed commit message
Use AWS-specific HTTP client
awshttp.BuildableClientwith overrides matching generic HTTP client of the processor. This allows the use of custom CA bundle loading and avoids failing internal to AWS SDK.Fix was tested in an EC2 environment with
AWS_CA_BUNDLEand it works as expected.Checklist
CHANGELOG.next.asciidocorCHANGELOG-developer.next.asciidoc.Related issues
Fixes #44186