|
@ -1,14 +1,33 @@ |
|
|
import time |
|
|
|
|
|
|
|
|
|
|
|
import boto3 |
|
|
import boto3 |
|
|
from botocore.exceptions import ClientError |
|
|
from botocore.exceptions import ClientError |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
################################################################################################ |
|
|
|
|
|
# |
|
|
|
|
|
# Configuration Parameters |
|
|
|
|
|
# |
|
|
|
|
|
################################################################################################ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
region = 'eu-central-1' |
|
|
region = 'eu-central-1' |
|
|
availabilityZone = 'eu-central-1b' |
|
|
availabilityZone = 'eu-central-1b' |
|
|
|
|
|
vpc_id = 'vpc-eedd4187' |
|
|
imageId = 'ami-0cc293023f983ed53' |
|
|
imageId = 'ami-0cc293023f983ed53' |
|
|
instanceType = 't3.nano' |
|
|
instanceType = 't3.nano' |
|
|
keyName = 'srieger-pub' |
|
|
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) |
|
|
client = boto3.setup_default_session(region_name=region) |
|
|
ec2Client = boto3.client("ec2") |
|
|
ec2Client = boto3.client("ec2") |
|
@ -16,8 +35,6 @@ ec2Resource = boto3.resource('ec2') |
|
|
|
|
|
|
|
|
rdsClient = boto3.client("rds") |
|
|
rdsClient = boto3.client("rds") |
|
|
|
|
|
|
|
|
response = ec2Client.describe_vpcs() |
|
|
|
|
|
vpc_id = response.get('Vpcs', [{}])[0].get('VpcId', '') |
|
|
|
|
|
subnet_id = ec2Client.describe_subnets( |
|
|
subnet_id = ec2Client.describe_subnets( |
|
|
Filters=[ |
|
|
Filters=[ |
|
|
{ |
|
|
{ |
|
|