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

error parsing terraform json: 53:77: illegal char escape #484

Closed
cncoder opened this issue Apr 23, 2020 · 4 comments · Fixed by #491
Closed

error parsing terraform json: 53:77: illegal char escape #484

cncoder opened this issue Apr 23, 2020 · 4 comments · Fixed by #491

Comments

@cncoder
Copy link

cncoder commented Apr 23, 2020

Very cool tool for importing alb, ec2 etc....

But I'm having issues importing WAF:

system env:

  • provider.aws: version = "~> 2.58"

command:

terraformer-aws import aws --resources=waf --regions ap-northeast-1 --profile XXXX

2020/04/24 XX:XX:XX aws importing default region
2020/04/24 XX:XX:XX aws importing... waf
2020/04/24 XX:XX:XX Refreshing state...
.......
2020/04/24 XX:XX:XX aws Connecting....
2020/04/24 XX:XX:XX aws save waf
2020/04/24 XX:XX:XX {
  "resource": {
    "aws_waf_regex_pattern_set": {
.......
2020/04/24 XX:XX:XX error parsing terraform json: 53:77: illegal char escape
@sergeylanzman
Copy link
Collaborator

can you share line 50-55?

@cncoder
Copy link
Author

cncoder commented Apr 23, 2020

@sergeylanzman share the code in TF file or output?

@cncoder
Copy link
Author

cncoder commented Apr 23, 2020

I can be very sure that it is caused by the complicated rules in aws_waf_regex_pattern_set (my aws_waf_regex_pattern_set has a lot of backslashes "\") , because once I set deny policy about list aws_waf_regex_pattern_set, it is work!

@patrykorwat
Copy link
Contributor

Thanks for raising the issue!
Can confirm, backslashes are problematic. The following regex causes problems: \\ \\\ \\\\ \ \\ \\< .
Full error when importing waf data:

{
  "resource": {
    "aws_waf_regex_match_set": {
      "tfer--asdasd_f213eedf": {
        "name": "asdasd",
        "regex_match_tuple": [
          {
            "field_to_match": [
              {
                "type": "ALL_QUERY_ARGS"
              }
            ],
            "regex_pattern_set_id": "762eb40f-30e6-44a3-8e06-0a6ed3161e02",
            "text_transformation": "NONE"
          }
        ]
      }
    },
    "aws_waf_regex_pattern_set": {
      "tfer--adssad_762eb40f": {
        "name": "adssad",
        "regex_pattern_strings": [
          "/n/n/n/nn/n/n/n/n",
          "\\\\ \\\\\\ \\\\\\\\ \\ \\\\ \\\<",
          "\\\\\\\\s\\\\s\\s"
        ]
      },
      "tfer--adssad_c4cc2640": {
        "name": "adssad"
      }
    }
  }
}
2020/04/24 23:05:50 error parsing terraform json: 24:44: illegal char escape

patrykorwat added a commit to patrykorwat/terraformer that referenced this issue May 1, 2020
sergeylanzman added a commit that referenced this issue May 1, 2020
#484 improved JSON backslash unescaping
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants