Browse Source

optimized imports

master
Sebastian Rieger 4 years ago
parent
commit
d265a10cb3
  1. 25
      example-projects/tug-of-war-in-the-clouds/aws-boto3-rds-db/start.py
  2. 17
      example-projects/tug-of-war-in-the-clouds/aws-boto3-rds-db/stop.py
  3. 2
      example-projects/tug-of-war-in-the-clouds/aws-boto3-standalone-db/create-loadbalancer.py

25
example-projects/tug-of-war-in-the-clouds/aws-boto3-rds-db/start.py

@ -1,14 +1,33 @@
import time
import boto3
from botocore.exceptions import ClientError
################################################################################################
#
# Configuration Parameters
#
################################################################################################
region = 'eu-central-1'
availabilityZone = 'eu-central-1b'
vpc_id = 'vpc-eedd4187'
imageId = 'ami-0cc293023f983ed53'
instanceType = 't3.nano'
keyName = 'srieger-pub'
# if you only have one VPC, vpc_id can be retrieved using:
#
# response = ec2Client.describe_vpcs()
# vpc_id = response.get('Vpcs', [{}])[0].get('VpcId', '')
################################################################################################
#
# boto3 code
#
################################################################################################
client = boto3.setup_default_session(region_name=region)
ec2Client = boto3.client("ec2")
@ -16,8 +35,6 @@ ec2Resource = boto3.resource('ec2')
rdsClient = boto3.client("rds")
response = ec2Client.describe_vpcs()
vpc_id = response.get('Vpcs', [{}])[0].get('VpcId', '')
subnet_id = ec2Client.describe_subnets(
Filters=[
{

17
example-projects/tug-of-war-in-the-clouds/aws-boto3-rds-db/stop.py

@ -1,8 +1,14 @@
import time
import boto3
from botocore.exceptions import ClientError
################################################################################################
#
# Configuration Parameters
#
################################################################################################
region = 'eu-central-1'
availabilityZone = 'eu-central-1b'
imageId = 'ami-0cc293023f983ed53'
@ -10,6 +16,13 @@ instanceType = 't3.nano'
keyName = 'srieger-pub'
################################################################################################
#
# boto3 code
#
################################################################################################
client = boto3.setup_default_session(region_name=region)
ec2Client = boto3.client("ec2")
ec2Resource = boto3.resource('ec2')

2
example-projects/tug-of-war-in-the-clouds/aws-boto3-standalone-db/create-loadbalancer.py

@ -1,6 +1,4 @@
import boto3
from botocore.exceptions import ClientError
################################################################################################
#

Loading…
Cancel
Save