Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 27 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,11 @@ Or install it yourself as:

$ gem install tfoutputs




## Pre-requistes

Ruby >= 2.2.2
Your terraform state file also needs to be generated by terraform > 0.7.0 there are currently no plans to support terraform < 0.7.0



## Usage

Require the gem:
Expand All @@ -63,6 +58,33 @@ S3 backends also have the following optional parameters:

**profile** - The AWS Credential profile to use.

If you have not set profile in the parmaters, make sure your AWS enviroment variables are set:
```ruby
ENV["AWS_DEFAULT_REGION"]
ENV["AWS_PROFILE"]
ENV["AWS_SESSION_TOKEN"]
ENV["AWS_ACCESS_KEY_ID"]
ENV["AWS_SECRET_ACCESS_KEY"]
```

For example:
```ruby
sts = Aws::STS::Client.new(
access_key_id: access_key_id,
secret_access_key: secret_access_key
)
role_credentials = Aws::AssumeRoleCredentials.new(
client: sts,
role_arn: "arn:aws:iam::#{accountnum}:role/#{assumerole}",
role_session_name: awsusername
)
ENV["AWS_DEFAULT_REGION"] = 'eu-west-1'
ENV["AWS_PROFILE"] = awsusername
ENV["AWS_SESSION_TOKEN"] = role_credentials.credentials.session_token
ENV["AWS_ACCESS_KEY_ID"] = role_credentials.credentials.access_key_id
ENV["AWS_SECRET_ACCESS_KEY"] = role_credentials.credentials.secret_access_key
```

Setting up a file backend:
```ruby
config = {:backend => 'file', :options => { :file_path => '/path/to/state/file/terraform.tfstate' } }
Expand All @@ -71,7 +93,6 @@ puts(state_reader.my_output_name)

```


Using multiple states with multiple backends:

```ruby
Expand Down