Пример #1
0
 def get_manager(self, data, config=None, session_factory=None):
     ctx = ExecutionContext(
         session_factory,
         Bag({
             "name": "test-policy",
             'provider_name': 'aws'
         }), config or Config.empty())
     return EC2(ctx, data)
Пример #2
0
    def process(self, resources, event=None):
        instances = []
        for r in resources:
            instances.extend([i['InstanceId'] for i in r['Instances']])
        instances = set(instances)
        from c7n.resources.ec2 import EC2
        manager = EC2(self.manager.ctx, {})

        self.elb_instances = {}
        for i in manager.resources():
            if i['InstanceId'] in instances:
                self.elb_instances[i['InstanceId']] = i
        return super(Instance, self).process(resources, event)
Пример #3
0
    def scan_ec2_roles(self):
        from c7n.resources.ec2 import EC2
        manager = EC2(self.manager.ctx, {})

        results = []
        for e in manager.resources():
            if 'Instances' not in e:
                continue
            for i in e['Instances']:
                if 'IamInstanceProfile' not in i:
                    continue
                results.append(i['IamInstanceProfile']['Arn'])
        return results
Пример #4
0
 def get_manager(self, data, config=None, session_factory=None):
     ctx = ExecutionContext(session_factory, Bag({'name': 'test-policy'}),
                            config or Config.empty())
     return EC2(ctx, data)
Пример #5
0
 def _pull_ec2_images(self):
     ec2_manager = EC2(self.manager.ctx, {})
     return set([i['ImageId'] for i in ec2_manager.resources()])