Skip to content
This repository has been archived by the owner on Sep 9, 2022. It is now read-only.

bug on merging with exisitn terraform.tfstate file #491

Open
StL-Jim opened this issue Dec 23, 2019 · 5 comments
Open

bug on merging with exisitn terraform.tfstate file #491

StL-Jim opened this issue Dec 23, 2019 · 5 comments

Comments

@StL-Jim
Copy link

StL-Jim commented Dec 23, 2019

Here's the error I get when I try to merge into an existing terraform.tfstate
terraforming cwa --tfstate --merge=terraform.tfstate --profile xxxxxxx
/var/lib/gems/2.3.0/gems/terraforming-0.18.0/lib/terraforming/cli.rb:269:in tfstate': undefined method []' for nil:NilClass (NoMethodError)
from /var/lib/gems/2.3.0/gems/terraforming-0.18.0/lib/terraforming/cli.rb:250:in execute' from /var/lib/gems/2.3.0/gems/terraforming-0.18.0/lib/terraforming/cli.rb:25:in cwa'
from /var/lib/gems/2.3.0/gems/thor-1.0.1/lib/thor/command.rb:27:in run' from /var/lib/gems/2.3.0/gems/thor-1.0.1/lib/thor/invocation.rb:127:in invoke_command'
from /var/lib/gems/2.3.0/gems/thor-1.0.1/lib/thor.rb:392:in dispatch' from /var/lib/gems/2.3.0/gems/thor-1.0.1/lib/thor/base.rb:485:in start'
from /var/lib/gems/2.3.0/gems/terraforming-0.18.0/bin/terraforming:5:in <top (required)>' from /usr/local/bin/terraforming:23:in load'
from /usr/local/bin/terraforming:23:in `

'

@StL-Jim
Copy link
Author

StL-Jim commented Dec 23, 2019

Also, I installed using gem install terraforming, here's the list of installed gems
gem list

*** LOCAL GEMS ***

aws-eventstream (1.0.3)
aws-partitions (1.259.0)
aws-sdk-autoscaling (1.30.0)
aws-sdk-cloudwatch (1.31.0)
aws-sdk-core (3.86.0)
aws-sdk-dynamodb (1.41.0)
aws-sdk-ec2 (1.129.0)
aws-sdk-efs (1.23.0)
aws-sdk-elasticache (1.29.0)
aws-sdk-elasticloadbalancing (1.19.0)
aws-sdk-elasticloadbalancingv2 (1.39.0)
aws-sdk-iam (1.32.0)
aws-sdk-kms (1.27.0)
aws-sdk-rds (1.74.0)
aws-sdk-redshift (1.35.0)
aws-sdk-route53 (1.30.0)
aws-sdk-s3 (1.60.1)
aws-sdk-sns (1.21.0)
aws-sdk-sqs (1.23.1)
aws-sigv4 (1.1.0)
bigdecimal (1.2.8)
did_you_mean (1.0.0)
io-console (0.4.5)
jmespath (1.4.0)
json (1.8.3)
minitest (5.8.4)
multi_json (1.12.2)
net-telnet (0.1.1)
power_assert (0.2.7)
psych (2.0.17)
rake (10.5.0)
rdoc (4.2.1)
terraforming (0.18.0)
test-unit (3.1.7)
thor (1.0.1)

@richstokes
Copy link

Running into something similar here. Did you ever find a solution?

Traceback (most recent call last):
	9: from /usr/local/bin/terraforming:23:in `<main>'
	8: from /usr/local/bin/terraforming:23:in `load'
	7: from /Library/Ruby/Gems/2.6.0/gems/terraforming-0.18.0/bin/terraforming:5:in `<top (required)>'
	6: from /Library/Ruby/Gems/2.6.0/gems/thor-1.0.1/lib/thor/base.rb:485:in `start'
	5: from /Library/Ruby/Gems/2.6.0/gems/thor-1.0.1/lib/thor.rb:392:in `dispatch'
	4: from /Library/Ruby/Gems/2.6.0/gems/thor-1.0.1/lib/thor/invocation.rb:127:in `invoke_command'
	3: from /Library/Ruby/Gems/2.6.0/gems/thor-1.0.1/lib/thor/command.rb:27:in `run'
	2: from /Library/Ruby/Gems/2.6.0/gems/terraforming-0.18.0/lib/terraforming/cli.rb:120:in `iamu'
	1: from /Library/Ruby/Gems/2.6.0/gems/terraforming-0.18.0/lib/terraforming/cli.rb:250:in `execute'
/Library/Ruby/Gems/2.6.0/gems/terraforming-0.18.0/lib/terraforming/cli.rb:269:in `tfstate': undefined method `[]' for nil:NilClass (NoMethodError)

@LunaticZorr
Copy link

Same error here too

Traceback (most recent call last):
	9: from /usr/local/bin/terraforming:23:in `<main>'
	8: from /usr/local/bin/terraforming:23:in `load'
	7: from /var/lib/gems/2.5.0/gems/terraforming-0.18.0/bin/terraforming:5:in `<top (required)>'
	6: from /usr/lib/ruby/vendor_ruby/thor/base.rb:444:in `start'
	5: from /usr/lib/ruby/vendor_ruby/thor.rb:369:in `dispatch'
	4: from /usr/lib/ruby/vendor_ruby/thor/invocation.rb:126:in `invoke_command'
	3: from /usr/lib/ruby/vendor_ruby/thor/command.rb:27:in `run'
	2: from /var/lib/gems/2.5.0/gems/terraforming-0.18.0/lib/terraforming/cli.rb:215:in `vpc'
	1: from /var/lib/gems/2.5.0/gems/terraforming-0.18.0/lib/terraforming/cli.rb:250:in `execute'
/var/lib/gems/2.5.0/gems/terraforming-0.18.0/lib/terraforming/cli.rb:269:in `tfstate': undefined method `[]' for nil:NilClass (NoMethodError)

@shanezeller
Copy link

I am getting parse error in Multi-json thrign to merge anything.
vagrant@ubuntu1804:~/SpecialProjects/Output$ terraforming alb --tfstate --merge=.terraform.tfstate --overwrite
Traceback (most recent call last):
11: from /usr/local/bin/terraforming:23:in <main>' 10: from /usr/local/bin/terraforming:23:in load'
9: from /var/lib/gems/2.5.0/gems/terraforming-0.18.0/bin/terraforming:5:in <top (required)>' 8: from /var/lib/gems/2.5.0/gems/thor-1.0.1/lib/thor/base.rb:485:in start'
7: from /var/lib/gems/2.5.0/gems/thor-1.0.1/lib/thor.rb:392:in dispatch' 6: from /var/lib/gems/2.5.0/gems/thor-1.0.1/lib/thor/invocation.rb:127:in invoke_command'
5: from /var/lib/gems/2.5.0/gems/thor-1.0.1/lib/thor/command.rb:27:in run' 4: from /var/lib/gems/2.5.0/gems/terraforming-0.18.0/lib/terraforming/cli.rb:15:in alb'
3: from /var/lib/gems/2.5.0/gems/terraforming-0.18.0/lib/terraforming/cli.rb:250:in execute' 2: from /var/lib/gems/2.5.0/gems/terraforming-0.18.0/lib/terraforming/cli.rb:267:in tfstate'
1: from /var/lib/gems/2.5.0/gems/multi_json-1.12.2/lib/multi_json.rb:122:in load' /var/lib/gems/2.5.0/gems/multi_json-1.12.2/lib/multi_json/adapter.rb:20:in load': JSON::ParserError (MultiJson::ParseError)

@tingwei628
Copy link

tingwei628 commented Jan 18, 2021

If there's no property "modules" in terraform.tfstate file, the following codes would cause NoMethodError problem.

tfstate["modules"][0]["resources"] = tfstate["modules"][0]["resources"].merge(klass.tfstate)

UPDATE
I found another tool to merge Terraform state files into one.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants