Advertisement
Guest User

Untitled

a guest
Dec 10th, 2019
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.77 KB | None | 0 0
  1. from sys import argv
  2. from time import sleep
  3. import boto3
  4. import botocore
  5. import requests
  6.  
  7. try:
  8.     stack = argv[1]
  9. except IndexError:
  10.     print("Please provide a stack name")
  11.     exit(1)
  12.  
  13. cfn_client = boto3.client('cloudformation')
  14.  
  15. try:
  16.     stack = cfn_client.describe_stacks(StackName=stack)
  17. except botocore.exceptions.ClientError:
  18.     print("This stack does not exist or region is incorrect")
  19.     exit(1)
  20.  
  21. ELB_DNS = stack['Stacks'][0]['Outputs'][0]['OutputValue']
  22. for _ in range(0, 2):
  23.     resp = requests.get(f"http://{ELB_DNS}")
  24.     if resp.status_code == 200:
  25.         print("Test succeeded")
  26.         exit(0)
  27.     sleep(5)
  28.  
  29. print(f"Result of test: {resp.content}")
  30. print(f"HTTP Response code: {resp.status_code}")
  31. print("Test did not succeed")
  32. exit(1)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement