Create a new security group for the instance
(self, args)
| 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 """ |
no test coverage detected