MCPcopy Create free account
hub / github.com/pgadmin-org/pgadmin4 / _create_security_group

Method _create_security_group

web/pgacloud/providers/aws.py:138–159  ·  view source on GitHub ↗

Create a new security group for the instance

(self, args)

Source from the content-addressed store, hash-verified

136 return self._clients['type']
137
138 def _create_security_group(self, args):
139 """ Create a new security group for the instance """
140 ec2 = self._get_aws_client('ec2', args)
141 ip = args.public_ip if args.public_ip else get_my_ip()
142 ip = ip.split(',')
143
144 # Deploy the security group
145 try:
146 name = 'pgacloud_{}_{}_{}'.format(args.name,
147 ip[0].replace('.', '-'),
148 get_random_id())
149 debug('Creating security group: {}...'.format(name))
150 output({'Creating': 'Creating security group: {}...'.format(name)})
151 response = ec2.create_security_group(
152 Description='Inbound access for {} to RDS instance {}'.format(
153 ip[0], args.name),
154 GroupName=name
155 )
156 except Exception as e:
157 error(str(e))
158
159 return response['GroupId']
160
161 def _add_ingress_rule(self, args, security_group):
162 """ Add a local -> PostgreSQL ingress rule to a security group """

Callers 1

cmd_create_instanceMethod · 0.95

Calls 6

_get_aws_clientMethod · 0.95
get_my_ipFunction · 0.90
get_random_idFunction · 0.90
debugFunction · 0.90
outputFunction · 0.90
errorFunction · 0.90

Tested by

no test coverage detected