start/stop/status scripts for AWS cloud formation demo
This commit is contained in:
		
							
								
								
									
										35
									
								
								example-projects/counter-demo/aws-cloudformation/start.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										35
									
								
								example-projects/counter-demo/aws-cloudformation/start.py
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,35 @@
 | 
			
		||||
import time
 | 
			
		||||
 | 
			
		||||
import boto3
 | 
			
		||||
from botocore.exceptions import ClientError
 | 
			
		||||
 | 
			
		||||
region = 'eu-central-1'
 | 
			
		||||
stackName = 'cloudcomp-counter-demo-stack'
 | 
			
		||||
keyName = 'srieger-pub'
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
client = boto3.setup_default_session(region_name=region)
 | 
			
		||||
cfClient = boto3.client('cloudformation')
 | 
			
		||||
 | 
			
		||||
templateFile = open("cloudcomp-counter-demo-with-vpc.json", "r")
 | 
			
		||||
templateBody = templateFile.read()
 | 
			
		||||
 | 
			
		||||
print("Deleting old stack...")
 | 
			
		||||
print("------------------------------------")
 | 
			
		||||
response = cfClient.delete_stack(
 | 
			
		||||
    StackName=stackName,
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
print("creating new stack...")
 | 
			
		||||
print("------------------------------------")
 | 
			
		||||
 | 
			
		||||
response = cfClient.create_stack(
 | 
			
		||||
    StackName=stackName,
 | 
			
		||||
    TemplateBody=templateBody,
 | 
			
		||||
    Parameters=[
 | 
			
		||||
        {
 | 
			
		||||
            'ParameterKey': 'paramKeyPair',
 | 
			
		||||
            'ParameterValue': keyName
 | 
			
		||||
        },
 | 
			
		||||
    ],
 | 
			
		||||
)
 | 
			
		||||
							
								
								
									
										18
									
								
								example-projects/counter-demo/aws-cloudformation/status.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										18
									
								
								example-projects/counter-demo/aws-cloudformation/status.py
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,18 @@
 | 
			
		||||
import json
 | 
			
		||||
import time
 | 
			
		||||
 | 
			
		||||
import boto3
 | 
			
		||||
from botocore.exceptions import ClientError
 | 
			
		||||
 | 
			
		||||
region = 'eu-central-1'
 | 
			
		||||
stackName = 'cloudcomp-counter-demo-stack'
 | 
			
		||||
 | 
			
		||||
client = boto3.setup_default_session(region_name=region)
 | 
			
		||||
cfClient = boto3.client('cloudformation')
 | 
			
		||||
 | 
			
		||||
print("Showing stack...")
 | 
			
		||||
print("------------------------------------")
 | 
			
		||||
response = cfClient.describe_stacks(
 | 
			
		||||
    StackName=stackName,
 | 
			
		||||
)
 | 
			
		||||
print(json.dumps(response, indent=4, sort_keys=True, default=str))
 | 
			
		||||
							
								
								
									
										16
									
								
								example-projects/counter-demo/aws-cloudformation/stop.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										16
									
								
								example-projects/counter-demo/aws-cloudformation/stop.py
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,16 @@
 | 
			
		||||
import time
 | 
			
		||||
 | 
			
		||||
import boto3
 | 
			
		||||
from botocore.exceptions import ClientError
 | 
			
		||||
 | 
			
		||||
region = 'eu-central-1'
 | 
			
		||||
stackName = 'cloudcomp-counter-demo-stack'
 | 
			
		||||
 | 
			
		||||
client = boto3.setup_default_session(region_name=region)
 | 
			
		||||
cfClient = boto3.client('cloudformation')
 | 
			
		||||
 | 
			
		||||
print("Deleting stack...")
 | 
			
		||||
print("------------------------------------")
 | 
			
		||||
response = cfClient.delete_stack(
 | 
			
		||||
    StackName=stackName,
 | 
			
		||||
)
 | 
			
		||||
		Reference in New Issue
	
	Block a user