Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Preserve double-quotes when calling "terraform import" #317

Open
2 of 3 tasks
alisson276 opened this issue Jul 18, 2023 · 0 comments
Open
2 of 3 tasks

Preserve double-quotes when calling "terraform import" #317

alisson276 opened this issue Jul 18, 2023 · 0 comments
Labels
bug Something isn't working help wanted Extra attention is needed

Comments

@alisson276
Copy link

Checklist

  • Upgrade Terraspace: Are you using the latest version of Terraspace? This allows Terraspace to fix issues fast. There's an Upgrading Guide: https://terraspace.cloud/docs/misc/upgrading/
  • Reproducibility: Are you reporting a bug others will be able to reproduce and not asking a question. If you're unsure or want to ask a question, do so on https://community.boltops.com
  • Code sample: Have you put together a code sample to reproduce the issue and make it available? Code samples help speed up fixes dramatically. If it's an easily reproducible issue, then code samples are not needed. If you're unsure, please include a code sample.

My Environment

Software Version
Operating System MacOS
Terraform v1.5.1
Terraspace 2.2.7
Ruby 3.2.1

Expected Behaviour

When calling terraspace import <STACK> 'module.some["parameter"].resource.name' 'arn:abc' through a shell it should preserve the double-quotes inside the single-quoted parameter.

Current Behavior

It is calling correct the terraform command, example:

terraform import module.some["parameter"].resource.name arn:abc

The problem is that it's calling through a shell, then the double-quotes are being caught by the shell and the Terraform get the parameter without double-quotes, causing the error:

│ Error: Index value required
│ 
│   on <import-address> line 1:
│    1: module.some[parameter].resource.name
│ 
│ Index brackets must contain either a literal number or a literal string.

Step-by-step reproduction instructions

Try to import any existent resource that uses a for_each statement, using a map(any) instead of a list.

Code Sample

Solution Suggestion

What I'm doing to by-pass this problem is to escape the double-quotes, like:

terraspace import <STACK> 'module.some[\"parameter\"].resource.name' 'arn:abc'

I suggest replace any double-quotes with the escape character. this approach as a simple one to by-pass this hassle. The other solution is do not run it through a shell, but it may impact other subcommands, so it's more risky to introduce new bugs.

@alisson276 alisson276 added the bug Something isn't working label Jul 18, 2023
@tongueroo tongueroo added the help wanted Extra attention is needed label Jul 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants