lib/terraforming/cli.rb in terraforming-0.15.0 vs lib/terraforming/cli.rb in terraforming-0.16.0

- old
+ new

@@ -3,10 +3,11 @@ class_option :merge, type: :string, desc: "tfstate file to merge" class_option :overwrite, type: :boolean, desc: "Overwrite existing tfstate" class_option :tfstate, type: :boolean, desc: "Generate tfstate" class_option :profile, type: :string, desc: "AWS credentials profile" class_option :region, type: :string, desc: "AWS region" + class_option :assume, type: :string, desc: "Role ARN to assume" class_option :use_bundled_cert, type: :boolean, desc: "Use the bundled CA certificate from AWS SDK" desc "alb", "ALB" @@ -227,9 +228,16 @@ private def configure_aws(options) Aws.config[:credentials] = Aws::SharedCredentials.new(profile_name: options[:profile]) if options[:profile] Aws.config[:region] = options[:region] if options[:region] + + if options[:assume] + args = { role_arn: options[:assume], role_session_name: "terraforming-session-#{Time.now.to_i}" } + args[:client] = Aws::STS::Client.new(profile: options[:profile]) if options[:profile] + Aws.config[:credentials] = Aws::AssumeRoleCredentials.new(args) + end + Aws.use_bundled_cert! if options[:use_bundled_cert] end def execute(klass, options) configure_aws(options)