Skip to content

Commit ce8a809

Browse files
committed
Update README with Aws::Google.config usage
1 parent bf31261 commit ce8a809

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

README.md

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -48,21 +48,23 @@ your Google Client ID (`accounts.google.com:aud`) and a specific set of Google A
4848
}
4949
```
5050

51-
- In your Ruby code, construct an `Aws::Google` object by passing in the AWS role, client id and client secret:
51+
- In your Ruby code, construct an `Aws::Google` object by passing the AWS `role_arn`, Google `client_id` and `client_secret`, either as constructor arguments or via the `Aws::Google.config` global defaults:
5252
```ruby
5353
require 'aws/google'
5454

55-
aws_role = 'arn:aws:iam::[AccountID]:role/[Role]'
56-
client_id = '123456789012-abcdefghijklmnopqrstuvwzyz0123456.apps.googleusercontent.com'
57-
client_secret = '01234567890abcdefghijklmn'
55+
options = {
56+
aws_role: 'arn:aws:iam::[AccountID]:role/[Role]',
57+
client_id: '123456789012-abcdefghijklmnopqrstuvwzyz0123456.apps.googleusercontent.com',
58+
client_secret: '01234567890abcdefghijklmn'
59+
}
5860

59-
role_credentials = Aws::Google.new(
60-
role_arn: aws_role,
61-
google_client_id: client_id,
62-
google_client_secret: client_secret
63-
)
61+
# Pass constructor arguments:
62+
credentials = Aws::Google.new(options)
63+
puts Aws::STS::Client.new(credentials: credentials).get_caller_identity
6464

65-
puts Aws::STS::Client.new(credentials: role_credentials).get_caller_identity
65+
# Set global defaults:
66+
Aws::Google.config = options
67+
puts Aws::STS::Client.new.get_caller_identity
6668
```
6769

6870
- Or, add the properties to your AWS config profile ([`~/.aws/config`](https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-files.html#cli-configure-files-where)) to use Google as the AWS credential provider without any changes to your application code:

0 commit comments

Comments
 (0)