Skip to content

Instantly share code, notes, and snippets.

@jboero
Last active February 8, 2021 13:20
Show Gist options
  • Save jboero/5ea883248d701319d3564698cb29a603 to your computer and use it in GitHub Desktop.
Save jboero/5ea883248d701319d3564698cb29a603 to your computer and use it in GitHub Desktop.
TFE migrate ORG
#!/bin/bash
export ATLAS_TOKEN={YOURTOKEN}
export OLD_ORG={YOUROLDORG}
export NEW_ORG={YOURNEWORG}
for ws in $(tfe workspace list)
do
tfe pullvars -name "$OLD_ORG/$ws" > $ws.vars
tfe pullvars -name "$OLD_ORG/$ws" -env true > $ws.env
done
tfe pushvars -name "$NEW_ORG/$ws" -var-file $ws.json
for f in *.env
do
for line in $(cat $f)
do
tfe pushvars -env true -tfe-org "$NEW_ORG" -tfe-workspace "$OLD_ORG" -env-var $line
done
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment