humanmade / cf-to-tf

CLI tool for generating Terraform configuration and state for existing CloudFormation resources
Other
416 stars 70 forks source link

JSON Parsing Error...? #8

Closed LucasGood closed 5 years ago

LucasGood commented 5 years ago

Running the comand cf-to-tf --stack /home/Username/Desktop/Test config | json2hcl | cf-to-tf clean-hcl | terraform fmt -

getting the error Error running fmt: In <standard input>: key 'illegal' expected start of object ('{') or assignment ('=')

Shortening the first command to cf-to-tf --stack /home/Username/Desktop/Test config | json2hcl | cf-to-tf clean-hcl

I get the error unable to parse JSON: 1:13: illegal char illegal

Note: the file /home/Username/Desktop/Test is the Demo Cloudformation stack in README.md

zackse commented 5 years ago

What is the output from cf-to-tf --stack /home/Username/Desktop/Test config ?

LucasGood commented 5 years ago

Here is the error message, if that is what you are asking for. I am trying to pull the config file from a local source, not directly from the AWS account. { ConfigError: Missing region in config at Request.VALIDATE_REGION (/usr/local/lib/node_modules/@humanmade/cf-to-tf/node_modules/aws-sdk/lib/event_listeners.js:91:45) at Request.callListeners (/usr/local/lib/node_modules/@humanmade/cf-to-tf/node_modules/aws-sdk/lib/sequential_executor.js:109:20) at callNextListener (/usr/local/lib/node_modules/@humanmade/cf-to-tf/node_modules/aws-sdk/lib/sequential_executor.js:99:12) at /usr/local/lib/node_modules/@humanmade/cf-to-tf/node_modules/aws-sdk/lib/event_listeners.js:85:9 at finish (/usr/local/lib/node_modules/@humanmade/cf-to-tf/node_modules/aws-sdk/lib/config.js:322:7) at /usr/local/lib/node_modules/@humanmade/cf-to-tf/node_modules/aws-sdk/lib/config.js:340:9 at SharedIniFileCredentials.get (/usr/local/lib/node_modules/@humanmade/cf-to-tf/node_modules/aws-sdk/lib/credentials.js:126:7) at getAsyncCredentials (/usr/local/lib/node_modules/@humanmade/cf-to-tf/node_modules/aws-sdk/lib/config.js:334:24) at Config.getCredentials (/usr/local/lib/node_modules/@humanmade/cf-to-tf/node_modules/aws-sdk/lib/config.js:354:9) at Request.VALIDATE_CREDENTIALS (/usr/local/lib/node_modules/@humanmade/cf-to-tf/node_modules/aws-sdk/lib/event_listeners.js:80:26) message: 'Missing region in config', code: 'ConfigError', time: 2018-10-18T23:20:33.964Z }

zackse commented 5 years ago

Given a stack name parameter, the program will attempt to pull the configuration from AWS (i.e., the argument is not a path). To use a local file, try passing its contents to standard input:

cf-to-tf --stack - config < /home/Username/Desktop/Test
LucasGood commented 5 years ago

Those recommended changes solved the problem I was getting running this against the example template.

ASethi93 commented 4 years ago

Hi i am having an error, i have set the profile with the region it still shows this error cf-to-tf -s LogStack state | tee terraform.tfstate Error [ConfigError]: Missing region in config at Request.VALIDATE_REGION (/usr/local/lib/node_modules/@humanmade/cf-to-tf/node_modules/aws-sdk/lib/event_listeners.js:92:45) at Request.callListeners (/usr/local/lib/node_modules/@humanmade/cf-to-tf/node_modules/aws-sdk/lib/sequential_executor.js:106:20) at callNextListener (/usr/local/lib/node_modules/@humanmade/cf-to-tf/node_modules/aws-sdk/lib/sequential_executor.js:96:12) at /usr/local/lib/node_modules/@humanmade/cf-to-tf/node_modules/aws-sdk/lib/event_listeners.js:86:9 at finish (/usr/local/lib/node_modules/@humanmade/cf-to-tf/node_modules/aws-sdk/lib/config.js:379:7) at /usr/local/lib/node_modules/@humanmade/cf-to-tf/node_modules/aws-sdk/lib/config.js:397:9 at SharedIniFileCredentials.get (/usr/local/lib/node_modules/@humanmade/cf-to-tf/node_modules/aws-sdk/lib/credentials.js:127:7) at getAsyncCredentials (/usr/local/lib/node_modules/@humanmade/cf-to-tf/node_modules/aws-sdk/lib/config.js:391:24) at Config.getCredentials (/usr/local/lib/node_modules/@humanmade/cf-to-tf/node_modules/aws-sdk/lib/config.js:411:9) at Request.VALIDATE_CREDENTIALS (/usr/local/lib/node_modules/@humanmade/cf-to-tf/node_modules/aws-sdk/lib/event_listeners.js:81:26) { message: 'Missing region in config', code: 'ConfigError', time: 2020-02-12T17:36:35.904Z }