Exemple #1
0
 def process_state_resource(self, state_resource, state_filename):
     logger.info("Found a resource of type %s!" % self.resource_type)
     for instance in state_resource['instances']:
         FoundItem(self.resource_type,
                   terraform_id=state_resource["name"],
                   predicted_id=instance["attributes"]["id"],
                   state_data=instance)
 def process_state_resource(self, state_resource, state_filename):
     logger.info("Found a resource of type %s!" % self.resource_type)
     for instance in state_resource["instances"]:
         FoundItem("aws_lb_target_group_attachment",
                   terraform_id=state_resource["name"],
                   predicted_id=instance["attributes"]["target_id"],
                   state_data=instance)
Exemple #3
0
    def fetch_real_regional_resources(self, region):
        logging.info("Looking for %s resources..." % self.resource_type)
        ec2 = self._get_resource('ec2', region)
        rd = ResourceDirectory()

        for subnet in ec2.subnets.filter():
            try:
                item = rd.get_item(predicted_id=subnet.id)
                item.real_id = subnet.id
                item.real_data = subnet
            except KeyError:
                FoundItem(self.resource_type, real_id=subnet.id, real_data=subnet)
Exemple #4
0
    def fetch_real_regional_resources(self, region):
        logging.info("Looking for %s resources..." % self.resource_type)
        client = self._get_client("rds", region)
        rd = ResourceDirectory()

        response = client.describe_db_instances()

        for instance in response["DBInstances"]:
            try:
                item = rd.get_item(predicted_id=instance["DBInstanceIdentifier"])
                item.real_id = instance["DBInstanceIdentifier"]
                item.real_data = instance
            except KeyError:
                item = FoundItem(self.resource_type, real_id=instance["DBInstanceIdentifier"], real_data=instance)
Exemple #5
0
    def fetch_real_global_resources(self):
        logging.info("Looking for %s resources..." % self.resource_type)
        client = self._get_client('s3', None)
        rd = ResourceDirectory()

        response = client.list_buckets()

        for bucket in response['Buckets']:
            try:
                item = rd.get_item(predicted_id=bucket["Name"])
                item.real_id = bucket["Name"]
                item.real_data = bucket
            except KeyError:
                FoundItem(self.resource_type,
                          real_id=bucket["Name"],
                          real_data=bucket)
    def fetch_real_regional_resources(self, region):
        logging.info("Looking for %s resources..." % self.resource_type)
        client = self._get_client("lambda", region)
        rd = ResourceDirectory()

        response = client.list_functions()

        for instance in response["Functions"]:
            try:
                item = rd.get_item(predicted_id=instance["FunctionName"])
                item.real_id = instance["FunctionName"]
                item.real_data = instance
            except KeyError:
                # that item isnt predicted!
                FoundItem("aws_lambda_function",
                          real_id=instance["FunctionName"],
                          real_data=instance)
    def fetch_real_regional_resources(self, region):
        logging.info("Looking for %s resources..." % self.resource_type)
        client = self._get_client("rds", region)
        rd = ResourceDirectory()

        response = client.describe_db_cluster_parameter_groups()

        for pg in response["DBClusterParameterGroups"]:
            try:
                item = rd.get_item(
                    predicted_id=pg["DBClusterParameterGroupName"])
                item.real_id = pg["DBClusterParameterGroupName"]
                item.real_data = pg
            except KeyError:
                FoundItem(self.resource_type,
                          real_id=pg["DBClusterParameterGroupName"],
                          real_data=pg)
Exemple #8
0
    def fetch_real_regional_resources(self, region):
        logging.info("Looking for %s resources..." % self.resource_type)
        client = self._get_client('ec2', region)
        rd = ResourceDirectory()

        instances = client.describe_instances()

        if instances:
            for reservation in instances["Reservations"]:
                for instance in reservation["Instances"]:
                    try:
                        item = rd.get_item(predicted_id=instance["InstanceId"])
                        item.real_id = instance["InstanceId"]
                        item.real_data = instance
                    except KeyError:
                        FoundItem(self.resource_type,
                                  real_id=instance["InstanceId"],
                                  real_data=instance)
    def fetch_real_regional_resources(self, region):
        logging.info("Looking for %s/aws_alb_target_group resources..." %
                     self.resource_type)
        client = self._get_client("elbv2", region)
        rd = ResourceDirectory()

        response = client.describe_target_groups()

        if "TargetGroups" in response:
            for tg in response["TargetGroups"]:
                try:
                    item = rd.get_item(predicted_id=tg["TargetGroupName"])
                    item.real_id = tg["TargetGroupName"]
                    item.real_data = tg
                except KeyError:
                    item = FoundItem(self.resource_type,
                                     real_id=tg["TargetGroupName"],
                                     real_data=tg)
                finally:
                    self._tgs_in_aws.append(item)
Exemple #10
0
    def fetch_real_regional_resources(self, region):
        logging.info("Looking for %s/aws_alb_listener_rule resources..." %
                     self.resource_type)
        client = self._get_client("elbv2", region)
        rd = ResourceDirectory()

        listeners = ResourceDirectory().lookup(
            "aws_lb_listener").listeners_in_aws
        for listener in listeners:
            response = client.describe_listener_certificates(
                ListenerArn=listener.real_data["ListenerArn"])
            if "Certificates" in response:
                for cert in response["Certificates"]:
                    try:
                        item = rd.get_item(predicted_id=cert["CertificateArn"])
                        item.real_id = cert["RuleArn"]
                        item.real_data = cert
                    except KeyError:
                        FoundItem(self.resource_type,
                                  real_id=cert["CertificateArn"],
                                  real_data=listener)
    def fetch_real_regional_resources(self, region):
        logging.info(
            "Looking for %s/aws_alb_target_group_attachment resources..." %
            self.resource_type)
        client = self._get_client("elbv2", region)
        rd = ResourceDirectory()

        target_groups = ResourceDirectory().lookup(
            "aws_lb_target_group").target_groups_in_aws

        for tg in target_groups:
            response = client.describe_target_health(
                TargetGroupArn=tg.real_data["TargetGroupArn"])
            if "TargetHealthDescriptions" in response:
                for target in response["TargetHealthDescriptions"]:
                    try:
                        item = rd.get_item(predicted_id=target["Target"]["Id"])
                        item.real_id = target["Target"]["Id"]
                        item.real_data = target
                    except KeyError:
                        FoundItem(self.resource_type,
                                  real_id=target["Target"]["Id"],
                                  real_data=target)
Exemple #12
0
    def fetch_real_regional_resources(self, region):
        logging.info("Looking for %s/aws_alb_listener resources..." %
                     self.resource_type)
        client = self._get_client("elbv2", region)
        rd = ResourceDirectory()

        load_balancers = ResourceDirectory().lookup(
            "aws_lb").load_balancers_in_aws
        for lb in load_balancers:
            response = client.describe_listeners(
                LoadBalancerArn=lb.real_data["LoadBalancerArn"])
            if "Listeners" in response:
                for listener in response["Listeners"]:
                    try:
                        item = rd.get_item(
                            predicted_id=listener["ListenerArn"])
                        item.real_id = listener["ListenerArn"]
                        item.real_data = listener
                    except KeyError:
                        item = FoundItem(self.resource_type,
                                         real_id=listener["ListenerArn"],
                                         real_data=listener)
                    finally:
                        self._listeners_in_aws.append(item)