File tree Expand file tree Collapse file tree 1 file changed +17
-4
lines changed
Expand file tree Collapse file tree 1 file changed +17
-4
lines changed Original file line number Diff line number Diff line change @@ -75,13 +75,26 @@ def object_exists?(key:)
7575 private
7676
7777 def get_client
78- @client = Aws ::S3 ::Client . new ( self . class . client_options ) unless @client
79- @client
78+ client = Aws ::S3 ::Client . new ( self . class . client_options )
79+ log_credential_info ( client )
80+ client
8081 end
8182
8283 def get_resource
83- @resource = Aws ::S3 ::Resource . new ( self . class . client_options ) unless @resource
84- @resource
84+ resource = Aws ::S3 ::Resource . new ( self . class . client_options )
85+ log_credential_info ( resource . client )
86+ resource
87+ end
88+
89+ def log_credential_info ( client )
90+ creds = client . config . credentials
91+ if creds . respond_to? ( :expiration )
92+ Rails . logger . info ( "[BookStore] AWS credentials expiration: \\ #{ creds . expiration } " )
93+ else
94+ Rails . logger . info ( "[BookStore] AWS credentials: \\ #{ creds . inspect } " )
95+ end
96+ rescue => e
97+ Rails . logger . warn ( "[BookStore] Could not log AWS credential info: \\ #{ e } " )
8598 end
8699
87100end
You can’t perform that action at this time.
0 commit comments