boltops-tools / terraspace

Terraspace: The Terraform Framework
https://terraspace.cloud
Apache License 2.0
674 stars 46 forks source link

String interpolation doesn't work #229

Closed mgzenitech closed 2 years ago

mgzenitech commented 2 years ago

Checklist

My Environment

Software Version
Operating System
Terraform
Terraspace
Ruby

Expected Behaviour

Current Behavior

Step-by-step reproduction instructions

Code Sample

terraform {
  backend "s3" {
    bucket = "<%= normalize('ts-state-' + seed) %>"
    ...
  }
}

terraform {
  backend "s3" {
    bucket = "<%= normalize('ts-state-#{seed}') %>"
    ...
  }
}

Solution Suggestion

tongueroo commented 2 years ago

String interpolation requires double quotes in Ruby 😄

So this should work:

terraform {
  backend "s3" {
    bucket = "<%= normalize("ts-state-#{seed}") %>"
  }
}

Also, testing in an interactive ruby client IRB can help to figure things out. Example:

$ irb
3.1.1 :001 > x = "bar"
 => "bar" 
3.1.1 :002 > y = "foo-#{x}"
 => "foo-bar" 
3.1.1 :003 > z = 'foo-#{x}'
 => "foo-\#{x}" 
3.1.1 :004 >