Exemple #1
0
from awsdaleks import chaser, warrior, dalek
import boto3
iam = boto3.client('iam')


def exterminate(target):
    ec2 = boto3.client('ec2', region_name=target["region"])
    instance_ids = target["names"]
    if (target["region"] == "eu-west-1"):
        print("STOP")
    if instance_ids:
        ec2.terminate_instances(InstanceIds=instance_ids)


warrior("ec2_instance", lambda r: exterminate(r))
Exemple #2
0
from awsdaleks import chaser, warrior, dalek
import boto3
iam = boto3.client('iam')


def exterminate(target):
    username = target['names'][0]
    if (username != "" and username != "dalek"):
        response = iam.delete_user(UserName=username)
        print(response)


warrior("iam_user", lambda r: exterminate(r))
from awsdaleks import warrior
import boto3


def exterminate(target):
    client = boto3.client('cloudformation', region_name=target["region"])
    stack_name = target["names"][0]
    client.delete_stack(StackName=stack_name)


warrior("cloudformation_stack", lambda t: exterminate(t))
Exemple #4
0
from awsdaleks import chaser, warrior, dalek
import boto3


def exterminate(target):
    iot = boto3.client('iot', region_name=target["region"])
    ruleName = target["names"][0]
    iot.delete_topic_rule(ruleName=ruleName)


warrior("iot_rule", lambda r: exterminate(r))
from awsdaleks import chaser, warrior, dalek
import boto3


def exterminate(target):
    iot = boto3.client('iot', region_name=target["region"])
    certificateId = target["names"][0]
    iot.update_certificate(certificateId=certificateId, newStatus='REVOKED')
    iot.delete_certificate(certificateId=certificateId)


warrior("iot_certificate", lambda r: exterminate(r))
Exemple #6
0
from awsdaleks import warrior

import boto3

s3 = boto3.client('s3')


def exterminate(target):
    bucketName = target["names"][0]
    s3.delete_bucket_policy(Bucket=bucketName)
    s3.delete_bucket(Bucket=bucketName)


warrior("s3_empty_bucket", lambda r: exterminate(r))
Exemple #7
0
from awsdaleks import chaser, warrior, dalek
import boto3
iam = boto3.client('iam')


def exterminate(target):
    ec2 = boto3.client('ec2', region_name=target["region"])
    instance_ids = target["names"]
    if(target["region"] == "eu-west-1"):
        print("STOP")
    if instance_ids:
        ec2.terminate_instances(InstanceIds=instance_ids)


warrior("ec2_instance", lambda r: exterminate(r))
from awsdaleks import chaser, warrior, dalek
import boto3


def exterminate(target):
    iot = boto3.client('iot', region_name=target["region"])
    certificateId = target["names"][0]
    iot.update_certificate(
        certificateId=certificateId,
        newStatus='REVOKED'
    )
    iot.delete_certificate(certificateId=certificateId)


warrior("iot_certificate", lambda r: exterminate(r))
Exemple #9
0
from awsdaleks import chaser, warrior, dalek
import boto3


def exterminate(target):
    iot = boto3.client('iot', region_name=target["region"])
    thingName = target["names"][0]
    principals = iot.list_thing_principals(thingName=thingName)
    for principal in principals["principals"]:
        iot.detach_thing_principal(thingName=thingName, principal=principal)
    iot.delete_thing(thingName=thingName)


warrior("iot_thing", lambda r: exterminate(r))
Exemple #10
0
from awsdaleks import chaser, warrior, dalek
import boto3


def exterminate(target):
    client = boto3.client('lambda', region_name=target["region"])
    functionName = target["names"][0]
    client.delete_function(FunctionName=functionName)


warrior("lambda_function", lambda r: exterminate(r))
Exemple #11
0
from awsdaleks import chaser, warrior, dalek
import boto3


def exterminate(target):
    iot = boto3.client('iot', region_name=target["region"])
    policyName = target["names"][0]
    targets = iot.list_targets_for_policy(policyName=policyName)["targets"]
    for targetName in targets:
        iot.detach_policy(
            policyName=policyName,
            target=targetName)
    iot.delete_policy(policyName=policyName)


warrior("iot_policy", lambda r: exterminate(r))
Exemple #12
0
from awsdaleks import warrior

import boto3
s3 = boto3.client('s3')


def mkargs(res):
    return {
        'Key': res[0],
        'VersionId': res[1]
    }


def exterminate(res):
    names = res.rnames
    objects = list(map(mkargs, names))
    bucketName = res.extras["bucket-name"]
    delete = {
        'Objects': objects,
    }
    result = None
    if objects:
        result = s3.delete_objects(
            Bucket=bucketName,
            Delete=delete)
    return result


warrior("s3_objects", lambda r: exterminate(r))