Skip to content

Instantly share code, notes, and snippets.

@mizzy
Created March 13, 2018 08:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mizzy/faa2e226b6ee1fe356ab5ec246137d3b to your computer and use it in GitHub Desktop.
Save mizzy/faa2e226b6ee1fe356ab5ec246137d3b to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
require 'json'
tfstate_file = ARGV[0]
tfstate = ''
File.open(tfstate_file, 'r') do |f|
tfstate = JSON.load(f)
end
tfstate['modules'][0]['resources'].each do |name, resouce|
if resouce['type'] == 'aws_alb'
resouce['primary']['attributes']['load_balancer_type'] = 'application'
end
if resouce['type'] == 'aws_alb_target_group'
resouce['primary']['attributes']['target_type'] = 'instance'
end
end
puts JSON.pretty_generate(tfstate)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment