diff --git a/lib/templates/examples/hcl/module/main.tf b/lib/templates/examples/hcl/module/main.tf index 200cc9c6..2db14134 100644 --- a/lib/templates/examples/hcl/module/main.tf +++ b/lib/templates/examples/hcl/module/main.tf @@ -1,5 +1,3 @@ resource "random_pet" "this" { - keepers = { - name = var.name - } + length = var.length } diff --git a/lib/templates/examples/hcl/module/variables.tf b/lib/templates/examples/hcl/module/variables.tf index 1737163b..13671c56 100644 --- a/lib/templates/examples/hcl/module/variables.tf +++ b/lib/templates/examples/hcl/module/variables.tf @@ -1,5 +1,5 @@ -variable "name" { - type = string - description = "pet name" - default = "example-name" +variable "length" { + type = number + description = "number of words" + default = 2 } diff --git a/lib/templates/examples/hcl/stack/main.tf b/lib/templates/examples/hcl/stack/main.tf index bfa3f5e3..5eca1731 100644 --- a/lib/templates/examples/hcl/stack/main.tf +++ b/lib/templates/examples/hcl/stack/main.tf @@ -1,4 +1,4 @@ module "pet" { source = "../../modules/example" - name = var.name + length = var.length } diff --git a/lib/templates/examples/hcl/stack/variables.tf b/lib/templates/examples/hcl/stack/variables.tf index fcc6b4b4..13671c56 100644 --- a/lib/templates/examples/hcl/stack/variables.tf +++ b/lib/templates/examples/hcl/stack/variables.tf @@ -1,5 +1,5 @@ -variable "name" { - type = string - description = "pet name" - default = "demo-name" +variable "length" { + type = number + description = "number of words" + default = 2 } diff --git a/lib/templates/examples/ruby/module/main.rb b/lib/templates/examples/ruby/module/main.rb index 50fe99da..ddfc6928 100644 --- a/lib/templates/examples/ruby/module/main.rb +++ b/lib/templates/examples/ruby/module/main.rb @@ -1,5 +1,3 @@ resource("random_pet", "this", - keepers: { - name: var.name - } + length: var.length ) diff --git a/lib/templates/examples/ruby/module/variables.rb b/lib/templates/examples/ruby/module/variables.rb index 8831e757..f1d9346f 100644 --- a/lib/templates/examples/ruby/module/variables.rb +++ b/lib/templates/examples/ruby/module/variables.rb @@ -1,4 +1,5 @@ -variable("name", - description: "pet name", - default: "example-name", +variable("length", + type: :number, + description: "number of words", + default: 2, ) diff --git a/lib/templates/examples/ruby/stack/main.rb b/lib/templates/examples/ruby/stack/main.rb index 97739d5d..e5ce485d 100644 --- a/lib/templates/examples/ruby/stack/main.rb +++ b/lib/templates/examples/ruby/stack/main.rb @@ -1,4 +1,4 @@ module!("pet", source: "../../modules/example", - name: var.name, + length: var.length, ) diff --git a/lib/templates/examples/ruby/stack/variables.rb b/lib/templates/examples/ruby/stack/variables.rb index 59a3ef46..f1d9346f 100644 --- a/lib/templates/examples/ruby/stack/variables.rb +++ b/lib/templates/examples/ruby/stack/variables.rb @@ -1,4 +1,5 @@ -variable("name", - description: "pet name", - default: "demo-name", +variable("length", + type: :number, + description: "number of words", + default: 2, ) diff --git a/lib/templates/hcl/project/config/terraform/provider.tf b/lib/templates/hcl/project/config/terraform/provider.tf index 844fc1d2..960157ab 100644 --- a/lib/templates/hcl/project/config/terraform/provider.tf +++ b/lib/templates/hcl/project/config/terraform/provider.tf @@ -1,25 +1,6 @@ -# This is where you put your provider declaration. Here are some examples: +# This is where you put your provider declaration. # -# provider "aws" { -# region = "<%= ENV['AWS_REGION'] || 'us-east-1' %>" -# } -# -# Docs: https://www.terraform.io/docs/providers/aws/index.html -# -# provider "azurerm" { -# features {} # required -# } -# -# Docs: https://www.terraform.io/docs/providers/aws/index.html -# -# provider "google" { -# project = "REPLACE_ME" -# region = "us-central1" # update to your region -# zone = "us-central1-a" # update to your zone -# } -# -# Docs: https://www.terraform.io/docs/providers/google/index.html -# -# Note: If you add a provider, you should also configure a terraspace_plugin_* gem +# If you end up adding a cloud provider, you should also configure a terraspace_plugin_* gem # in the Terraspace project Gemfile and run bundle. -# \ No newline at end of file +# +# See: https://terraspace.cloud/docs/plugins/ diff --git a/lib/terraspace/cli/new/example.rb b/lib/terraspace/cli/new/example.rb index d78c035a..6ef2ce58 100644 --- a/lib/terraspace/cli/new/example.rb +++ b/lib/terraspace/cli/new/example.rb @@ -8,8 +8,9 @@ class Example < Thor::Group def self.options # default is nil for autodetection [ - [:plugin, aliases: %w[p], default: nil, type: :string], [:force, aliases: %w[f], type: :boolean, desc: "Force overwrite"], + [:lang, default: "hcl", desc: "Language to use: HCL/ERB or Ruby DSL"], + [:plugin, aliases: %w[p], default: nil, type: :string], ] end options.each { |args| class_option(*args) } @@ -28,6 +29,7 @@ def cli_args ['--plugin', 'none'] # override default of aws end args << "--force" if @options[:force] + args += ["--lang", @options[:lang]] if @options[:lang] args end end diff --git a/lib/terraspace/cli/new/stack.rb b/lib/terraspace/cli/new/stack.rb index e832e799..9351da13 100644 --- a/lib/terraspace/cli/new/stack.rb +++ b/lib/terraspace/cli/new/stack.rb @@ -2,7 +2,8 @@ class Terraspace::CLI::New class Stack < Sequence component_options.each { |args| class_option(*args) } - argument :name + # default so terraspace new example works without a Thor warning + argument :name, default: "demo" def create_stack puts "=> Creating new stack called #{name}"