Class: TfOutputs::Configurator::Backends::S3StateConfiguration
- Inherits:
-
Object
- Object
- TfOutputs::Configurator::Backends::S3StateConfiguration
- Defined in:
- lib/tfoutputs/configurator/backends/s3_state_configuration.rb
Instance Method Summary collapse
-
#initialize(options) ⇒ S3StateConfiguration
constructor
A new instance of S3StateConfiguration.
- #save ⇒ Object
Constructor Details
#initialize(options) ⇒ S3StateConfiguration
9 10 11 12 13 14 |
# File 'lib/tfoutputs/configurator/backends/s3_state_configuration.rb', line 9 def initialize() @bucket_name = [:bucket_name] @bucket_key = [:bucket_key] @bucket_region = [:bucket_region] @profile = [:profile] ? [:profile] : nil end |
Instance Method Details
#save ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/tfoutputs/configurator/backends/s3_state_configuration.rb', line 16 def save file = Tempfile.new('tf_state') # Setup the base client config which must always have a bucket region client_config = {region: @bucket_region} # if a profile was supplied, then add that to the client config if !@profile.nil? client_config[:profile] = @profile end # setup s3 client s3 = Aws::S3::Client.new(client_config) resp = s3.get_object bucket: @bucket_name, key: @bucket_key file.write(resp.body.string) file.rewind file end |