Skip to content

Commit 052b67a

Browse files
make aws-sdk-rds gem optional
Exit if it's being called for and is not present.
1 parent 6e09c67 commit 052b67a

File tree

3 files changed

+9
-2
lines changed

3 files changed

+9
-2
lines changed

README.md

+2
Original file line numberDiff line numberDiff line change
@@ -358,6 +358,8 @@ will be fetched as necessary and used for connections until it
358358
expires. The value for :host_region will either use the one provided,
359359
or if not provided, the environment variable AWS_REGION.
360360

361+
You must add the `aws-sdk-rds` gem to your bundle to use this functionality.
362+
361363
| `:use_iam_authentication` | true |
362364
| --- | --- |
363365
| `:username` | The database username configured to use IAM Authentication |

lib/mysql2/aws_iam_auth.rb

+7-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
require 'singleton'
2-
require 'aws-sdk-rds'
32

43
module Mysql2
54
class AwsTokenAuth
@@ -10,6 +9,13 @@ class AwsTokenAuth
109
TOKEN_EXPIRES_IN = (60*14) # 14 minutes
1110

1211
def initialize
12+
begin
13+
require 'aws-sdk-rds'
14+
rescue LoadError
15+
puts "gem aws-sdk-rds was not found. Please add this gem to your bundle to use AWS IAM Authentication."
16+
exit
17+
end
18+
1319
@mutex = Mutex.new
1420
# Key identifies a unique set of authentication parameters
1521
# Value is a Hash

mysql2.gemspec

-1
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,4 @@ Mysql2::GEMSPEC = Gem::Specification.new do |s|
2424
s.metadata['msys2_mingw_dependencies'] = 'libmariadbclient'
2525

2626
s.add_runtime_dependency 'bigdecimal'
27-
s.add_runtime_dependency 'aws-sdk-rds'
2827
end

0 commit comments

Comments
 (0)