Skip to content

Commit

Permalink
Merge pull request #88 from fluent/handle-opensearch-serverless
Browse files Browse the repository at this point in the history
out_opensearch: Provide service_name choices for handling serverless
  • Loading branch information
cosmo0920 authored Nov 24, 2022
2 parents f364806 + e8da9d2 commit 5a95b8f
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 1 deletion.
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1577,6 +1577,19 @@ If you want to expire AWS credentials in certain interval, you should specify `r
</endpoint>
```

### Use OpenSearch Serverless

If you want to use Serverless version of OpenSearch service, you have to specify `aoss` in `aws_service_name` under `endpoint` section:

```aconf
<endpoint>
url https://CLUSTER_ENDPOINT_URL
region us-east-2
# ...
aws_service_name aoss # default is es that is for AWS OpenSearch Service not Serverless.
</endpoint>
```

## Troubleshooting

See [Troubleshooting document](README.Troubleshooting.md)
Expand Down
3 changes: 2 additions & 1 deletion lib/fluent/plugin/out_opensearch.rb
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,7 @@ def initialize(retry_stream)
config_param :assume_role_web_identity_token_file, :string, :default => nil
config_param :sts_credentials_region, :string, :default => nil
config_param :refresh_credentials_interval, :time, :default => "5h"
config_param :aws_service_name, :enum, list: [:es, :aoss], :default => :es
end

config_section :buffer do
Expand Down Expand Up @@ -622,7 +623,7 @@ def client(host = nil, compress_connection = false)
lambda do |f|
f.request(
:aws_sigv4,
service: 'es',
service: @endpoint.aws_service_name.to_s,
region: @endpoint.region,
credentials: @_aws_credentials,
)
Expand Down
33 changes: 33 additions & 0 deletions test/plugin/test_out_opensearch.rb
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,39 @@ def test_configure
assert_equal "fluentd", instance.endpoint.assume_role_session_name
assert_nil instance.endpoint.assume_role_web_identity_token_file
assert_nil instance.endpoint.sts_credentials_region
assert_equal :es, instance.endpoint.aws_service_name
end

data("OpenSearch Service" => [:es, 'es'],
"OpenSearch Serverless" => [:aoss, 'aoss'])
test 'configure endpoint section w/ aws_service_name' do |data|
expected, conf = data
config = Fluent::Config::Element.new(
'ROOT', '', {
'@type' => 'opensearch',
}, [
Fluent::Config::Element.new('endpoint', '', {
'url' => "https://search-opensearch.aws.example.com/",
'region' => "local",
'access_key_id' => 'YOUR_AWESOME_KEY',
'secret_access_key' => 'YOUR_AWESOME_SECRET',
'aws_service_name' => conf,
}, []),
Fluent::Config::Element.new('buffer', 'tag', {}, [])

])
instance = driver(config).instance

assert_equal "https://search-opensearch.aws.example.com", instance.endpoint.url
assert_equal "local", instance.endpoint.region
assert_equal "YOUR_AWESOME_KEY", instance.endpoint.access_key_id
assert_equal "YOUR_AWESOME_SECRET", instance.endpoint.secret_access_key
assert_nil instance.endpoint.assume_role_arn
assert_nil instance.endpoint.ecs_container_credentials_relative_uri
assert_equal "fluentd", instance.endpoint.assume_role_session_name
assert_nil instance.endpoint.assume_role_web_identity_token_file
assert_nil instance.endpoint.sts_credentials_region
assert_equal expected, instance.endpoint.aws_service_name
end

test 'configure compression' do
Expand Down

0 comments on commit 5a95b8f

Please sign in to comment.