Skip to content

Commit

Permalink
work around terraform bug
Browse files Browse the repository at this point in the history
  • Loading branch information
s0enke committed Aug 20, 2017
1 parent f04058f commit da0842a
Showing 1 changed file with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ Resources:
import cfnresponse
import subprocess
import os
import sys
def handler(event, context):
print("Received event: " + json.dumps(event, indent=2))
Expand All @@ -33,7 +34,9 @@ Resources:
open(os.path.join(terraform_working_directory, 'terraform.tf'), 'w').write(event['ResourceProperties']['Terraform'])
try:
subprocess.check_output('/tmp/terraform init', shell=True, cwd=terraform_working_directory)
# https://github.com/hashicorp/terraform/issues/12971
subprocess.check_output('rm -fr .terraform/terraform.tfstate', stdout=sys.stdout, shell=True, cwd=terraform_working_directory)
subprocess.check_call('/tmp/terraform init', stdout=sys.stdout, shell=True, cwd=terraform_working_directory)
print(subprocess.check_output('/tmp/terraform apply', stderr=subprocess.STDOUT, shell=True, cwd=terraform_working_directory))
terraform_outputs = json.loads(subprocess.check_output('/tmp/terraform output -json', stderr=subprocess.STDOUT, shell=True, cwd=terraform_working_directory))
Expand Down

0 comments on commit da0842a

Please sign in to comment.