@@ -19,7 +19,7 @@ def createSecurityGroup():
19
19
global security_group_id
20
20
try :
21
21
response = ec2 .create_security_group (GroupName = app_name + "-sg" ,
22
- Description = app_name + "Security Group" ,
22
+ Description = app_name + " Security Group" ,
23
23
VpcId = vpc_id ,
24
24
TagSpecifications = [
25
25
{
@@ -36,31 +36,31 @@ def createSecurityGroup():
36
36
security_group_id = response ['GroupId' ]
37
37
print ('Security Group Created %s in vpc %s.' % (security_group_id , vpc_id ))
38
38
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 )
64
64
except ClientError as e :
65
65
print (e )
66
66
@@ -71,7 +71,7 @@ def createKeyPair():
71
71
72
72
ssh_private_key = key_pair ["KeyMaterial" ]
73
73
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 :
75
75
handle .write (ssh_private_key )
76
76
except ClientError as e :
77
77
print (e )
0 commit comments