Skip to content

Instantly share code, notes, and snippets.

@clstokes
Last active October 1, 2021 15:09
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save clstokes/977b7bd00b37e0a564f707f0ebe36e08 to your computer and use it in GitHub Desktop.
Save clstokes/977b7bd00b37e0a564f707f0ebe36e08 to your computer and use it in GitHub Desktop.
Helper program to convert a Pulumi checkpoint file to work with `pulumi stack import`
"""A program to convert Pulumi checkpoint files to work with `pulumi stack import`"""
import json, sys
args = sys.argv
if len(args) != 2:
print("Exepected at least one argument - the path to the checkpoint file to convert.")
checkpoint_file = open(args[1])
checkpoint_json = json.load(checkpoint_file)
# Converts the format on the left to the format on the right:
# { {
# "version": 3, "version": 3,
# "checkpoint": { "deployment": { ... }
# "stack": "demo", }
# "latest": { ... }
# }
# }
state_file = {
"version": checkpoint_json["version"],
"deployment": checkpoint_json["checkpoint"]["latest"],
}
print(json.dumps(state_file, indent=4))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment