From d265a10cb3e4691955574959de4cbd2875cb83d2 Mon Sep 17 00:00:00 2001 From: Sebastian Rieger Date: Thu, 28 May 2020 11:58:38 +0200 Subject: [PATCH] optimized imports --- .../aws-boto3-rds-db/start.py | 25 ++++++++++++++++--- .../aws-boto3-rds-db/stop.py | 17 +++++++++++-- .../create-loadbalancer.py | 2 -- 3 files changed, 36 insertions(+), 8 deletions(-) diff --git a/example-projects/tug-of-war-in-the-clouds/aws-boto3-rds-db/start.py b/example-projects/tug-of-war-in-the-clouds/aws-boto3-rds-db/start.py index 3cb43b2..be2e2f4 100644 --- a/example-projects/tug-of-war-in-the-clouds/aws-boto3-rds-db/start.py +++ b/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=[ { diff --git a/example-projects/tug-of-war-in-the-clouds/aws-boto3-rds-db/stop.py b/example-projects/tug-of-war-in-the-clouds/aws-boto3-rds-db/stop.py index 5021e35..534fa92 100644 --- a/example-projects/tug-of-war-in-the-clouds/aws-boto3-rds-db/stop.py +++ b/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') diff --git a/example-projects/tug-of-war-in-the-clouds/aws-boto3-standalone-db/create-loadbalancer.py b/example-projects/tug-of-war-in-the-clouds/aws-boto3-standalone-db/create-loadbalancer.py index ec66a27..7114094 100644 --- a/example-projects/tug-of-war-in-the-clouds/aws-boto3-standalone-db/create-loadbalancer.py +++ b/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 - ################################################################################################ #