diff --git a/README.md b/README.md index b0c1b4f..684fe5b 100644 --- a/README.md +++ b/README.md @@ -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: @@ -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' } } @@ -71,7 +93,6 @@ puts(state_reader.my_output_name) ``` - Using multiple states with multiple backends: ```ruby