-
-
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.
add replace_provider command and call after init_terraform in deploy …
…script
- Loading branch information
1 parent
a66f456
commit 46b0868
Showing
2 changed files
with
33 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,27 @@ | ||
import signal | ||
import subprocess | ||
|
||
|
||
def replace_provider(org, provider): | ||
""" | ||
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", | ||
"state", | ||
"replace-provider", | ||
f"registry.terraform.io/-/{provider}", | ||
f"registry.terraform.io/{org}/{provider}", | ||
] | ||
terraform_process = subprocess.Popen(command) | ||
terraform_process.wait() | ||
except KeyboardInterrupt: | ||
terraform_process.send_signal(signal.SIGINT) | ||
terraform_process.wait() | ||
|
||
return terraform_process.returncode |