@@ -19,7 +19,7 @@ def createSecurityGroup():
1919 global security_group_id
2020 try :
2121 response = ec2 .create_security_group (GroupName = app_name + "-sg" ,
22- Description = app_name + "Security Group" ,
22+ Description = app_name + " Security Group" ,
2323 VpcId = vpc_id ,
2424 TagSpecifications = [
2525 {
@@ -36,31 +36,31 @@ def createSecurityGroup():
3636 security_group_id = response ['GroupId' ]
3737 print ('Security Group Created %s in vpc %s.' % (security_group_id , vpc_id ))
3838
39- data = ec2 .authorize_security_group_ingress (
40- GroupId = security_group_id ,
41- IpPermissions = [
42- {
43- 'IpProtocol' : 'tcp' ,
44- 'FromPort' : 80 ,
45- 'ToPort' : 80 ,
46- 'IpRanges' : [
47- {
48- 'CidrIp' : '0.0.0.0/0'
49- }
50- ]
51- },
52- {
53- 'IpProtocol' : 'tcp' ,
54- 'FromPort' : 22 ,
55- 'ToPort' : 22 ,
56- 'IpRanges' : [
57- {
58- 'CidrIp' : '0.0.0.0/0'
59- }
60- ]
61- }
62- ])
63- print ('Ingress Successfully Set %s' % data )
39+ ingress = ec2 .authorize_security_group_ingress (
40+ GroupId = security_group_id ,
41+ IpPermissions = [
42+ {
43+ 'IpProtocol' : 'tcp' ,
44+ 'FromPort' : 80 ,
45+ 'ToPort' : 80 ,
46+ 'IpRanges' : [
47+ {
48+ 'CidrIp' : '0.0.0.0/0'
49+ }
50+ ]
51+ },
52+ {
53+ 'IpProtocol' : 'tcp' ,
54+ 'FromPort' : 22 ,
55+ 'ToPort' : 22 ,
56+ 'IpRanges' : [
57+ {
58+ 'CidrIp' : '0.0.0.0/0'
59+ }
60+ ]
61+ }
62+ ])
63+ print ('Ingress Successfully Set %s' % ingress )
6464 except ClientError as e :
6565 print (e )
6666
@@ -71,7 +71,7 @@ def createKeyPair():
7171
7272 ssh_private_key = key_pair ["KeyMaterial" ]
7373
74- with os .fdopen (os .open (key_location + "app-key .pem" , os .O_WRONLY | os .O_CREAT , 0o400 ), "w+" ) as handle :
74+ with os .fdopen (os .open (key_location + key_name + " .pem" , os .O_WRONLY | os .O_CREAT , 0o400 ), "w+" ) as handle :
7575 handle .write (ssh_private_key )
7676 except ClientError as e :
7777 print (e )
0 commit comments