-
-
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`
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
"""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