Project

tfoutputs

0.01
No commit activity in last 3 years
No release in over 3 years
Sometimes we want to use the outputs of terraform in our ruby code for generating dashboard etc.. This gem enables this
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 10.0
~> 3.5
~> 3.0
~> 2.1

Runtime

 Project Readme
    ____        __             ____________     ____        __              __      
   / __ \__  __/ /_  __  __   /_  __/ ____/    / __ \__  __/ /_____  __  __/ /______
  / /_/ / / / / __ \/ / / /    / / / /_       / / / / / / / __/ __ \/ / / / __/ ___/
 / _, _/ /_/ / /_/ / /_/ /    / / / __/      / /_/ / /_/ / /_/ /_/ / /_/ / /_(__  ) 
/_/ |_|\__,_/_.___/\__, /    /_/ /_/         \____/\__,_/\__/ .___/\__,_/\__/____/  
                  /____/                                   /_/                      

Build Status Gem Version

Ruby TF Outputs

This gem is a ruby interface to access your terraform outputs.

Installation

Add this line to your application's Gemfile:

gem 'tfoutputs'

And then execute:

$ bundle

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:

require 'tfoutputs'

tfoutputs uses 'backends' as a means of retrieving the state files. A backend is a place where the terraform state file lives. Currently only two are supported: s3 and file.

Setting up an s3 backend:

config = {:backend => 's3',:options => {:bucket_name => 'my-bucket-name-goes-here',
           :bucket_region => 'eu-west-1', :bucket_key => 'terraform.tfstate' }
         }
state_reader = TfOutputs.configure(config)
puts(state_reader.my_output_name)

S3 backends also have the following optional parameters:

profile - The AWS Credential profile to use.

Setting up a file backend:

config = {:backend => 'file', :options => { :file_path => '/path/to/state/file/terraform.tfstate' } }
state_reader = TfOutputs.configure(config)
puts(state_reader.my_output_name)

Using multiple states with multiple backends:

config = [{:backend => 's3',:options => {:bucket_name => 'my-bucket-name-goes-here',
           :bucket_region => 'eu-west-1', :bucket_key => 'terraform.tfstate' }
         },
          {:backend => 'file', :options => { :file_path => '/path/to/state/file/terraform.tfstate' } }
        ]
state_reader = TfOutputs.configure(config)
puts(state_reader.my_output_name)

Blog post on tfoutputs

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/jae2/ruby-tfoutput. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.

License

The gem is available as open source under the terms of the MIT License.