Skip to content

Extension chaosaws

Version 0.10.0
Repository https://github.com/chaostoolkit-incubator/chaostoolkit-aws

Build Status Python versions

This project is a collection of actions and probes, gathered as an extension to the Chaos Toolkit.

Install

This package requires Python 3.5+

To be used from your experiment, this package must be installed in the Python environment where chaostoolkit already lives.

$ pip install -U chaostoolkit-aws

Usage

To use the probes and actions from this package, add the following to your experiment file:

{
    "name": "stop-an-ec2-instance",
    "provider": {
        "type": "python",
        "module": "chaosaws.ec2.actions",
        "func": "stop_instance",
        "arguments": {
            "instance_id": "i-123456"
        }
    }
},
{
    "name": "create-a-new-policy",
    "provider": {
        "type": "python",
        "module": "chaosaws.iam.actions",
        "func": "create_policy",
        "arguments": {
            "name": "mypolicy",
            "path": "user/Jane",
            "policy": {
                "Version": "2012-10-17",
                "Statement": [
                    {
                        "Effect": "Allow",
                        "Action": [
                            "s3:ListAllMyBuckets",
                            "s3:GetBucketLocation"
                        ],
                        "Resource": "arn:aws:s3:::*"
                    }
                ]
            }
        }
    }
}

Or select one at random from an AZ:

{
    "name": "stop-an-ec2-instance-in-az-at-random",
    "provider": {
        "type": "python",
        "module": "chaosaws.ec2.actions",
        "func": "stop_instance",
        "arguments": {
            "az": "us-west-1"
        }
    }
}

That’s it!

Please explore the code to see existing probes and actions.

Configuration

Credentials

This extension uses the boto3 library under the hood. This library expects that you have properly configured your environment to connect and authenticate with the AWS services.

Generally speaking, there are two ways of doing this:

  • you have configured the environment where you will run the experiment from (any of the user-wide credential sources would do). You may also provide a profile name to assume a role.

    {
        "configuration": {
            "aws_profile_name": "dev"
        }
    }
    
  • you explicitely pass the correct environment variables to the experiment definition as follows:

    {
        "secrets": {
            "aws": {
                "aws_access_key_id": "your key",
                "aws_secret_access_key": "access key",
                "aws_session_token": "token",
            }
        }
    }
    

Note that the token is optional. Then, use it as follows:

```json
{
    "name": "stop-an-ec2-instance",
    "provider": {
        "type": "python",
        "module": "chaosaws.ec2.actions",
        "func": "stop_instance",
        "secrets": ["aws"],
        "arguments": {
            "instance_id": "i-123456"
        }
    }
}
```

Other AWS settings

In additon to the authentication credentials, you can configure the region against which you want to use. At the top level of the experiment, add:

{
    "configuration": {
        "aws_region": "us-east-1"
    }
}

You may also specify an AWS Role ARN to assume. This is helpful for AWS systems with multiple accounts, and running experiments across those accounts. In order to use this, the AWS profile you are initially using must have the permissions to assume the given role. Given those conditions are met, boto3 will issue a call to the sts assume_role function. This can be used alone, or with the “aws_profile_name” as follows:

{
  "configuration": {
    "aws_profile_name": "dev",
    "aws_assume_role_arn": "arn"
  }
}

Contribute

If you wish to contribute more functions to this package, you are more than welcome to do so. Please, fork this project, make your changes following the usual PEP 8 code style, sprinkling with tests and submit a PR for review.

The Chaos Toolkit projects require all contributors must sign a Developer Certificate of Origin on each commit they would like to merge into the master branch of the repository. Please, make sure you can abide by the rules of the DCO before submitting a PR.

Develop

If you wish to develop on this project, make sure to install the development dependencies. But first, create a virtual environment and then install those dependencies.

$ pip install -r requirements-dev.txt -r requirements.txt 

Then, point your environment to this directory:

$ python setup.py develop

Now, you can edit the files and they will be automatically be seen by your environment, even when running from the chaos command locally.

Test

To run the tests for the project execute the following:

$ pytest

Add new AWS API Support

Once you have setup your environment, you can start adding new AWS API support by adding new actions, probes and entire sub-packages for those.

Services supported by boto

This package relies on boto3 to wrap the API calls into a fluent Python API. Some newer AWS services are not yet available in boto3, in that case, you should read the next section.

Let’s say you want to support a new action in the EC2 sub-package.

Start by creating a new function in ec2/actions.py:

from chaoslib.types import Configuration, Secrets

from chaosaws import aws_client
from chaosaws.types import AWSResponse

def reboot_instance(instance_id: str, dry_run: bool=False,
                    configuration: Configuration=None,
                    secrets: Secrets=None) -> AWSResponse:
    """
    Reboot a given EC2 instance.
    """
    client = aws_client('ec2', configuration, secrets)
    return client.reboot_instances(InstanceIds=[instance_id], DryRun=dry_run)

As you can see, the actual code is straightforward. You first create a EC2 client and simply call the appropriate method on that client with the expected arguments. We return the action as-is so that it can be logged by the chaostoolkit, or even be used as part of a steady-state hypothesis probe (if this was a probe, not action that is).

You could decide to make more than one AWS API call but, it is better to keep it simple so that composition is easier from the experiment. Nonetheless, you may also compose those directly into a single action as well for specific use-cases.

Please refer to the Chaos Toolkit documentation to learn more about the configuration and secrets objects.

Once you have implemented that action, you must create at least one unit test for it in the tests/ec2/test_ec2_actions.py test module. For example:

from chaosaws.ec2.actions import reboot_instancex

@patch('chaosaws.ec2.actions.aws_client', autospec=True)
def test_reboot_instance(aws_client):
    client = MagicMock()
    aws_client.return_value = client
    inst_id = "i-1234567890abcdef0"
    response = reboot_instance(inst_id)
    client.reboot_instances.assert_called_with(
        InstanceIds=[inst_id], DryRun=False)

By using the built-in Python module to mock objects, we can mock the EC2 client and assert we edo indeed call the appropriate method with the right arguments. You are encouraged to write more than a single test for various conditions.

Finally, should you choose to add support for a new AWS API resource altogether, you should create the according sub-package.

Services not supported by boto (new AWS features)

If the support you want to provide is for a new AWS service that boto does not support yet, this requires direct call to the API endpoint via the requests package. Say we have a new service, not yet supported by boto3

from chaoslib.types import Configuration, Secrets

from chaosaws import signed_api_call
from chaosaws.types import AWSResponse

def terminate_worker_node(worker_node_id: str,
                          configuration: Configuration=None,
                          secrets: Secrets=None) -> AWSResponse:
    """
    Terminate a worker node.
    """
    params = {
        "DryRun": True,
        "WorkerNodeId.1": worker_node_id
    }
    response = signed_api_call(
        'some-new-service-name', path='/2018-01-01/worker/terminate',
        method='POST', params=params,
        configuration=configuration, secrets=secrets)
    return response.json()

Here is an example on existing API call (as a more concrete snippet):

from chaoslib.types import Configuration, Secrets

from chaosaws import signed_api_call

def stop_instance(instance_id: str, configuration: Configuration=None,
                  secrets: Secrets=None) -> str:
    response = signed_api_call(
        'ec2',
        configuration=configuration,
        secrets=secrets,
        params={
            "Action": "StopInstances",
            "InstanceId.1": instance_id,
            "Version": "2013-06-15"
        }
    )

    # this API returns XML, not JSON
    return response.text

When using the signed_api_call, you are responsible for the right way of passing the parameters. Basically, look at the AWS documentation for each API call.

WARNING: It should be noted that, whenever boto3 implements an API, this package should be updated accordingly, as boto3 is much more versatile and solid.

Make your new sub-package discoverable

Finally, if you have created a new sub-package entirely, you need to make its capability discoverable by the chaos toolkit. Simply amend the discover function in the chaosaws/__init__.py. For example, assuming a new eks sub-package, with actions and probes:

    activities.extend(discover_actions("chaosaws.eks.actions"))
    activities.extend(discover_probes("chaosaws.eks.probes"))

Exported Activities

cloudwatch


delete_rule

Type action
Module chaosaws.cloudwatch.actions
Name delete_rule
Return None

Deletes a CloudWatch rule.

All rule targets must be removed before deleting the rule. Set input argument force to True to force all rule targets to be deleted.

Signature:

def delete_rule(rule_name: str,
                force: bool = False,
                configuration: Dict[str, Dict[str, str]] = None,
                secrets: Dict[str, Dict[str, str]] = None) -> Dict[str, Any]:
    pass

Arguments:

Name Type Default Required
rule_name string Yes
force boolean false No

Usage:

{
  "provider": {
    "module": "chaosaws.cloudwatch.actions",
    "arguments": {
      "rule_name": ""
    },
    "func": "delete_rule",
    "type": "python"
  },
  "type": "action",
  "name": "delete-rule"
}
name: delete-rule
provider:
  arguments:
    rule_name: ''
  func: delete_rule
  module: chaosaws.cloudwatch.actions
  type: python
type: action

disable_rule

Type action
Module chaosaws.cloudwatch.actions
Name disable_rule
Return None

Disables a CloudWatch rule.

Signature:

def disable_rule(rule_name: str,
                 configuration: Dict[str, Dict[str, str]] = None,
                 secrets: Dict[str, Dict[str, str]] = None) -> Dict[str, Any]:
    pass

Arguments:

Name Type Default Required
rule_name string Yes

Usage:

{
  "provider": {
    "module": "chaosaws.cloudwatch.actions",
    "arguments": {
      "rule_name": ""
    },
    "func": "disable_rule",
    "type": "python"
  },
  "type": "action",
  "name": "disable-rule"
}
name: disable-rule
provider:
  arguments:
    rule_name: ''
  func: disable_rule
  module: chaosaws.cloudwatch.actions
  type: python
type: action

enable_rule

Type action
Module chaosaws.cloudwatch.actions
Name enable_rule
Return None

Enables a CloudWatch rule.

Signature:

def enable_rule(rule_name: str,
                configuration: Dict[str, Dict[str, str]] = None,
                secrets: Dict[str, Dict[str, str]] = None) -> Dict[str, Any]:
    pass

Arguments:

Name Type Default Required
rule_name string Yes

Usage:

{
  "provider": {
    "module": "chaosaws.cloudwatch.actions",
    "arguments": {
      "rule_name": ""
    },
    "func": "enable_rule",
    "type": "python"
  },
  "type": "action",
  "name": "enable-rule"
}
name: enable-rule
provider:
  arguments:
    rule_name: ''
  func: enable_rule
  module: chaosaws.cloudwatch.actions
  type: python
type: action

get_alarm_state_value

Type probe
Module chaosaws.cloudwatch.probes
Name get_alarm_state_value
Return None

Return the state value of an alarm.

The possbile alarm state values are described in the documentation https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/cloudwatch.html#CloudWatch.Client.describe_alarms

Signature:

def get_alarm_state_value(alarm_name: str,
                          configuration: Dict[str, Dict[str, str]] = None,
                          secrets: Dict[str, Dict[str, str]] = None) -> str:
    pass

Arguments:

Name Type Default Required
alarm_name string Yes

Usage:

{
  "provider": {
    "module": "chaosaws.cloudwatch.probes",
    "arguments": {
      "alarm_name": ""
    },
    "func": "get_alarm_state_value",
    "type": "python"
  },
  "type": "probe",
  "name": "get-alarm-state-value"
}
name: get-alarm-state-value
provider:
  arguments:
    alarm_name: ''
  func: get_alarm_state_value
  module: chaosaws.cloudwatch.probes
  type: python
type: probe

get_metric_statistics

Type probe
Module chaosaws.cloudwatch.probes
Name get_metric_statistics
Return None

Get the value of a statistical calculation for a given metric.

The period for which the calculation will be performed is specified by a duration and an offset from the current time. Both are specified in seconds.

Example: A duration of 60 seconds and an offset of 30 seconds will yield a statistical value based on the time interval between 30 and 90 seconds in the past.

More information about input parameters are available in the documentation https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/cloudwatch.html#CloudWatch.Client.get_metric_statistics

Signature:

def get_metric_statistics(namespace: str,
                          metric_name: str,
                          dimension_name: str,
                          dimension_value: str,
                          duration: int = 60,
                          offset: int = 0,
                          statistic: str = None,
                          extended_statistic: str = None,
                          unit: str = None,
                          configuration: Dict[str, Dict[str, str]] = None,
                          secrets: Dict[str, Dict[str, str]] = None):
    pass

Arguments:

Name Type Default Required
namespace string Yes
metric_name string Yes
dimension_name string Yes
dimension_value string Yes
duration integer 60 No
offset integer 0 No
statistic string null No
extended_statistic string null No
unit string null No

Usage:

{
  "provider": {
    "module": "chaosaws.cloudwatch.probes",
    "arguments": {
      "dimension_name": "",
      "metric_name": "",
      "namespace": "",
      "dimension_value": ""
    },
    "func": "get_metric_statistics",
    "type": "python"
  },
  "type": "probe",
  "name": "get-metric-statistics"
}
name: get-metric-statistics
provider:
  arguments:
    dimension_name: ''
    dimension_value: ''
    metric_name: ''
    namespace: ''
  func: get_metric_statistics
  module: chaosaws.cloudwatch.probes
  type: python
type: probe

put_rule

Type action
Module chaosaws.cloudwatch.actions
Name put_rule
Return None

Creates or updates a CloudWatch event rule.

Please refer to https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/events.html#CloudWatchEvents.Client.put_rule for details on input arguments.

Signature:

def put_rule(rule_name: str,
             schedule_expression: str = None,
             event_pattern: str = None,
             state: str = None,
             description: str = None,
             role_arn: str = None,
             configuration: Dict[str, Dict[str, str]] = None,
             secrets: Dict[str, Dict[str, str]] = None) -> Dict[str, Any]:
    pass

Arguments:

Name Type Default Required
rule_name string Yes
schedule_expression string null No
event_pattern string null No
state string null No
description string null No
role_arn string null No

Usage:

{
  "provider": {
    "module": "chaosaws.cloudwatch.actions",
    "arguments": {
      "rule_name": ""
    },
    "func": "put_rule",
    "type": "python"
  },
  "type": "action",
  "name": "put-rule"
}
name: put-rule
provider:
  arguments:
    rule_name: ''
  func: put_rule
  module: chaosaws.cloudwatch.actions
  type: python
type: action

put_rule_targets

Type action
Module chaosaws.cloudwatch.actions
Name put_rule_targets
Return None

Creates or update CloudWatch event rule targets.

Please refer to https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/events.html#CloudWatchEvents.Client.put_targets for details on input arguments.

Signature:

def put_rule_targets(
        rule_name: str,
        targets: List[Dict[str, Any]],
        configuration: Dict[str, Dict[str, str]] = None,
        secrets: Dict[str, Dict[str, str]] = None) -> Dict[str, Any]:
    pass

Arguments:

Name Type Default Required
rule_name string Yes
targets list Yes

Usage:

{
  "provider": {
    "module": "chaosaws.cloudwatch.actions",
    "arguments": {
      "rule_name": "",
      "targets": []
    },
    "func": "put_rule_targets",
    "type": "python"
  },
  "type": "action",
  "name": "put-rule-targets"
}
name: put-rule-targets
provider:
  arguments:
    rule_name: ''
    targets: []
  func: put_rule_targets
  module: chaosaws.cloudwatch.actions
  type: python
type: action

remove_rule_targets

Type action
Module chaosaws.cloudwatch.actions
Name remove_rule_targets
Return None

Removes CloudWatch rule targets. If no target ids are provided all targets will be removed.

Signature:

def remove_rule_targets(
        rule_name: str,
        target_ids: List[str] = None,
        configuration: Dict[str, Dict[str, str]] = None,
        secrets: Dict[str, Dict[str, str]] = None) -> Dict[str, Any]:
    pass

Arguments:

Name Type Default Required
rule_name string Yes
target_ids list null No

Usage:

{
  "provider": {
    "module": "chaosaws.cloudwatch.actions",
    "arguments": {
      "rule_name": ""
    },
    "func": "remove_rule_targets",
    "type": "python"
  },
  "type": "action",
  "name": "remove-rule-targets"
}
name: remove-rule-targets
provider:
  arguments:
    rule_name: ''
  func: remove_rule_targets
  module: chaosaws.cloudwatch.actions
  type: python
type: action

elbv2


all_targets_healthy

Type probe
Module chaosaws.elbv2.probes
Name all_targets_healthy
Return None

Return true/false based on if all targets for listed target groups are healthy

Signature:

def all_targets_healthy(
        tg_names: List[str],
        configuration: Dict[str, Dict[str, str]] = None,
        secrets: Dict[str, Dict[str, str]] = None) -> Dict[str, Any]:
    pass

Arguments:

Name Type Default Required
tg_names list Yes

Usage:

{
  "provider": {
    "module": "chaosaws.elbv2.probes",
    "arguments": {
      "tg_names": []
    },
    "func": "all_targets_healthy",
    "type": "python"
  },
  "type": "probe",
  "name": "all-targets-healthy"
}
name: all-targets-healthy
provider:
  arguments:
    tg_names: []
  func: all_targets_healthy
  module: chaosaws.elbv2.probes
  type: python
type: probe

deregister_target

Type action
Module chaosaws.elbv2.actions
Name deregister_target
Return None

Deregisters one random target from target group

Signature:

def deregister_target(
        tg_name: str,
        configuration: Dict[str, Dict[str, str]] = None,
        secrets: Dict[str, Dict[str, str]] = None) -> Dict[str, Any]:
    pass

Arguments:

Name Type Default Required
tg_name string Yes

Usage:

{
  "provider": {
    "module": "chaosaws.elbv2.actions",
    "arguments": {
      "tg_name": ""
    },
    "func": "deregister_target",
    "type": "python"
  },
  "type": "action",
  "name": "deregister-target"
}
name: deregister-target
provider:
  arguments:
    tg_name: ''
  func: deregister_target
  module: chaosaws.elbv2.actions
  type: python
type: action

set_security_groups

Type action
Module chaosaws.elbv2.actions
Name set_security_groups
Return None

Changes the security groups for the specified load balancer(s). This action will replace the existing security groups on an application load balancer with the specified security groups.

Parameters: - load_balancer_names: a list of load balancer names - security_group_ids: a list of security group ids

returns: [ { ‘LoadBalancerArn’: ‘string’, ‘SecurityGroupIds’: [‘sg-0000000’, ‘sg-0000001’] }, … ]

Signature:

def set_security_groups(
        load_balancer_names: List[str],
        security_group_ids: List[str],
        configuration: Dict[str, Dict[str, str]] = None,
        secrets: Dict[str, Dict[str, str]] = None) -> List[Dict[str, Any]]:
    pass

Arguments:

Name Type Default Required
load_balancer_names list Yes
security_group_ids list Yes

Usage:

{
  "provider": {
    "module": "chaosaws.elbv2.actions",
    "arguments": {
      "load_balancer_names": [],
      "security_group_ids": []
    },
    "func": "set_security_groups",
    "type": "python"
  },
  "type": "action",
  "name": "set-security-groups"
}
name: set-security-groups
provider:
  arguments:
    load_balancer_names: []
    security_group_ids: []
  func: set_security_groups
  module: chaosaws.elbv2.actions
  type: python
type: action

set_subnets

Type action
Module chaosaws.elbv2.actions
Name set_subnets
Return None

Changes the subnets for the specified application load balancer(s) This action will replace the existing security groups on an application load balancer with the specified security groups.

Parameters: - load_balancer_names: a list of load balancer names - subnet_ids: a list of subnet ids

returns: [ { ‘LoadBalancerArn’: ‘string’, ‘AvailabilityZones’: { ‘ZoneName’: ‘string’, ‘SubnetId’: ‘string’, ‘LoadBalancerAddresses’: [ { ‘IpAddress’: ‘string’, ‘AllocationId’: ‘string’ } ] } }, … ]

Signature:

def set_subnets(
        load_balancer_names: List[str],
        subnet_ids: List[str],
        configuration: Dict[str, Dict[str, str]] = None,
        secrets: Dict[str, Dict[str, str]] = None) -> List[Dict[str, Any]]:
    pass

Arguments:

Name Type Default Required
load_balancer_names list Yes
subnet_ids list Yes

Usage:

{
  "provider": {
    "module": "chaosaws.elbv2.actions",
    "arguments": {
      "subnet_ids": [],
      "load_balancer_names": []
    },
    "func": "set_subnets",
    "type": "python"
  },
  "type": "action",
  "name": "set-subnets"
}
name: set-subnets
provider:
  arguments:
    load_balancer_names: []
    subnet_ids: []
  func: set_subnets
  module: chaosaws.elbv2.actions
  type: python
type: action

targets_health_count

Type probe
Module chaosaws.elbv2.probes
Name targets_health_count
Return None

Count of healthy/unhealthy targets per targetgroup

Signature:

def targets_health_count(
        tg_names: List[str],
        configuration: Dict[str, Dict[str, str]] = None,
        secrets: Dict[str, Dict[str, str]] = None) -> Dict[str, Any]:
    pass

Arguments:

Name Type Default Required
tg_names list Yes

Usage:

{
  "provider": {
    "module": "chaosaws.elbv2.probes",
    "arguments": {
      "tg_names": []
    },
    "func": "targets_health_count",
    "type": "python"
  },
  "type": "probe",
  "name": "targets-health-count"
}
name: targets-health-count
provider:
  arguments:
    tg_names: []
  func: targets_health_count
  module: chaosaws.elbv2.probes
  type: python
type: probe

iam


attach_role_policy

Type action
Module chaosaws.iam.actions
Name attach_role_policy
Return None

Attach a role to a policy.

Signature:

def attach_role_policy(
        arn: str,
        role_name: str,
        configuration: Dict[str, Dict[str, str]] = None,
        secrets: Dict[str, Dict[str, str]] = None) -> Dict[str, Any]:
    pass

Arguments:

Name Type Default Required
arn string Yes
role_name string Yes

Usage:

{
  "provider": {
    "module": "chaosaws.iam.actions",
    "arguments": {
      "arn": "",
      "role_name": ""
    },
    "func": "attach_role_policy",
    "type": "python"
  },
  "type": "action",
  "name": "attach-role-policy"
}
name: attach-role-policy
provider:
  arguments:
    arn: ''
    role_name: ''
  func: attach_role_policy
  module: chaosaws.iam.actions
  type: python
type: action

create_policy

Type action
Module chaosaws.iam.actions
Name create_policy
Return None

Create a new IAM policy

Signature:

def create_policy(name: str,
                  policy: Dict[str, Any],
                  path: str = '/',
                  description: str = '',
                  configuration: Dict[str, Dict[str, str]] = None,
                  secrets: Dict[str, Dict[str, str]] = None) -> Dict[str, Any]:
    pass

Arguments:

Name Type Default Required
name string Yes
policy mapping Yes
path string ”/” No
description string ”“ No

Usage:

{
  "provider": {
    "module": "chaosaws.iam.actions",
    "arguments": {
      "policy": {},
      "name": ""
    },
    "func": "create_policy",
    "type": "python"
  },
  "type": "action",
  "name": "create-policy"
}
name: create-policy
provider:
  arguments:
    name: ''
    policy: {}
  func: create_policy
  module: chaosaws.iam.actions
  type: python
type: action

detach_role_policy

Type action
Module chaosaws.iam.actions
Name detach_role_policy
Return None

Detach a role from a policy.

Signature:

def detach_role_policy(
        arn: str,
        role_name: str,
        configuration: Dict[str, Dict[str, str]] = None,
        secrets: Dict[str, Dict[str, str]] = None) -> Dict[str, Any]:
    pass

Arguments:

Name Type Default Required
arn string Yes
role_name string Yes

Usage:

{
  "provider": {
    "module": "chaosaws.iam.actions",
    "arguments": {
      "arn": "",
      "role_name": ""
    },
    "func": "detach_role_policy",
    "type": "python"
  },
  "type": "action",
  "name": "detach-role-policy"
}
name: detach-role-policy
provider:
  arguments:
    arn: ''
    role_name: ''
  func: detach_role_policy
  module: chaosaws.iam.actions
  type: python
type: action

get_policy

Type probe
Module chaosaws.iam.probes
Name get_policy
Return None

Get a policy by its ARN

Signature:

def get_policy(arn: str,
               configuration: Dict[str, Dict[str, str]] = None,
               secrets: Dict[str, Dict[str, str]] = None) -> bool:
    pass

Arguments:

Name Type Default Required
arn string Yes

Usage:

{
  "provider": {
    "module": "chaosaws.iam.probes",
    "arguments": {
      "arn": ""
    },
    "func": "get_policy",
    "type": "python"
  },
  "type": "probe",
  "name": "get-policy"
}
name: get-policy
provider:
  arguments:
    arn: ''
  func: get_policy
  module: chaosaws.iam.probes
  type: python
type: probe

eks


create_cluster

Type action
Module chaosaws.eks.actions
Name create_cluster
Return None

Create a new EKS cluster.

Signature:

def create_cluster(
        name: str,
        role_arn: str,
        vpc_config: Dict[str, Any],
        version: str = None,
        configuration: Dict[str, Dict[str, str]] = None,
        secrets: Dict[str, Dict[str, str]] = None) -> Dict[str, Any]:
    pass

Arguments:

Name Type Default Required
name string Yes
role_arn string Yes
vpc_config mapping Yes
version string null No

Usage:

{
  "provider": {
    "module": "chaosaws.eks.actions",
    "arguments": {
      "role_arn": "",
      "vpc_config": {},
      "name": ""
    },
    "func": "create_cluster",
    "type": "python"
  },
  "type": "action",
  "name": "create-cluster"
}
name: create-cluster
provider:
  arguments:
    name: ''
    role_arn: ''
    vpc_config: {}
  func: create_cluster
  module: chaosaws.eks.actions
  type: python
type: action

delete_cluster

Type action
Module chaosaws.eks.actions
Name delete_cluster
Return None

Delete the given EKS cluster.

Signature:

def delete_cluster(
        name: str = None,
        configuration: Dict[str, Dict[str, str]] = None,
        secrets: Dict[str, Dict[str, str]] = None) -> Dict[str, Any]:
    pass

Arguments:

Name Type Default Required
name string null No

Usage:

{
  "provider": {
    "module": "chaosaws.eks.actions",
    "func": "delete_cluster",
    "type": "python"
  },
  "type": "action",
  "name": "delete-cluster"
}
name: delete-cluster
provider:
  func: delete_cluster
  module: chaosaws.eks.actions
  type: python
type: action

describe_cluster

Type probe
Module chaosaws.eks.probes
Name describe_cluster
Return None

Describe an EKS cluster.

Signature:

def describe_cluster(
        name: str,
        configuration: Dict[str, Dict[str, str]] = None,
        secrets: Dict[str, Dict[str, str]] = None) -> Dict[str, Any]:
    pass

Arguments:

Name Type Default Required
name string Yes

Usage:

{
  "provider": {
    "module": "chaosaws.eks.probes",
    "arguments": {
      "name": ""
    },
    "func": "describe_cluster",
    "type": "python"
  },
  "type": "probe",
  "name": "describe-cluster"
}
name: describe-cluster
provider:
  arguments:
    name: ''
  func: describe_cluster
  module: chaosaws.eks.probes
  type: python
type: probe

list_clusters

Type probe
Module chaosaws.eks.probes
Name list_clusters
Return None

List EKS clusters available to the authenticated account.

Signature:

def list_clusters(configuration: Dict[str, Dict[str, str]] = None,
                  secrets: Dict[str, Dict[str, str]] = None) -> Dict[str, Any]:
    pass

Arguments:

Name Type Default Required

Usage:

{
  "provider": {
    "module": "chaosaws.eks.probes",
    "func": "list_clusters",
    "type": "python"
  },
  "type": "probe",
  "name": "list-clusters"
}
name: list-clusters
provider:
  func: list_clusters
  module: chaosaws.eks.probes
  type: python
type: probe

ec2


count_instances

Type probe
Module chaosaws.ec2.probes
Name count_instances
Return None

Return count of instances matching the specified filters.

Please refer to https://bit.ly/2Sv9lmU

for details on said filters.

Signature:

def count_instances(
        filters: List[Dict[str, Any]],
        configuration: Dict[str, Dict[str, str]] = None,
        secrets: Dict[str, Dict[str, str]] = None) -> Dict[str, Any]:
    pass

Arguments:

Name Type Default Required
filters list Yes

Usage:

{
  "provider": {
    "module": "chaosaws.ec2.probes",
    "arguments": {
      "filters": []
    },
    "func": "count_instances",
    "type": "python"
  },
  "type": "probe",
  "name": "count-instances"
}
name: count-instances
provider:
  arguments:
    filters: []
  func: count_instances
  module: chaosaws.ec2.probes
  type: python
type: probe

describe_instances

Type probe
Module chaosaws.ec2.probes
Name describe_instances
Return None

Describe instances following the specified filters.

Please refer to https://bit.ly/2Sv9lmU

for details on said filters.

Signature:

def describe_instances(
        filters: List[Dict[str, Any]],
        configuration: Dict[str, Dict[str, str]] = None,
        secrets: Dict[str, Dict[str, str]] = None) -> Dict[str, Any]:
    pass

Arguments:

Name Type Default Required
filters list Yes

Usage:

{
  "provider": {
    "module": "chaosaws.ec2.probes",
    "arguments": {
      "filters": []
    },
    "func": "describe_instances",
    "type": "python"
  },
  "type": "probe",
  "name": "describe-instances"
}
name: describe-instances
provider:
  arguments:
    filters: []
  func: describe_instances
  module: chaosaws.ec2.probes
  type: python
type: probe

stop_instance

Type action
Module chaosaws.ec2.actions
Name stop_instance
Return None

Stop a single EC2 instance.

You may provide an instance id explicitly or, if you only specify the AZ, a random instance will be selected. If you need more control, you can also provide a list of filters following the documentation https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/ec2.html#EC2.Client.describe_instances

Signature:

def stop_instance(instance_id: str = None,
                  az: str = None,
                  force: bool = False,
                  filters: List[Dict[str, Any]] = None,
                  configuration: Dict[str, Dict[str, str]] = None,
                  secrets: Dict[str, Dict[str, str]] = None) -> Dict[str, Any]:
    pass

Arguments:

Name Type Default Required
instance_id string null No
az string null No
force boolean false No
filters list null No

Usage:

{
  "provider": {
    "module": "chaosaws.ec2.actions",
    "func": "stop_instance",
    "type": "python"
  },
  "type": "action",
  "name": "stop-instance"
}
name: stop-instance
provider:
  func: stop_instance
  module: chaosaws.ec2.actions
  type: python
type: action

stop_instances

Type action
Module chaosaws.ec2.actions
Name stop_instances
Return None

Stop the given EC2 instances or, if none is provided, all instances of the given availability zone. If you need more control, you can also provide a list of filters following the documentation https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/ec2.html#EC2.Client.describe_instances

Signature:

def stop_instances(
        instance_ids: List[str] = None,
        az: str = None,
        filters: List[Dict[str, Any]] = None,
        force: bool = False,
        configuration: Dict[str, Dict[str, str]] = None,
        secrets: Dict[str, Dict[str, str]] = None) -> Dict[str, Any]:
    pass

Arguments:

Name Type Default Required
instance_ids list null No
az string null No
filters list null No
force boolean false No

Usage:

{
  "provider": {
    "module": "chaosaws.ec2.actions",
    "func": "stop_instances",
    "type": "python"
  },
  "type": "action",
  "name": "stop-instances"
}
name: stop-instances
provider:
  func: stop_instances
  module: chaosaws.ec2.actions
  type: python
type: action

terminate_instance

Type action
Module chaosaws.ec2.actions
Name terminate_instance
Return None

Terminates a single EC2 instance.

An instance may be targeted by specifying it by instance-id. If only the availability-zone is provided, a random instances in that AZ will be selected and terminated. For more control, please reference the available filters found: https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/ec2.html#EC2.Client.describe_instances

Signature:

def terminate_instance(
        instance_id: str = None,
        az: str = None,
        filters: List[Dict[str, Any]] = None,
        configuration: Dict[str, Dict[str, str]] = None,
        secrets: Dict[str, Dict[str, str]] = None) -> List[Dict[str, Any]]:
    pass

Arguments:

Name Type Default Required
instance_id string null No
az string null No
filters list null No

Usage:

{
  "provider": {
    "module": "chaosaws.ec2.actions",
    "func": "terminate_instance",
    "type": "python"
  },
  "type": "action",
  "name": "terminate-instance"
}
name: terminate-instance
provider:
  func: terminate_instance
  module: chaosaws.ec2.actions
  type: python
type: action

terminate_instances

Type action
Module chaosaws.ec2.actions
Name terminate_instances
Return None

Terminates multiple EC2 instances

A set of instances may be targeted by providing them as the instance-ids.

WARNING: If only an Availability Zone is specified, all instances in that AZ will be terminated.

Additional filters may be used to narrow the scope: https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/ec2.html#EC2.Client.describe_instances

Signature:

def terminate_instances(
        instance_ids: List[str] = None,
        az: str = None,
        filters: List[Dict[str, Any]] = None,
        configuration: Dict[str, Dict[str, str]] = None,
        secrets: Dict[str, Dict[str, str]] = None) -> List[Dict[str, Any]]:
    pass

Arguments:

Name Type Default Required
instance_ids list null No
az string null No
filters list null No

Usage:

{
  "provider": {
    "module": "chaosaws.ec2.actions",
    "func": "terminate_instances",
    "type": "python"
  },
  "type": "action",
  "name": "terminate-instances"
}
name: terminate-instances
provider:
  func: terminate_instances
  module: chaosaws.ec2.actions
  type: python
type: action

awslambda


delete_function_concurrency

Type action
Module chaosaws.awslambda.actions
Name delete_function_concurrency
Return None

Removes concurrency limit applied to the specified Lambda

Signature:

def delete_function_concurrency(
        function_name: str,
        configuration: Dict[str, Dict[str, str]] = None,
        secrets: Dict[str, Dict[str, str]] = None) -> Dict[str, Any]:
    pass

Arguments:

Name Type Default Required
function_name string Yes

Usage:

{
  "provider": {
    "module": "chaosaws.awslambda.actions",
    "arguments": {
      "function_name": ""
    },
    "func": "delete_function_concurrency",
    "type": "python"
  },
  "type": "action",
  "name": "delete-function-concurrency"
}
name: delete-function-concurrency
provider:
  arguments:
    function_name: ''
  func: delete_function_concurrency
  module: chaosaws.awslambda.actions
  type: python
type: action

get_function_concurrency

Type probe
Module chaosaws.awslambda.probes
Name get_function_concurrency
Return None

Get configuration information of lambda by its function name

Signature:

def get_function_concurrency(
        function_name: str,
        configuration: Dict[str, Dict[str, str]] = None,
        secrets: Dict[str, Dict[str, str]] = None) -> bool:
    pass

Arguments:

Name Type Default Required
function_name string Yes

Usage:

{
  "provider": {
    "module": "chaosaws.awslambda.probes",
    "arguments": {
      "function_name": ""
    },
    "func": "get_function_concurrency",
    "type": "python"
  },
  "type": "probe",
  "name": "get-function-concurrency"
}
name: get-function-concurrency
provider:
  arguments:
    function_name: ''
  func: get_function_concurrency
  module: chaosaws.awslambda.probes
  type: python
type: probe

get_function_memory_size

Type probe
Module chaosaws.awslambda.probes
Name get_function_memory_size
Return None

Get the configured memory size of a lambda function.

The returned memory size is specified in megabytes.

Signature:

def get_function_memory_size(function_name: str,
                             qualifier: str = None,
                             configuration: Dict[str, Dict[str, str]] = None,
                             secrets: Dict[str, Dict[str, str]] = None) -> int:
    pass

Arguments:

Name Type Default Required
function_name string Yes
qualifier string null No

Usage:

{
  "provider": {
    "module": "chaosaws.awslambda.probes",
    "arguments": {
      "function_name": ""
    },
    "func": "get_function_memory_size",
    "type": "python"
  },
  "type": "probe",
  "name": "get-function-memory-size"
}
name: get-function-memory-size
provider:
  arguments:
    function_name: ''
  func: get_function_memory_size
  module: chaosaws.awslambda.probes
  type: python
type: probe

get_function_timeout

Type probe
Module chaosaws.awslambda.probes
Name get_function_timeout
Return None

Get the configured timeout of a lambda function.

The returned timeout is specified in number of seconds.

Signature:

def get_function_timeout(function_name: str,
                         qualifier: str = None,
                         configuration: Dict[str, Dict[str, str]] = None,
                         secrets: Dict[str, Dict[str, str]] = None) -> int:
    pass

Arguments:

Name Type Default Required
function_name string Yes
qualifier string null No

Usage:

{
  "provider": {
    "module": "chaosaws.awslambda.probes",
    "arguments": {
      "function_name": ""
    },
    "func": "get_function_timeout",
    "type": "python"
  },
  "type": "probe",
  "name": "get-function-timeout"
}
name: get-function-timeout
provider:
  arguments:
    function_name: ''
  func: get_function_timeout
  module: chaosaws.awslambda.probes
  type: python
type: probe

invoke_function

Type action
Module chaosaws.awslambda.actions
Name invoke_function
Return None

Invokes Lambda.

More information about request arguments are available in the documentation https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/lambda.html#Lambda.Client.invoke

Signature:

def invoke_function(
        function_name: str,
        function_arguments: Dict[str, Any] = None,
        invocation_type: str = 'RequestResponse',
        client_context: Dict[str, Any] = None,
        qualifier: str = None,
        configuration: Dict[str, Dict[str, str]] = None,
        secrets: Dict[str, Dict[str, str]] = None) -> Dict[str, Any]:
    pass

Arguments:

Name Type Default Required
function_name string Yes
function_arguments mapping null No
invocation_type string “RequestResponse” No
client_context mapping null No
qualifier string null No

Usage:

{
  "provider": {
    "module": "chaosaws.awslambda.actions",
    "arguments": {
      "function_name": ""
    },
    "func": "invoke_function",
    "type": "python"
  },
  "type": "action",
  "name": "invoke-function"
}
name: invoke-function
provider:
  arguments:
    function_name: ''
  func: invoke_function
  module: chaosaws.awslambda.actions
  type: python
type: action

put_function_concurrency

Type action
Module chaosaws.awslambda.actions
Name put_function_concurrency
Return None

Throttles Lambda by setting reserved concurrency amount.

Signature:

def put_function_concurrency(
        function_name: str,
        concurrent_executions: int,
        configuration: Dict[str, Dict[str, str]] = None,
        secrets: Dict[str, Dict[str, str]] = None) -> Dict[str, Any]:
    pass

Arguments:

Name Type Default Required
function_name string Yes
concurrent_executions integer Yes

Usage:

{
  "provider": {
    "module": "chaosaws.awslambda.actions",
    "arguments": {
      "function_name": "",
      "concurrent_executions": 0
    },
    "func": "put_function_concurrency",
    "type": "python"
  },
  "type": "action",
  "name": "put-function-concurrency"
}
name: put-function-concurrency
provider:
  arguments:
    concurrent_executions: 0
    function_name: ''
  func: put_function_concurrency
  module: chaosaws.awslambda.actions
  type: python
type: action

put_function_memory_size

Type action
Module chaosaws.awslambda.actions
Name put_function_memory_size
Return None

Sets the function memory size.

Input memory_size argument is specified in megabytes.

Signature:

def put_function_memory_size(
        function_name: str,
        memory_size: int,
        configuration: Dict[str, Dict[str, str]] = None,
        secrets: Dict[str, Dict[str, str]] = None) -> Dict[str, Any]:
    pass

Arguments:

Name Type Default Required
function_name string Yes
memory_size integer Yes

Usage:

{
  "provider": {
    "module": "chaosaws.awslambda.actions",
    "arguments": {
      "memory_size": 0,
      "function_name": ""
    },
    "func": "put_function_memory_size",
    "type": "python"
  },
  "type": "action",
  "name": "put-function-memory-size"
}
name: put-function-memory-size
provider:
  arguments:
    function_name: ''
    memory_size: 0
  func: put_function_memory_size
  module: chaosaws.awslambda.actions
  type: python
type: action

put_function_timeout

Type action
Module chaosaws.awslambda.actions
Name put_function_timeout
Return None

Sets the function timeout.

Input timeout argument is specified in seconds.

Signature:

def put_function_timeout(
        function_name: str,
        timeout: int,
        configuration: Dict[str, Dict[str, str]] = None,
        secrets: Dict[str, Dict[str, str]] = None) -> Dict[str, Any]:
    pass

Arguments:

Name Type Default Required
function_name string Yes
timeout integer Yes

Usage:

{
  "provider": {
    "module": "chaosaws.awslambda.actions",
    "arguments": {
      "timeout": 0,
      "function_name": ""
    },
    "func": "put_function_timeout",
    "type": "python"
  },
  "type": "action",
  "name": "put-function-timeout"
}
name: put-function-timeout
provider:
  arguments:
    function_name: ''
    timeout: 0
  func: put_function_timeout
  module: chaosaws.awslambda.actions
  type: python
type: action

ecs


are_all_desired_tasks_running

Type probe
Module chaosaws.ecs.probes
Name are_all_desired_tasks_running
Return None

Checks to make sure desired and running tasks counts are equal

Signature:

def are_all_desired_tasks_running(
        cluster: str,
        service: str,
        configuration: Dict[str, Dict[str, str]] = None,
        secrets: Dict[str, Dict[str, str]] = None) -> bool:
    pass

Arguments:

Name Type Default Required
cluster string Yes
service string Yes

Usage:

{
  "provider": {
    "module": "chaosaws.ecs.probes",
    "arguments": {
      "service": "",
      "cluster": ""
    },
    "func": "are_all_desired_tasks_running",
    "type": "python"
  },
  "type": "probe",
  "name": "are-all-desired-tasks-running"
}
name: are-all-desired-tasks-running
provider:
  arguments:
    cluster: ''
    service: ''
  func: are_all_desired_tasks_running
  module: chaosaws.ecs.probes
  type: python
type: probe

delete_cluster

Type action
Module chaosaws.ecs.actions
Name delete_cluster
Return None

Delete a given ECS cluster

Signature:

def delete_cluster(
        cluster: str,
        configuration: Dict[str, Dict[str, str]] = None,
        secrets: Dict[str, Dict[str, str]] = None) -> Dict[str, Any]:
    pass

Arguments:

Name Type Default Required
cluster string Yes

Usage:

{
  "provider": {
    "module": "chaosaws.ecs.actions",
    "arguments": {
      "cluster": ""
    },
    "func": "delete_cluster",
    "type": "python"
  },
  "type": "action",
  "name": "delete-cluster"
}
name: delete-cluster
provider:
  arguments:
    cluster: ''
  func: delete_cluster
  module: chaosaws.ecs.actions
  type: python
type: action

delete_service

Type action
Module chaosaws.ecs.actions
Name delete_service
Return None

Update a given ECS service by updating it to set the desired count of tasks to 0 then delete it. If not provided, a random one will be picked up regarding service_pattern, if provided, so that only service names matching the pattern would be be used. This should be a valid regex.

You can specify a cluster by its ARN identifier or, if not provided, the default cluster will be picked up.

Signature:

def delete_service(
        service: str = None,
        cluster: str = None,
        service_pattern: str = None,
        configuration: Dict[str, Dict[str, str]] = None,
        secrets: Dict[str, Dict[str, str]] = None) -> Dict[str, Any]:
    pass

Arguments:

Name Type Default Required
service string null No
cluster string null No
service_pattern string null No

Usage:

{
  "provider": {
    "module": "chaosaws.ecs.actions",
    "func": "delete_service",
    "type": "python"
  },
  "type": "action",
  "name": "delete-service"
}
name: delete-service
provider:
  func: delete_service
  module: chaosaws.ecs.actions
  type: python
type: action

deregister_container_instance

Type action
Module chaosaws.ecs.actions
Name deregister_container_instance
Return None

Deregister a given ECS container. Becareful that tasks handled by this instance will remain orphan.

Signature:

def deregister_container_instance(
        cluster: str,
        instance_id: str,
        force: bool = False,
        configuration: Dict[str, Dict[str, str]] = None,
        secrets: Dict[str, Dict[str, str]] = None) -> Dict[str, Any]:
    pass

Arguments:

Name Type Default Required
cluster string Yes
instance_id string Yes
force boolean false No

Usage:

{
  "provider": {
    "module": "chaosaws.ecs.actions",
    "arguments": {
      "instance_id": "",
      "cluster": ""
    },
    "func": "deregister_container_instance",
    "type": "python"
  },
  "type": "action",
  "name": "deregister-container-instance"
}
name: deregister-container-instance
provider:
  arguments:
    cluster: ''
    instance_id: ''
  func: deregister_container_instance
  module: chaosaws.ecs.actions
  type: python
type: action

service_is_deploying

Type probe
Module chaosaws.ecs.probes
Name service_is_deploying
Return None

Checks to make sure there is not an in progress deployment

Signature:

def service_is_deploying(cluster: str,
                         service: str,
                         configuration: Dict[str, Dict[str, str]] = None,
                         secrets: Dict[str, Dict[str, str]] = None) -> bool:
    pass

Arguments:

Name Type Default Required
cluster string Yes
service string Yes

Usage:

{
  "provider": {
    "module": "chaosaws.ecs.probes",
    "arguments": {
      "service": "",
      "cluster": ""
    },
    "func": "service_is_deploying",
    "type": "python"
  },
  "type": "probe",
  "name": "service-is-deploying"
}
name: service-is-deploying
provider:
  arguments:
    cluster: ''
    service: ''
  func: service_is_deploying
  module: chaosaws.ecs.probes
  type: python
type: probe

stop_task

Type action
Module chaosaws.ecs.actions
Name stop_task
Return None

Stop a given ECS task instance. If no task_id provided, a random task of the given service is stopped.

You can specify a cluster by its ARN identifier or, if not provided, the default cluster will be picked up.

Signature:

def stop_task(cluster: str = None,
              task_id: str = None,
              service: str = None,
              reason: str = 'Chaos Testing',
              configuration: Dict[str, Dict[str, str]] = None,
              secrets: Dict[str, Dict[str, str]] = None) -> Dict[str, Any]:
    pass

Arguments:

Name Type Default Required
cluster string null No
task_id string null No
service string null No
reason string “Chaos Testing” No

Usage:

{
  "provider": {
    "module": "chaosaws.ecs.actions",
    "func": "stop_task",
    "type": "python"
  },
  "type": "action",
  "name": "stop-task"
}
name: stop-task
provider:
  func: stop_task
  module: chaosaws.ecs.actions
  type: python
type: action