Created
June 9, 2017 21:40
-
-
Save carlosonunez/af38d604bd48eb771b4cdb9bbd0bd761 to your computer and use it in GitHub Desktop.
[Terraform] planVersionFormat magic byte issue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Where is 'terraform'? | |
[2017-06-09 16:26:36 carlosnunez@DESKTOP-RHPB7LP <<master>> infrastructure] $: which terraform | |
/usr/local/bin/terraform | |
# Where is './terraform'? | |
[2017-06-09 16:27:02 carlosnunez@DESKTOP-RHPB7LP <<master>> infrastructure] $: readlink -f ./terraform | |
/home/cnunez/src/infrastructure/terraform | |
# Okay, cool. So we have two different terraform binaries installed. Let's see what their versions are. | |
[2017-06-09 16:20:26 carlosnunez@DESKTOP-RHPB7LP <<master>> infrastructure]$: terraform version | |
Terraform v0.8.0 | |
Your version of Terraform is out of date! The latest version | |
is 0.9.8. You can update by downloading from www.terraform.io | |
[2017-06-09 16:21:18 carlosnunez@DESKTOP-RHPB7LP <<master>> infrastructure] $: ./terraform version | |
Terraform v0.9.8 | |
# Alright! We've confirmed that the versions are different. Let's go ahead and generate some plans. We'll be discarding the states and output from Terraform. | |
[2017-06-09 16:20:33 carlosnunez@DESKTOP-RHPB7LP <<master>> infrastructure]$: terraform plan -state=nil -out=./plan_from_v0-8.tfplan > /dev/null | |
[2017-06-09 16:21:29 carlosnunez@DESKTOP-RHPB7LP <<master>> infrastructure] $: ./terraform plan -state=nil -out=./plan_from_v0-9-8.tfplan > /dev/null | |
# So I've been using a tool called tfjson to convert the tfplan binary into json. This uses the terraform source from a few months ago. | |
# You can see this project here: https://github.com/palantir/tfjson | |
# Let's try and get some JSON from our plans. | |
[2017-06-09 16:21:02 carlosnunez@DESKTOP-RHPB7LP <<master>> infrastructure] $: tfjson ./plan-from-v0-8.tfplan | head -n 5 | |
{ | |
"aws_vpc.infrastructure": { | |
"cidr_block": "10.1.0.0/16", | |
"default_network_acl_id": "", | |
"default_route_table_id": "", | |
[2017-06-09 16:22:01 carlosnunez@DESKTOP-RHPB7LP <<master>> infrastructure] $: tfjson ./plan-from-v0-9-8.tfplan | head -n 5 | |
gob: wrong type (map[string]string) for received field InstanceState.Meta | |
# That's weird! Maybe they are different plan formats. Let's check the byte streams of each and confirm this. | |
[2017-06-09 16:24:48 carlosnunez@DESKTOP-RHPB7LP <<master>> infrastructure] $: hexdump plan-from-v0-8.tfplan -Cn 8 | |
00000000 74 66 70 6c 61 6e 01 4a |tfplan.J| | |
00000008 | |
[2017-06-09 16:24:56 carlosnunez@DESKTOP-RHPB7LP <<master>> infrastructure] $: hexdump plan-from-v0.9.8.tfplan -Cn 8 | |
00000000 74 66 70 6c 61 6e 01 57 |tfplan.W| | |
00000008 | |
# 7466706c616e = "tfplan" | |
# 01 = 1 | |
# The '01' should differ between the two plans because they came from two different versions. | |
# See the 'Expected' and 'Actual' outputs to see the consequences of this. | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment