diff --git a/lib/terraspace/plugin/expander/interface.rb b/lib/terraspace/plugin/expander/interface.rb index d145cde0..f7839d29 100644 --- a/lib/terraspace/plugin/expander/interface.rb +++ b/lib/terraspace/plugin/expander/interface.rb @@ -84,7 +84,7 @@ def var_value(unexpanded) elsif !ENV[name].blank? return ENV[name] else - return unexpanded + return '' end if downcase == "namespace" && Terraspace.config.layering.enable_names.expansion value = friendly_name(value) diff --git a/spec/terraspace/provider/expander/generic_spec.rb b/spec/terraspace/provider/expander/generic_spec.rb index 0d0e8064..f07ad469 100644 --- a/spec/terraspace/provider/expander/generic_spec.rb +++ b/spec/terraspace/provider/expander/generic_spec.rb @@ -3,7 +3,7 @@ let(:props) do { bucket: "my-bucket", - key: ":env/:build_dir/terraform.tfstate", # variable notation expanded by terraspace + key: ":env/:TEAM/:ENVNOTSET/:build_dir/terraform.tfstate", # variable notation expanded by terraspace region: "us-west-2", encrypt: true, dynamodb_table: "terraform_locks" @@ -15,12 +15,14 @@ mod end + before { stub_const('ENV', {'TEAM' => 'backend'}) } + context "default path" do it "expand" do result = expander.expand(props) expect(result).to eq({ bucket: "my-bucket", - key: "dev/stacks/core/terraform.tfstate", + key: "dev/backend/stacks/core/terraform.tfstate", region: "us-west-2", encrypt: true, dynamodb_table: "terraform_locks"