AWS AZ
action AZ:EC2

# fail_az

Simulates the loss of an AZ in an AWS Region for EC2

Run it now
View details

Type | action
Module | azchaosaws.ec2.actions
Name | fail_az
Return | mapping

This function simulates the lost of an AZ in an AWS Region for EC2. For network failure type, it uses a blackhole network ACL with deny all traffic. For instance failure type, it stops normal instances with force; stops persistent spot instances; cancels spot requests and terminates one-time spot instances. Ensure your subnets are tagged if failure_type = “network” and ensure your instances are tagged if failure_type = “instance”. Instances that are not in pending or running state will still be captured and stopped.

Usage

JSON

    {
      "name": "fail_az",
      "type": "action",
      "provider": {
        "type": "python",
        "module": "azchaosaws.ec2.actions",
        "func": "fail_az",
        "arguments": {
          "az": "",
          "dry_run": true
        }
      }
    }

YAML

    name: fail_az
    provider:
      arguments:
        az: ""
        dry_run: true
      func: fail_az
      module: azchaosaws.ec2.actions
      type: python
    type: action

Arguments

Name | Type | Default | Required | Title | Description
--- | --- | --- | --- | --- | ---
az | string |  | Yes | Availability Zone | AZ to target
tags | List[Dict[str, str]] | [{"Key": "AZ_FAILURE", "Value": "True"}] | No | Tags | Match only resources with these tags
failure_type | str | network | No | Failure Type | Type of failure to apply: network, instance
dry_run | bool | false | No | Dry Run | Only perform a dry run for it

Required:

- dry_run (bool): The boolean flag to simulate a dry run or not. Setting to True will only run read-only operations and not make changes to resources. (Accepted values: True | False)

At least one of:

- az (str): An availability zone
- filters (List[Dict[str, Any]]): A list of key/value pair to identify subnets by. Provide availability-zone filter if az is not specified.

Optional:

- failure_type (str): The failure type to simulate. (Accepted values: “network” | “instance”) (Default: “network”)
- state_path (str): Path to generate the state data (Default: fail_az.ec2.json). This file is used for recover_az (rollback).

Return structure

    {
      "AvailabilityZone": str,
      "DryRun": bool,
      "Subnets":
        [
          {
            "SubnetId": str,
            "VpcId": str,
            "Before": {
              "NetworkAclId": str,
              "NetworkAclAssociationId": str
            },
            "After": {
              "NetworkAclId": str,
              "NetworkAclAssociationId": str
            }
          },
          ...
        ],
      "Instances":
        [
          {
            "InstanceId": str,
            "Before": {
              "State": 'pending'|'running'
            }
            "After": {
              "State": 'stopping'|'stopped'
            }
          },
          ...
        ]
    }

Signature

    def fail_az(
        az: str = None,
        dry_run: bool = None,
        failure_type: str = "network",
        filters: List[Dict[str, Any]] = None,
        state_path: str = "fail_az.{}.json".format(__package__.split(".", 1)[1]),
        configuration: Configuration = None,
    ) -> Dict[str, Any]:
        pass

## Related starters

- AWS AZ
  action AZ:EC2

  ## `recover_az`

  Rolls back the subnet(s) and/or EC2 instances that were affected by the fail_az action
- AWS AZ
  action AZ:ELBv2

  ## `recover_az`

  Rolls back the ELB(s) that were affected by the fail_az action
- AWS AZ
  action AZ:EC2

  ## `recover_az`

  Rolls back the subnet(s) and/or EC2 instances that were affected by the fail_az action