optimized imports

This commit is contained in:
Sebastian Rieger 2020-05-28 11:58:38 +02:00
parent 89f3f3cdd4
commit d265a10cb3
3 changed files with 36 additions and 8 deletions

View File

@ -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=[
{

View File

@ -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')

View File

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