Giter Site home page Giter Site logo

Comments (24)

CumpsD avatar CumpsD commented on September 28, 2024 2

The caller debug is sadly enough empty:

terraspace up demo
The system cannot find the path specified.
WARN: The command 'file' is not installed.
Unable to check if files are text or binary files as a part of the Terraspace compile processing.
Assuming all files are not binary file.

Please install the file command to remove this warning message.
caller:
C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/terraspace-1.1.1/lib/terraspace/compiler/dsl/syntax/mod.rb:4:in `<module:Mod>'
C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/terraspace-1.1.1/lib/terraspace/compiler/dsl/syntax/mod.rb:2:in `<module:Syntax>'
C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/terraspace-1.1.1/lib/terraspace/compiler/dsl/syntax/mod.rb:1:in `<top (required)>'
C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/zeitwerk-2.5.4/lib/zeitwerk/kernel.rb:27:in `require'
C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/zeitwerk-2.5.4/lib/zeitwerk/kernel.rb:27:in `require'
C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/terraspace-1.1.1/lib/terraspace/compiler/erb/helpers.rb:3:in `<module:Helpers>'
C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/terraspace-1.1.1/lib/terraspace/compiler/erb/helpers.rb:2:in `<module:Erb>'
C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/terraspace-1.1.1/lib/terraspace/compiler/erb/helpers.rb:1:in `<top (required)>'
C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/zeitwerk-2.5.4/lib/zeitwerk/kernel.rb:27:in `require'
C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/zeitwerk-2.5.4/lib/zeitwerk/kernel.rb:27:in `require'
C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/terraspace-1.1.1/lib/terraspace/compiler/erb/context.rb:3:in `<class:Context>'
C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/terraspace-1.1.1/lib/terraspace/compiler/erb/context.rb:2:in `<module:Erb>'
C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/terraspace-1.1.1/lib/terraspace/compiler/erb/context.rb:1:in `<top (required)>'
C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/zeitwerk-2.5.4/lib/zeitwerk/kernel.rb:27:in `require'
C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/zeitwerk-2.5.4/lib/zeitwerk/kernel.rb:27:in `require'
C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/terraspace-1.1.1/lib/terraspace/compiler/erb/render.rb:8:in `build'
C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/terraspace-1.1.1/lib/terraspace/compiler/strategy/mod/tf.rb:4:in `run'
C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/terraspace-1.1.1/lib/terraspace/compiler/strategy/mod.rb:6:in `run'
C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/terraspace-1.1.1/lib/terraspace/compiler/cleaner/backend_change.rb:40:in `fresh_backend'
C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/terraspace-1.1.1/lib/terraspace/compiler/cleaner/backend_change.rb:21:in `purge?'
C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/terraspace-1.1.1/lib/terraspace/compiler/cleaner/backend_change.rb:10:in `purge'
C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/terraspace-1.1.1/lib/terraspace/compiler/cleaner.rb:16:in `backend_change_purge'
C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/terraspace-1.1.1/lib/terraspace/compiler/cleaner.rb:9:in `clean'
C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/terraspace-1.1.1/lib/terraspace/builder.rb:71:in `clean'
C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/terraspace-1.1.1/lib/terraspace/builder.rb:23:in `run'
C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/terraspace-1.1.1/lib/terraspace/cli/up.rb:20:in `build'
C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/terraspace-1.1.1/lib/terraspace/cli/up.rb:8:in `run'
C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/terraspace-1.1.1/lib/terraspace/cli.rb:230:in `up'
C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/thor-1.2.1/lib/thor/command.rb:27:in `run'
C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/thor-1.2.1/lib/thor/invocation.rb:127:in `invoke_command'
C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/thor-1.2.1/lib/thor.rb:392:in `dispatch'
C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/terraspace-1.1.1/lib/terraspace/command.rb:61:in `dispatch'
C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/thor-1.2.1/lib/thor/base.rb:485:in `start'
C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/terraspace-1.1.1/lib/terraspace/cli/concern.rb:65:in `start'
C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/terraspace-1.1.1/exe/terraspace:14:in `<top (required)>'
C:/Ruby31-x64/bin/terraspace:25:in `load'
C:/Ruby31-x64/bin/terraspace:25:in `<main>'

However, this works nicely:

module Terraspace::Compiler::Dsl::Syntax
  module Mod
    include Terraspace::Util::Logging
    # include_dir("mod")
    # include_dir("helpers")

    include Terraspace::Compiler::Dsl::Syntax::Mod::Backend
    include Terraspace::Compiler::Dsl::Syntax::Mod::Data
    include Terraspace::Compiler::Dsl::Syntax::Mod::Locals
    include Terraspace::Compiler::Dsl::Syntax::Mod::Module
    include Terraspace::Compiler::Dsl::Syntax::Mod::Output
    include Terraspace::Compiler::Dsl::Syntax::Mod::Provider
    include Terraspace::Compiler::Dsl::Syntax::Mod::Resource
    include Terraspace::Compiler::Dsl::Syntax::Mod::Terraform
    include Terraspace::Compiler::Dsl::Syntax::Mod::Variable
    include Terraspace::Compiler::Dsl::Syntax::Helpers::Common

    include_plugin_helpers
    include_project_level_helpers
  end
end

This change fixed it :)

I will have a look at the PR hold on

from terraspace.

tongueroo avatar tongueroo commented on September 28, 2024

Pretty sure it's the way the terraform path is being checked by terraspace. It uses linux-specific commands. Currently, windows is not supported. See: https://terraspace.cloud/docs/install/dependencies/ Want to get to it, it's a matter of time.

from terraspace.

vivek221994 avatar vivek221994 commented on September 28, 2024

Thank you.

from terraspace.

CumpsD avatar CumpsD commented on September 28, 2024

Oh, that's a pitty, since terraform works on Windows, I would've thought it was no problem

from terraspace.

tongueroo avatar tongueroo commented on September 28, 2024

Yup. It's a bummer. Looks like others are using WSL2 #188 (comment) Notice folks using Windows Subsystem for other tools like jets also. Get it if that doesn't work for all. That's the recommendation for now, though.

from terraspace.

CumpsD avatar CumpsD commented on September 28, 2024

Would it be possible to add an override flag?

To avoid doing this:

out = `type terraform 2>&1`.strip

Then it's our responsibility to have it on the PATH, which should work because you are just called terraform anyway

from terraspace.

tongueroo avatar tongueroo commented on September 28, 2024

Open to it adding an override. Though, thinking it'll require more than that to get working for Windows. 🤔 It'll probably require brute force 💪🤣 If you're up for it, thinking try editing your current install in-place and going from there. So please try that first. Thanks.

from terraspace.

CumpsD avatar CumpsD commented on September 28, 2024

Yeah, I started doing that just now :)

This gets around the tf check ;)

    def terraform_bin
      out = "/c/Hashicorp/terraform.exe is terraform.exe".strip
      # return unless $?.success?
      md = out.match(/is (.*)/)
      md[1] if md
    end
    memoize :terraform_bin

==>

terraspace setup check
Detected Terrspace version: 1.1.1
Detected Terraform bin: terraform.exe
Detected Terraform v1.1.5
Terraspace requires Terraform v0.12.x and above
You're all set!

Next step is harder:

Building .terraspace-cache/eu-central-1/dev/stacks/demo
The system cannot find the path specified.
WARN: The command 'file' is not installed.
Unable to check if files are text or binary files as a part of the Terraspace compile processing.
Assuming all files are not binary file.

Please install the file command to remove this warning message.
The system cannot find the path specified.
The system cannot find the path specified.
The system cannot find the path specified.
NoMethodError: undefined method `expansion' for #<Terraspace::Compiler::Erb::Context:0x00000266b45f7d88 @mod=#<Terraspace::Mod:0x00000266b4e65970 @options={"init"=>true, "mod"=>"demo", "args"=>[]}, @name="demo", @consider_stacks=true, @instance=nil, @resolved=true, @_memoized_root="C:/Work/Terraspace/terratest/infra/app/stacks/demo", @root_module=true, @_memoized_cache_dir="C:/Work/Terraspace/terratest/infra/.terraspace-cache/eu-central-1/dev/stacks/demo">, @options={"init"=>true, "mod"=>"demo", "args"=>[]}>
Error evaluating ERB template around line 0 of: C:/Work/Terraspace/terratest/infra/config/terraform/backend.tf:
1 terraform {
2   backend "s3" {
3     bucket         = "<%= expansion('terraform-state-:ACCOUNT-:REGION-:ENV') %>"
4     key            = "<%= expansion(':REGION/:ENV/:BUILD_DIR/terraform.tfstate') %>"
5     region         = "<%= expansion(':REGION') %>"

Original backtrace (last 8 lines):
C:/Work/Terraspace/terratest/infra/config/terraform/backend.tf:3:in `__tilt_7300'
C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/tilt-2.0.10/lib/tilt/template.rb:170:in `call'
C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/tilt-2.0.10/lib/tilt/template.rb:170:in `evaluate'
C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/tilt-2.0.10/lib/tilt/template.rb:109:in `render'
C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/render_me_pretty-0.8.4/lib/render_me_pretty/erb.rb:91:in `render'
C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/render_me_pretty-0.8.4/lib/render_me_pretty.rb:11:in `result'
C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/terraspace-1.1.1/lib/terraspace/compiler/erb/render.rb:9:in `build'
C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/terraspace-1.1.1/lib/terraspace/compiler/strategy/mod/tf.rb:4:in `run'

Re-run with FULL_BACKTRACE=1 to see all lines

from terraspace.

tongueroo avatar tongueroo commented on September 28, 2024

Guessing it's the beginnings of an Alice In Wonderland rabbit hole 👧🐰🕳 Am interested in how much work it would be. Appreciate any helpful updates. Even if it turns out that it's a no-go.

Right now, gut says it's probably a lot more 🤣 Unsure. Been hoping am wrong though. Also, been curious to give WSL2 a try. It's a matter of time ⏳ 🤦🏻‍♂️

from terraspace.

CumpsD avatar CumpsD commented on September 28, 2024

WSL 2 should give you no problems.

As for the above, when I remove the ERB template it continues :)

terraspace up demo
Building .terraspace-cache/eu-central-1/dev/stacks/demo
The system cannot find the path specified.
WARN: The command 'file' is not installed.
Unable to check if files are text or binary files as a part of the Terraspace compile processing.
Assuming all files are not binary file.

Please install the file command to remove this warning message.
The system cannot find the path specified.
The system cannot find the path specified.
The system cannot find the path specified.
The system cannot find the path specified.
The system cannot find the path specified.
The system cannot find the path specified.
The system cannot find the path specified.
Built in .terraspace-cache/eu-central-1/dev/stacks/demo
Current directory: .terraspace-cache/eu-central-1/dev/stacks/demo
=> terraform init -get -input=false >> /tmp/terraspace/log/init/demo.log
=> terraform apply -input=false

Terraform used the selected providers to generate the following execution
plan. Resource actions are indicated with the following symbols:
  + create


Terraform will perform the following actions:

  # random_pet.this will be created
  + resource "random_pet" "this" {
      + id        = (known after apply)
      + length    = 2
      + separator = "-"
    }

  # module.bucket.aws_s3_bucket.this will be created
  + resource "aws_s3_bucket" "this" {
      + acceleration_status                  = (known after apply)
      + acl                                  = (known after apply)
      + arn                                  = (known after apply)
      + bucket                               = (known after apply)
      + bucket_domain_name                   = (known after apply)
      + bucket_regional_domain_name          = (known after apply)
      + cors_rule                            = (known after apply)
      + force_destroy                        = false
      + grant                                = (known after apply)
      + hosted_zone_id                       = (known after apply)
      + id                                   = (known after apply)
      + lifecycle_rule                       = (known after apply)
      + logging                              = (known after apply)
      + policy                               = (known after apply)
      + region                               = (known after apply)
      + replication_configuration            = (known after apply)
      + request_payer                        = (known after apply)
      + server_side_encryption_configuration = (known after apply)
      + tags_all                             = (known after apply)
      + versioning                           = (known after apply)
      + website                              = (known after apply)
      + website_domain                       = (known after apply)
      + website_endpoint                     = (known after apply)


              + grantee {
                  + display_name  = (known after apply)
                  + email_address = (known after apply)
                  + id            = (known after apply)
                  + type          = (known after apply)
                  + uri           = (known after apply)
                }
            }

          + owner {
              + display_name = (known after apply)
              + id           = (known after apply)
            }
        }
    }

Plan: 3 to add, 0 to change, 0 to destroy.

Changes to Outputs:
  + bucket_name = (known after apply)

Do you want to perform these actions?
  Terraform will perform the actions described above.
  Only 'yes' will be accepted to approve.

  Enter a value:

The The system cannot find the path specified. error is the fact it can't do file

It's having trouble on expansion() in the template now

I'm not a Ruby dev btw ;) Just experimenting changing the code now, not sure if expansion is something built in, or something terraspace provides

from terraspace.

tongueroo avatar tongueroo commented on September 28, 2024

Oh wow. Surprised it got that far 🎉 Lol 🤣

RE: expansion

Here's a code trace:

Interestingly, ripped out the deprecated Microsoft deprecated azure mgmt sdk recently with a leaner REST implementation: boltops-tools/terraspace_plugin_azurerm#14

This might actually give it a fighting chance to work natively on windows.

from terraspace.

CumpsD avatar CumpsD commented on September 28, 2024

I managed to get to here:

delegate :expand, :expansion, to: :expander

When I added

def expansion x
  puts "Wah"
end

The error went away and called it :)

So something is up with the delegate ..... to I guess, but then my Ruby knowledge lacks ;)

from terraspace.

tongueroo avatar tongueroo commented on September 28, 2024

The delegate method is magic provided by Rails ActiveSupport. Dug into it and here's the definition https://github.com/rails/rails/blob/main/activesupport/lib/active_support/core_ext/module/delegation.rb#L171-L241
As I said, it's magically 🤣 Guessing the (ab)use of module_eval is bombing on Windows.

This may be a simple fix though. Give this a go:

terraspace/lib/terraspace/compiler/expander.rb

    # comment this out
    # delegate :expand, :expansion, to: :expander
    
    # add this
    def expansion(string)
      expander.expansion(string
    end
    alias_method :expand, :expansion

from terraspace.

CumpsD avatar CumpsD commented on September 28, 2024

No luck, I added:

    def expansion(string)
      puts "expander.rb"
      expander.expansion(string)
    end
    alias_method :expand, :expansion

Which blows out again:

terraspace up demo
expander.rb
Building .terraspace-cache/eu-central-1/dev/stacks/demo
expander.rb
The system cannot find the path specified.
WARN: The command 'file' is not installed.
Unable to check if files are text or binary files as a part of the Terraspace compile processing.
Assuming all files are not binary file.

Please install the file command to remove this warning message.
The system cannot find the path specified.
The system cannot find the path specified.
The system cannot find the path specified.
NoMethodError: undefined method `expansion' for #<Terraspace::Compiler::Erb::Context:0x000001da4d399fa8 @mod=#<Terraspace::Mod:0x000001da4c90d238 @options={"init"=>true, "mod"=>"demo", "args"=>[]}, @name="demo", @consider_stacks=true, @instance=nil, @resolved=true, @_memoized_root="C:/Work/Terraspace/terratest/infra/app/stacks/demo", @root_module=true, @_memoized_cache_dir="C:/Work/Terraspace/terratest/infra/.terraspace-cache/eu-central-1/dev/stacks/demo">, @options={"init"=>true, "mod"=>"demo", "args"=>[]}>

It calls it twice, but passing it down to the expander fails.

from terraspace.

CumpsD avatar CumpsD commented on September 28, 2024

Actually, my bad! It calls the extension.

C:\Ruby31-x64\lib\ruby\gems\3.1.0\gems\terraspace_plugin_aws-0.3.7\lib\terraspace_plugin_aws\interfaces\expander.rb

require "aws_data"

module TerraspacePluginAws::Interfaces
  class Expander
    include Terraspace::Plugin::Expander::Interface
    delegate :account, :region, to: :aws_data
    alias_method :namespace, :account
    alias_method :location, :region

    def expansion(string)
      puts "aws!"
    end

    def aws_data
      $__aws_data ||= AwsData.new
    end

    def expand_string?(string)
      !string.include?("arn:")
    end
  end
end

This prints "aws!" :) Now to figure out what needs to go in expansion to make it work :)

The current output, with the above code change:

C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/terraspace-1.1.1/lib/terraspace/util/pretty.rb:16:in `pretty_path': undefined method `sub' for nil:NilClass (NoMethodError)

      path.sub("#{Terraspace.root}/",'').sub(ENV['HOME'], '~')
          ^^^^
        from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/terraspace-1.1.1/lib/terraspace/builder.rb:34:in `build'
        from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/terraspace-1.1.1/lib/terraspace/builder.rb:25:in `run'
        from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/terraspace-1.1.1/lib/terraspace/cli/up.rb:20:in `build'
        from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/terraspace-1.1.1/lib/terraspace/cli/up.rb:8:in `run'
        from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/terraspace-1.1.1/lib/terraspace/cli.rb:230:in `up'
        from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/thor-1.2.1/lib/thor/command.rb:27:in `run'
        from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/thor-1.2.1/lib/thor/invocation.rb:127:in `invoke_command'
        from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/thor-1.2.1/lib/thor.rb:392:in `dispatch'
        from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/terraspace-1.1.1/lib/terraspace/command.rb:61:in `dispatch'
        from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/thor-1.2.1/lib/thor/base.rb:485:in `start'
        from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/terraspace-1.1.1/lib/terraspace/cli/concern.rb:65:in `start'
        from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/terraspace-1.1.1/exe/terraspace:14:in `<top (required)>'
        from C:/Ruby31-x64/bin/terraspace:25:in `load'
        from C:/Ruby31-x64/bin/terraspace:25:in `<main>'

Which I tried to bypass by just returning path again, without sub. but then it turns out in builder.rs that @mod.cache_dir is an empty string

    def build(modules: true)
      puts @mod.cache_dir
      build_dir = Util.pretty_path(@mod.cache_dir)
      placeholder_stack_message
      logger.info "Building #{build_dir}" unless @options[:quiet] # from terraspace all
      FileUtils.mkdir_p(@mod.cache_dir) # so terraspace before build hooks work
      run_hooks("terraspace.rb", "build") do
        build_dir("modules") if modules
        build_stacks
        logger.info "Built in #{build_dir}" unless @options[:quiet] # from terraspace all
      end
    end

from terraspace.

tongueroo avatar tongueroo commented on September 28, 2024

I see. It's a little tricky to see what's going on. Here's the code trace:

  • mod cache_dir method should return a string
    expander.expansion(pattern) # pattern is a String that contains placeholders for substitutions
  • So believe what's happening is that since puts "aws!" returns nil it then breaks later downstream.

So thinking this:

    def expansion(string)
      puts "aws!" # returns nil
      # try returning the string straight through
      string # this is a String, not nil
    end

But then you'll need to edit any place where expansion is used with hard-coded values. Since the expansion method will pass the string straight through.

So instead of:

config/terraform/backend.tf

terraform {
  backend "azurerm" {
    resource_group_name  = "<%= expansion(':ENV-:LOCATION') %>"
    storage_account_name = "<%= expansion('ts:SUBSCRIPTION_HASH:LOCATION:ENV') %>"
    container_name       = "terraform-state"
    key                  = "<%= expansion(':LOCATION/:ENV/:BUILD_DIR/terraform.tfstate') %>"
  }
}

Hard code values. Something like this:

terraform {
  backend "azurerm" {
    resource_group_name  = "dev-eastus"
    storage_account_name = "tsHASHeastusdev" # it needs to be available
    container_name       = "terraform-state"
    key                  = "eastus/dev/stacks/demo/terraform.tfstate"
  }
}

Another place that the expansion is use is the config.build.cache_dir setting.

So also hard code this configuration. You can just do it in the inline-source code you're hacking on. Or you can do it as a config/app.rb

config/app.rb

Terraspace.configure do |config|
  config.build.cache_dir = "#{Terraspace.root}/.terraspace-cache/test/path"
end

Hope those are all the places. 🤞

from terraspace.

CumpsD avatar CumpsD commented on September 28, 2024

Might as well undo all changes then, if I am not going to use expansion it works ;) See #84 (comment)

from terraspace.

CumpsD avatar CumpsD commented on September 28, 2024

Summary:

gem install terraspace
gem install terraspace_plugin_aws

Edit lib\terraspace\cli\setup\check.rb:

    def terraform_bin
      out = "is terraform.exe".strip
      # return unless $?.success?
      md = out.match(/is (.*)/)
      md[1] if md
    end
    memoize :terraform_bin
terraspace new project infra --examples
PS C:\Work\Terraspace\terratest\infra> terraspace up demo      
The system cannot find the path specified.
WARN: The command 'file' is not installed.
Unable to check if files are text or binary files as a part of the Terraspace compile processing.
Assuming all files are not binary file.

Please install the file command to remove this warning message.
Building .terraspace-cache/eu-central-1/dev/stacks/demo
The system cannot find the path specified.
The system cannot find the path specified.
The system cannot find the path specified.
The system cannot find the path specified.
The system cannot find the path specified.
The system cannot find the path specified.
The system cannot find the path specified.
The system cannot find the path specified.
Built in .terraspace-cache/eu-central-1/dev/stacks/demo
Current directory: .terraspace-cache/eu-central-1/dev/stacks/demo
Creating bucket: terraform-state-xxxxxxx-eu-central-1-dev
Creating dynamodb table: terraform_locks
Waiting for dynamodb table to finish creating...
=> terraform init -get -input=false >> /tmp/terraspace/log/init/demo.log
=> terraform apply -input=false

Terraform used the selected providers to generate the following execution
plan. Resource actions are indicated with the following symbols:
  + create


Terraform will perform the following actions:

  # random_pet.this will be created
  + resource "random_pet" "this" {
      + id        = (known after apply)
      + length    = 2
      + separator = "-"
    }
  # module.bucket.aws_s3_bucket.this will be created
  + resource "aws_s3_bucket" "this" {
      + acceleration_status                  = (known after apply)
      + acl                                  = (known after apply)
      + arn                                  = (known after apply)
      + bucket                               = (known after apply)
      + bucket_domain_name                   = (known after apply)
      + bucket_regional_domain_name          = (known after apply)
      + cors_rule                            = (known after apply)
      + force_destroy                        = false
      + grant                                = (known after apply)
      + hosted_zone_id                       = (known after apply)
      + id                                   = (known after apply)
      + lifecycle_rule                       = (known after apply)
      + logging                              = (known after apply)
      + policy                               = (known after apply)
      + region                               = (known after apply)
      + replication_configuration            = (known after apply)
      + request_payer                        = (known after apply)
      + server_side_encryption_configuration = (known after apply)
      + tags_all                             = (known after apply)
      + versioning                           = (known after apply)
      + website                              = (known after apply)
      + website_domain                       = (known after apply)
      + website_endpoint                     = (known after apply)

      + object_lock_configuration {
          + object_lock_enabled = (known after apply)
          + rule                = (known after apply)
        }
    }
  # module.bucket.aws_s3_bucket_acl.this will be created
  + resource "aws_s3_bucket_acl" "this" {
      + acl    = "private"
      + bucket = (known after apply)
      + id     = (known after apply)

      + access_control_policy {
          + grant {
              + permission = (known after apply)

              + grantee {
                  + display_name  = (known after apply)
                  + email_address = (known after apply)
                  + id            = (known after apply)
                  + type          = (known after apply)
                  + uri           = (known after apply)
                }
            }

          + owner {
              + display_name = (known after apply)
              + id           = (known after apply)
            }
        }
    }

Plan: 3 to add, 0 to change, 0 to destroy.

Changes to Outputs:
  + bucket_name = (known after apply)

Do you want to perform these actions?
  Terraform will perform the actions described above.
  Only 'yes' will be accepted to approve.

  Enter a value: yes
random_pet.this: Creating...
random_pet.this: Creation complete after 0s [id=adapted-piranha]
module.bucket.aws_s3_bucket.this: Creating...
module.bucket.aws_s3_bucket.this: Creation complete after 1s [id=bucket-adapted-piranha]
module.bucket.aws_s3_bucket_acl.this: Creating...
module.bucket.aws_s3_bucket_acl.this: Creation complete after 1s [id=bucket-adapted-piranha,private]

Apply complete! Resources: 3 added, 0 changed, 0 destroyed.


Outputs:

bucket_name = "bucket-adapted-piranha"
Time took: 19s
PS C:\Work\Terraspace\terratest\infra> aws s3 ls
2022-02-16 20:51:11 bucket-adapted-piranha

Seems ok?

from terraspace.

CumpsD avatar CumpsD commented on September 28, 2024

So, if you change the terraform_bin logic to work on windows, or allow it to be skipped, people could use it on Windows without the ERB templates :) I think

from terraspace.

CumpsD avatar CumpsD commented on September 28, 2024

Might have been happy too soon...

First time:

terraspace up demo      
The system cannot find the path specified.
WARN: The command 'file' is not installed.
Unable to check if files are text or binary files as a part of the Terraspace compile processing.
Assuming all files are not binary file.

Please install the file command to remove this warning message.
Building .terraspace-cache/eu-central-1/dev/stacks/demo
The system cannot find the path specified.
The system cannot find the path specified.
The system cannot find the path specified.
The system cannot find the path specified.
The system cannot find the path specified.
The system cannot find the path specified.
The system cannot find the path specified.
The system cannot find the path specified.
Built in .terraspace-cache/eu-central-1/dev/stacks/demo
Current directory: .terraspace-cache/eu-central-1/dev/stacks/demo

Second time:

terraspace up demo
The system cannot find the path specified.
WARN: The command 'file' is not installed.
Unable to check if files are text or binary files as a part of the Terraspace compile processing.
Assuming all files are not binary file.

Please install the file command to remove this warning message.
Building .terraspace-cache/test/path
The system cannot find the path specified.
The system cannot find the path specified.
The system cannot find the path specified.
The system cannot find the path specified.
The system cannot find the path specified.
Built in .terraspace-cache/test/path
Current directory: .terraspace-cache/test/path
=> terraform init -get -input=false >> /tmp/terraspace/log/init/demo.log
╷
│ Error: Unreadable module directory
│
│ Unable to evaluate directory symlink: CreateFile ..\..\modules: The system
│ cannot find the file specified.
╵

╷
│ Error: Failed to read module directory
│
│ Module directory  does not exist or cannot be read.
╵

╷
│ Error: Unreadable module directory
│
│ Unable to evaluate directory symlink: CreateFile ..\..\modules: The system
│ cannot find the file specified.
╵

╷
│ Error: Failed to read module directory
│
│ Module directory  does not exist or cannot be read.
╵

Error running command: terraform init -get -input=false >> /tmp/terraspace/log/init/demo.log

For some reason the second time it tries to build in /test/path?

from terraspace.

CumpsD avatar CumpsD commented on September 28, 2024

Forget that... config.build.cache_dir = "#{Terraspace.root}/.terraspace-cache/test/path" 🤦🏻‍♂️ ofcourse

This change config.build.cache_dir = ":CACHE_ROOT/:REGION/:ENV/:BUILD_DIR" apparently isn't needed to hardcode

from terraspace.

tongueroo avatar tongueroo commented on September 28, 2024

RE: Might as well undo all changes then, if I am not going to use expansion it works ;) See #84 (comment)

Of course 🤣 Duh. My long comment is totally useless. That's hilarious.

RE: Seems ok?
So, if you change the terraform_bin logic to work on windows, or allow it to be skipped, people could use it on Windows without the ERB templates :) I think

Sweet. 🎉

So mainly just got to get the darn expansion method working. Hoping to get that working first 😁

Reviewed a previous comment.

#84 (comment)

Wondering about this error:

NoMethodError: undefined method `expansion' for #<Terraspace::Compiler::Erb::Context:0x000001da4d399fa8 @mod=#<Terraspace::Mod:0x000001da4c90d238 @options={"init"=>true, "mod"=>"demo", "args"=>[]}, @name="demo", @consider_stacks=true, @instance=nil, @resolved=true, @_memoized_root="C:/Work/Terraspace/terratest/infra/app/stacks/demo", @root_module=true, @_memoized_cache_dir="C:/Work/Terraspace/terratest/infra/.terraspace-cache/eu-central-1/dev/stacks/demo">, @options={"init"=>true, "mod"=>"demo", "args"=>[]}>

Dug into it. Here's the code trace:

The Terraspace meta-magic include_dir method is defined here:

def include_dir(dir)

The include_dir method provides a way to include many modules from a relative subfolder dynamically. So wouldn't forget to include them when creating a new one.

Guessing that the use of caller in include_dir on Windows is causing issues and that's the reason why Terraspace::Compiler::Erb::Context does not have the expansion method. Maybe that's the problem.

Wondering if you can give this a go:

Replace this code https://github.com/boltops-tools/terraspace/blob/55b11972e0477313763f49f26fb0d9fface38b15/lib/terraspace/compiler/dsl/syntax/mod.rb with:

module Terraspace::Compiler::Dsl::Syntax
  module Mod
    include Terraspace::Util::Logging

    # comment out these lines
    # include_dir("mod")
    # include_dir("helpers")

    # Use this instead
    include Terraspace::Compiler::Dsl::Syntax::Mod::Backend
    include Terraspace::Compiler::Dsl::Syntax::Mod::Data
    include Terraspace::Compiler::Dsl::Syntax::Mod::Locals
    include Terraspace::Compiler::Dsl::Syntax::Mod::Module
    include Terraspace::Compiler::Dsl::Syntax::Mod::Output
    include Terraspace::Compiler::Dsl::Syntax::Mod::Provider
    include Terraspace::Compiler::Dsl::Syntax::Mod::Resource
    include Terraspace::Compiler::Dsl::Syntax::Mod::Terraform
    include Terraspace::Compiler::Dsl::Syntax::Mod::Variable
    include Terraspace::Compiler::Dsl::Syntax::Helpers::Common

    include_plugin_helpers
    include_project_level_helpers
  end
end

Hoping that solves the issue.

Also, wondering if you can also add to ext/core/module.rb. Post that when you get a chance.

  def include_dir(dir)
    puts "caller:" # add this line
    puts caller    # also add
    calling_file = caller[0].split(':').first # IE: /home/ec2-user/environment/terraspace/lib/terraspace/compiler/dsl/syntax/mod.rb

Thinking that caller lines on windows are different. Let's see if the hard-coded includes above work first. If so, would still like to fix the include_dir so it works on windows also. 👍

from terraspace.

tongueroo avatar tongueroo commented on September 28, 2024

Oh I think I see it. Got a caller stack line from one of your previous comments: #84 (comment)

from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/terraspace-1.1.1/lib/terraspace/builder.rb:34:in `build'

The C: results in

  def include_dir(dir)
    calling_file = caller[0].split(':').first # IE: /home/ec2-user/environment/terraspace/lib/terraspace/compiler/dsl/syntax/mod.rb

From

calling_file = caller[0].split(':').first # IE: /home/ec2-user/environment/terraspace/lib/terraspace/compiler/dsl/syntax/mod.rb

Not grabbing the right path. Think got what is needed for a fix.

from terraspace.

tongueroo avatar tongueroo commented on September 28, 2024

Opened up a PR #202 Wondering if could get some help testing it

How to use a custom version of terraspace docs: https://terraspace.cloud/docs/install/gem/custom-version/#gemfile-forked-git-source

Gemfile

source "https://rubygems.org"
gem 'terraspace', git: 'https://github.com/boltops-tools/terraspace', branch: "windows"

Then run

bundle
bundle update # sometimes its required

Then try:

bundle exec terraspace up demo # in case you don't have a shim

Shim docs in case you're interested, though they are currently for linux: https://terraspace.cloud/docs/install/shim/

Let me know. Thanks

from terraspace.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.