-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #992 from AlexsLemonade/davidsmejia/temp-ignore-lock
add unlock_state and use it to unlock failed command
- Loading branch information
Showing
2 changed files
with
28 additions
and
0 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import signal | ||
import subprocess | ||
|
||
|
||
def unlock_state(lock_id): | ||
""" | ||
Replaces the aws provider. | ||
Takes an org name, and a provider, | ||
and changes the terraform state to use the new qualified provider. | ||
""" | ||
|
||
# Make sure that Terraform is allowed to shut down gracefully. | ||
try: | ||
command = ["terraform", "force-unlock", "-force", lock_id] | ||
terraform_process = subprocess.Popen(command) | ||
terraform_process.wait() | ||
except KeyboardInterrupt: | ||
terraform_process.send_signal(signal.SIGINT) | ||
terraform_process.wait() | ||
|
||
# ignore error | ||
return 1 |