Skip to content

Commit 2514c49

Browse files
committed
Add howto section for AWS EC2 authentication
1 parent e632ba8 commit 2514c49

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,16 @@ client_1 = Vault::Client.new(address: "https://vault.mycompany.com")
7979
client_2 = Vault::Client.new(address: "https://other-vault.mycompany.com")
8080
```
8181

82+
And if you want to authenticate with a `AWS EC2` :
83+
84+
```ruby
85+
# Export VAULT_ADDR to ENV then
86+
# Get the pkcs7 value from AWS
87+
signature = `curl http://169.254.169.254/latest/dynamic/instance-identity/pkcs7`
88+
vault_token = Vault.auth.aws_ec2(ENV['EC2_ROLE'], signature, nil)
89+
vault_client = Vault::Client.new(address: ENV["VAULT_ADDR"], token: vault_token.auth.client_token)
90+
```
91+
8292
### Making requests
8393
All of the methods and API calls are heavily documented with examples inline using YARD. In order to keep the examples versioned with the code, the README only lists a few examples for using the Vault gem. Please see the inline documentation for the full API documentation. The tests in the 'spec' directory are an additional source of examples.
8494

0 commit comments

Comments
 (0)