lib/terraforming/cli.rb in terraforming-0.7.0 vs lib/terraforming/cli.rb in terraforming-0.8.0
- old
+ new
@@ -2,10 +2,11 @@
class CLI < Thor
class_option :merge, type: :string, desc: "tfstate file to merge"
class_option :overwrite, type: :boolean, desc: "Overwrite existng 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"
desc "asg", "AutoScaling Group"
def asg
execute(Terraforming::Resource::AutoScalingGroup, options)
end
@@ -93,10 +94,15 @@
desc "iamup", "IAM User Policy"
def iamup
execute(Terraforming::Resource::IAMUserPolicy, options)
end
+ desc "lc", "Launch Configuration"
+ def lc
+ execute(Terraforming::Resource::LaunchConfiguration, options)
+ end
+
desc "igw", "Internet Gateway"
def igw
execute(Terraforming::Resource::InternetGateway, options)
end
@@ -153,18 +159,30 @@
desc "sn", "Subnet"
def sn
execute(Terraforming::Resource::Subnet, options)
end
+ desc "sqs", "SQS"
+ def sqs
+ execute(Terraforming::Resource::SQS, options)
+ end
+
desc "vpc", "VPC"
def vpc
execute(Terraforming::Resource::VPC, options)
end
+ desc "vgw", "VPN Gateway"
+ def vgw
+ execute(Terraforming::Resource::VPNGateway, options)
+ end
+
+
private
def execute(klass, options)
Aws.config[:credentials] = Aws::SharedCredentials.new(profile_name: options[:profile]) if options[:profile]
+ Aws.config[:region] = options[:region] if options[:region]
result = options[:tfstate] ? tfstate(klass, options[:merge]) : tf(klass)
if options[:tfstate] && options[:merge] && options[:overwrite]
open(options[:merge], "w+") do |f|
f.write(result)