-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
118 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,3 +18,4 @@ def main(): | |
print(ascii_art) | ||
if __name__ == "__main__": | ||
main() | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import boto3 as bt | ||
|
||
ec2 = bt.resource('ec2') | ||
|
||
def create_instance(ami_id, min_count, max_count, instance_type, key_name): | ||
instances = ec2.create_instances( | ||
ImageId=ami_id, | ||
MinCount=min_count, | ||
MaxCount=max_count, | ||
InstanceType=instance_type, | ||
KeyName=key_name | ||
) | ||
|
||
print(instances + " instances are launched successfully") |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import boto3 as bt | ||
|
||
client = bt.client('ec2') | ||
|
||
def describe_instance(instance_id): | ||
response = client.describe_instances( | ||
InstanceIds=[ | ||
instance_id, | ||
], | ||
) | ||
|
||
print(response) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import boto3 as bt | ||
|
||
client = bt.client('ec2') | ||
|
||
def stop_instance(instance_id): | ||
response = client.stop_instances( | ||
InstanceIds=[ | ||
instance_id, | ||
], | ||
) | ||
print(response) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import boto3 | ||
|
||
ec2 = boto3.client('ec2') | ||
|
||
def create_key_pair(key_name): | ||
response = ec2.create_key_pair(KeyName=key_name) | ||
print(response) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import boto3 as bt | ||
|
||
ec2 = bt.resource('ec2') | ||
|
||
def delete_key_pair(key_name): | ||
response = ec2.delete_key_pair(KeyName=key_name) | ||
print(response) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import boto3 as bt | ||
|
||
ec2 = bt.resource('ec2') | ||
|
||
def describe_key_pair(key_name): | ||
response = ec2.describe_key_pairs(KeyNames=[key_name]) | ||
print(response) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import boto3 | ||
from botocore.exceptions import ClientError | ||
|
||
ec2 = boto3.client('ec2') | ||
|
||
def create_security_group(vpc_id, group_name, description): | ||
try: | ||
response = ec2.create_security_group( | ||
GroupName=group_name, | ||
Description=description, | ||
VpcId=vpc_id | ||
) | ||
security_group_id = response['GroupId'] | ||
print('Security Group Created %s in vpc %s.' % (security_group_id, vpc_id)) | ||
|
||
data = ec2.authorize_security_group_ingress( | ||
GroupId=security_group_id, | ||
IpPermissions=[ | ||
{ | ||
'IpProtocol': 'tcp', | ||
'FromPort': 80, | ||
'ToPort': 80, | ||
'IpRanges': [{'CidrIp': '0.0.0.0/0'}] | ||
}, | ||
{ | ||
'IpProtocol': 'tcp', | ||
'FromPort': 22, | ||
'ToPort': 22, | ||
'IpRanges': [{'CidrIp': '0.0.0.0/0'}] | ||
} | ||
] | ||
) | ||
print('Ingress Successfully Set %s' % data) | ||
except ClientError as e: | ||
print(e) | ||
|
||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import boto3 as bt | ||
|
||
ec2 = bt.resource('ec2') | ||
|
||
def delete_security_group(group_id, group_name): | ||
response = ec2.delete_security_group( | ||
GroupId=group_id, | ||
GroupName=group_name, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import boto3 as bt | ||
|
||
client = bt.client('ec2') | ||
|
||
def describe_security_group(group_id): | ||
response = client.describe_security_groups( | ||
GroupIds=[ | ||
group_id, | ||
], | ||
) | ||
print(response) |