> ## Documentation Index
> Fetch the complete documentation index at: https://docs.formae.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Cancel a running command

> Stop an in-progress apply or destroy without leaving orphaned resources behind.

A command you triggered by mistake, or one that is stuck, is its own kind of
incident. You can cancel it.

## Cancel it

```bash theme={"languages":{"custom":["/languages/pkl.json"]}}
formae cancel
```

With no query, `formae cancel` targets the most recent command. To target specific
in-progress commands, pass a query:

```bash theme={"languages":{"custom":["/languages/pkl.json"]}}
formae cancel --query="command:apply status:InProgress"
```

## What cancel does

By default, cancel is careful about work that is already in flight:

* Only commands in the `InProgress` state can be canceled.
* Resources already executing run through to completion, so formae leaves no
  half-applied or orphaned resources behind. Operations that have not started yet
  are dropped.
* Work already completed is not rolled back. Cancel stops further changes; it does
  not undo what already happened.

This is the live view the moment you cancel. Some resources are already done (the
check marks), a couple are still running to completion (the spinner), and the rest
are canceled. The progress bar turns red to show the command is being canceled:

<div className="fa-term">
  <div className="fa-term-body">  <span style={{fontWeight:'600'}} /><span style={{color:'rgb(232,232,232)',fontWeight:'600'}}>formae</span> <span style={{fontWeight:'600'}} /><span style={{color:'rgb(255,133,51)',fontWeight:'600'}}>status command</span>                                                                                     <span style={{color:'rgb(129,209,219)'}}>↻ live</span><br /><span style={{color:'rgb(85,85,102)'}}>────────────────────────────────────────────────────────────────────────────────────────────────────────────────────</span><br /><span style={{color:'rgb(85,85,102)'}} /><span style={{color:'rgb(85,85,102)',fontWeight:'600'}} /><span style={{color:'rgb(170,170,170)',fontWeight:'600'}}>     ID                          Command   Mode        Progress                         ✓    ✗    ◐    ○    Time</span><br /><span style={{color:'rgb(170,170,170)',fontWeight:'600'}} /><span style={{color:'rgb(248,113,113)'}}>⣾    </span><span style={{color:'rgb(129,209,219)'}}>3GovHX0bguXAqlm8H98bXBebF5q </span><span style={{color:'rgb(232,232,232)'}}>apply     reconcile   </span><span style={{color:'rgb(248,113,113)'}}>███████████████████████</span><span style={{color:'rgb(170,170,170)'}}>░░░░</span><span style={{color:'rgb(232,232,232)'}}> 4/15 4    </span><span style={{color:'rgb(248,113,113)'}}>9    </span><span style={{color:'rgb(170,170,170)'}}>2    </span><span style={{color:'rgb(232,232,232)'}}>0    00:14</span><br /><span style={{color:'rgb(232,232,232)'}} /><span style={{color:'rgb(85,85,102)'}}>────────────────────────────────────────────────────────────────────────────────────────────────────────────────────</span><br /><span style={{color:'rgb(85,85,102)'}} /><br /><span style={{color:'rgb(85,85,102)'}}>  </span><span style={{color:'rgb(85,85,102)',fontWeight:'600'}} /><span style={{color:'rgb(255,133,51)',fontWeight:'600'}}>▌ Targets</span><br />  <span style={{color:'rgb(170,170,170)'}}>      </span><span style={{color:'rgb(170,170,170)',fontWeight:'600'}} /><span style={{color:'rgb(232,232,232)',fontWeight:'600'}} /><span style={{color:'rgb(232,232,232)',fontWeight:'600'}}>Label ▲                                                                                   </span><span style={{color:'rgb(170,170,170)'}}>Operation   Time</span><br />   <span style={{color:'rgb(232,232,232)'}} /><span style={{color:'rgb(232,232,232)'}}>✓</span>    <span style={{color:'rgb(170,170,170)'}}>aws-target</span>                                                                                <span style={{color:'rgb(170,170,170)'}}>create</span>      <span style={{color:'rgb(170,170,170)'}}>00:00</span><br /><br />  <span style={{fontWeight:'600'}} /><span style={{color:'rgb(255,133,51)',fontWeight:'600'}}>▌ Stacks</span><br />  <span style={{color:'rgb(170,170,170)'}}>      </span><span style={{color:'rgb(170,170,170)',fontWeight:'600'}} /><span style={{color:'rgb(232,232,232)',fontWeight:'600'}} /><span style={{color:'rgb(232,232,232)',fontWeight:'600'}}>Label ▲                                                                                   </span><span style={{color:'rgb(170,170,170)'}}>Operation   Time</span><br />   <span style={{color:'rgb(232,232,232)'}}>✓</span>    <span style={{color:'rgb(153,153,153)'}}>lifeline</span>                                                                                  <span style={{color:'rgb(153,153,153)'}}>create</span>      <span style={{color:'rgb(153,153,153)'}}>00:00</span><br /><br />  <span style={{fontWeight:'600'}} /><span style={{color:'rgb(255,133,51)',fontWeight:'600'}}>▌ Resources</span><br />  <span style={{color:'rgb(170,170,170)'}}>      </span><span style={{color:'rgb(170,170,170)',fontWeight:'600'}} /><span style={{color:'rgb(232,232,232)',fontWeight:'600'}} /><span style={{color:'rgb(232,232,232)',fontWeight:'600'}}>Label ▲                                               </span><span style={{color:'rgb(170,170,170)'}}>Type                                Operation   Time</span><br />   <span style={{color:'rgb(170,170,170)'}}>⊘</span>    <span style={{color:'rgb(248,113,113)'}}>lifeline-alb-http-ingress</span>                             <span style={{color:'rgb(248,113,113)'}}>AWS::EC2::SecurityGroupIngress</span>      <span style={{color:'rgb(248,113,113)'}}>create</span>      <span style={{color:'rgb(248,113,113)'}}>—</span><br />   <span style={{color:'rgb(170,170,170)'}}>⊘</span>    <span style={{color:'rgb(248,113,113)'}}>lifeline-alb-sg</span>                                       <span style={{color:'rgb(248,113,113)'}}>AWS::EC2::SecurityGroup</span>             <span style={{color:'rgb(248,113,113)'}}>create</span>      <span style={{color:'rgb(248,113,113)'}}>—</span><br />   <span style={{color:'rgb(232,232,232)'}}>✓</span>    <span style={{color:'rgb(153,153,153)'}}>lifeline-igw</span>                                          <span style={{color:'rgb(153,153,153)'}}>AWS::EC2::InternetGateway</span>           <span style={{color:'rgb(153,153,153)'}}>create</span>      <span style={{color:'rgb(153,153,153)'}}>00:05</span><br />   <span style={{color:'rgb(170,170,170)'}}>⊘</span>    <span style={{color:'rgb(248,113,113)'}}>lifeline-igw-attachment</span>                               <span style={{color:'rgb(248,113,113)'}}>AWS::EC2::VPCGatewayAttachment</span>      <span style={{color:'rgb(248,113,113)'}}>create</span>      <span style={{color:'rgb(248,113,113)'}}>—</span><br />   <span style={{color:'rgb(170,170,170)'}}>⊘</span>    <span style={{color:'rgb(248,113,113)'}}>lifeline-public-route</span>                                 <span style={{color:'rgb(248,113,113)'}}>AWS::EC2::Route</span>                     <span style={{color:'rgb(248,113,113)'}}>create</span>      <span style={{color:'rgb(248,113,113)'}}>—</span><br />   <span style={{color:'rgb(129,209,219)'}}>⣾ </span>   <span style={{color:'rgb(129,209,219)'}}>lifeline-public-rt</span>                                    <span style={{color:'rgb(170,170,170)'}}>AWS::EC2::RouteTable</span>                <span style={{color:'rgb(170,170,170)'}}>create</span>      <span style={{color:'rgb(153,153,153)'}}>00:14</span><br />   <span style={{color:'rgb(129,209,219)'}}>⣾ </span>   <span style={{color:'rgb(129,209,219)'}}>lifeline-public-subnet-1</span>                              <span style={{color:'rgb(170,170,170)'}}>AWS::EC2::Subnet</span>                    <span style={{color:'rgb(170,170,170)'}}>create</span>      <span style={{color:'rgb(153,153,153)'}}>00:14</span><br />   <span style={{color:'rgb(170,170,170)'}}>⊘</span>    <span style={{color:'rgb(248,113,113)'}}>lifeline-public-subnet-1-assoc</span>                        <span style={{color:'rgb(248,113,113)'}}>AWS::EC2::SubnetRouteTableAssocia…</span>  <span style={{color:'rgb(248,113,113)'}}>create</span>      <span style={{color:'rgb(248,113,113)'}}>—</span><br />   <span style={{color:'rgb(170,170,170)'}}>⊘</span>    <span style={{color:'rgb(248,113,113)'}}>lifeline-public-subnet-2</span>                              <span style={{color:'rgb(248,113,113)'}}>AWS::EC2::Subnet</span>                    <span style={{color:'rgb(248,113,113)'}}>create</span>      <span style={{color:'rgb(248,113,113)'}}>—</span><br />   <span style={{color:'rgb(170,170,170)'}}>⊘</span>    <span style={{color:'rgb(248,113,113)'}}>lifeline-public-subnet-2-assoc</span>                        <span style={{color:'rgb(248,113,113)'}}>AWS::EC2::SubnetRouteTableAssocia…</span>  <span style={{color:'rgb(248,113,113)'}}>create</span>      <span style={{color:'rgb(248,113,113)'}}>—</span><br />   <span style={{color:'rgb(170,170,170)'}}>⊘</span>    <span style={{color:'rgb(248,113,113)'}}>lifeline-task-http-ingress</span>                            <span style={{color:'rgb(248,113,113)'}}>AWS::EC2::SecurityGroupIngress</span>      <span style={{color:'rgb(248,113,113)'}}>create</span>      <span style={{color:'rgb(248,113,113)'}}>—</span><br />   <span style={{color:'rgb(170,170,170)'}}>⊘</span>    <span style={{color:'rgb(248,113,113)'}}>lifeline-task-sg</span>                                      <span style={{color:'rgb(248,113,113)'}}>AWS::EC2::SecurityGroup</span>             <span style={{color:'rgb(248,113,113)'}}>create</span>      <span style={{color:'rgb(248,113,113)'}}>—</span><br />   <span style={{color:'rgb(232,232,232)'}}>✓</span>    <span style={{color:'rgb(153,153,153)'}}>lifeline-vpc</span>                                          <span style={{color:'rgb(153,153,153)'}}>AWS::EC2::VPC</span>                       <span style={{color:'rgb(153,153,153)'}}>create</span>      <span style={{color:'rgb(153,153,153)'}}>00:03</span><br /><br /><span style={{color:'rgb(85,85,102)'}}>────────────────────────────────────────────────────────────────────────────────────────────────────────────────────</span></div>
</div>

Once the in-flight resources finish, the command settles into a terminal
`canceled` state. The resources that completed remain under management: inspect
them with `formae inventory`, or remove them with `formae destroy`.

<div className="fa-term">
  <div className="fa-term-body">  <span style={{fontWeight:'600'}} /><span style={{color:'rgb(232,232,232)',fontWeight:'600'}}>formae</span> <span style={{fontWeight:'600'}} /><span style={{color:'rgb(255,133,51)',fontWeight:'600'}}>status command</span>                                                                                     <span style={{color:'rgb(129,209,219)'}}>↻ live</span><br /><span style={{color:'rgb(85,85,102)'}}>────────────────────────────────────────────────────────────────────────────────────────────────────────────────────</span><br /><span style={{color:'rgb(85,85,102)'}} /><span style={{color:'rgb(85,85,102)',fontWeight:'600'}} /><span style={{color:'rgb(170,170,170)',fontWeight:'600'}}>     ID                          Command   Mode        Progress                         ✓    ✗    ◐    ○    Time</span><br /><span style={{color:'rgb(170,170,170)',fontWeight:'600'}} /><span style={{color:'rgb(232,232,232)'}}>⊘    </span><span style={{color:'rgb(129,209,219)'}}>3GovHX0bguXAqlm8H98bXBebF5q </span><span style={{color:'rgb(232,232,232)'}}>apply     reconcile   canceled 6/15                    6    </span><span style={{color:'rgb(248,113,113)'}}>9</span><span style={{color:'rgb(232,232,232)'}}>    0    0    00:22</span><br /><span style={{color:'rgb(232,232,232)'}} /><span style={{color:'rgb(85,85,102)'}}>────────────────────────────────────────────────────────────────────────────────────────────────────────────────────</span><br /><span style={{color:'rgb(85,85,102)'}} /><br /><span style={{color:'rgb(85,85,102)'}}>  </span><span style={{color:'rgb(85,85,102)',fontWeight:'600'}} /><span style={{color:'rgb(255,133,51)',fontWeight:'600'}}>▌ Targets</span><br />  <span style={{color:'rgb(170,170,170)'}}>      </span><span style={{color:'rgb(170,170,170)',fontWeight:'600'}} /><span style={{color:'rgb(232,232,232)',fontWeight:'600'}} /><span style={{color:'rgb(232,232,232)',fontWeight:'600'}}>Label ▲                                                                                   </span><span style={{color:'rgb(170,170,170)'}}>Operation   Time</span><br />   <span style={{color:'rgb(232,232,232)'}} /><span style={{color:'rgb(232,232,232)'}}>✓</span>    <span style={{color:'rgb(170,170,170)'}}>aws-target</span>                                                                                <span style={{color:'rgb(170,170,170)'}}>create</span>      <span style={{color:'rgb(170,170,170)'}}>00:00</span><br /><br />  <span style={{fontWeight:'600'}} /><span style={{color:'rgb(255,133,51)',fontWeight:'600'}}>▌ Stacks</span><br />  <span style={{color:'rgb(170,170,170)'}}>      </span><span style={{color:'rgb(170,170,170)',fontWeight:'600'}} /><span style={{color:'rgb(232,232,232)',fontWeight:'600'}} /><span style={{color:'rgb(232,232,232)',fontWeight:'600'}}>Label ▲                                                                                   </span><span style={{color:'rgb(170,170,170)'}}>Operation   Time</span><br />   <span style={{color:'rgb(232,232,232)'}}>✓</span>    <span style={{color:'rgb(153,153,153)'}}>lifeline</span>                                                                                  <span style={{color:'rgb(153,153,153)'}}>create</span>      <span style={{color:'rgb(153,153,153)'}}>00:00</span><br /><br />  <span style={{fontWeight:'600'}} /><span style={{color:'rgb(255,133,51)',fontWeight:'600'}}>▌ Resources</span><br />  <span style={{color:'rgb(170,170,170)'}}>      </span><span style={{color:'rgb(170,170,170)',fontWeight:'600'}} /><span style={{color:'rgb(232,232,232)',fontWeight:'600'}} /><span style={{color:'rgb(232,232,232)',fontWeight:'600'}}>Label ▲                                               </span><span style={{color:'rgb(170,170,170)'}}>Type                                Operation   Time</span><br />   <span style={{color:'rgb(170,170,170)'}}>⊘</span>    <span style={{color:'rgb(248,113,113)'}}>lifeline-alb-http-ingress</span>                             <span style={{color:'rgb(248,113,113)'}}>AWS::EC2::SecurityGroupIngress</span>      <span style={{color:'rgb(248,113,113)'}}>create</span>      <span style={{color:'rgb(248,113,113)'}}>—</span><br />   <span style={{color:'rgb(170,170,170)'}}>⊘</span>    <span style={{color:'rgb(248,113,113)'}}>lifeline-alb-sg</span>                                       <span style={{color:'rgb(248,113,113)'}}>AWS::EC2::SecurityGroup</span>             <span style={{color:'rgb(248,113,113)'}}>create</span>      <span style={{color:'rgb(248,113,113)'}}>—</span><br />   <span style={{color:'rgb(232,232,232)'}}>✓</span>    <span style={{color:'rgb(153,153,153)'}}>lifeline-igw</span>                                          <span style={{color:'rgb(153,153,153)'}}>AWS::EC2::InternetGateway</span>           <span style={{color:'rgb(153,153,153)'}}>create</span>      <span style={{color:'rgb(153,153,153)'}}>00:05</span><br />   <span style={{color:'rgb(170,170,170)'}}>⊘</span>    <span style={{color:'rgb(248,113,113)'}}>lifeline-igw-attachment</span>                               <span style={{color:'rgb(248,113,113)'}}>AWS::EC2::VPCGatewayAttachment</span>      <span style={{color:'rgb(248,113,113)'}}>create</span>      <span style={{color:'rgb(248,113,113)'}}>—</span><br />   <span style={{color:'rgb(170,170,170)'}}>⊘</span>    <span style={{color:'rgb(248,113,113)'}}>lifeline-public-route</span>                                 <span style={{color:'rgb(248,113,113)'}}>AWS::EC2::Route</span>                     <span style={{color:'rgb(248,113,113)'}}>create</span>      <span style={{color:'rgb(248,113,113)'}}>—</span><br />   <span style={{color:'rgb(232,232,232)'}}>✓</span>    <span style={{color:'rgb(153,153,153)'}}>lifeline-public-rt</span>                                    <span style={{color:'rgb(153,153,153)'}}>AWS::EC2::RouteTable</span>                <span style={{color:'rgb(153,153,153)'}}>create</span>      <span style={{color:'rgb(153,153,153)'}}>00:18</span><br />   <span style={{color:'rgb(232,232,232)'}}>✓</span>    <span style={{color:'rgb(153,153,153)'}}>lifeline-public-subnet-1</span>                              <span style={{color:'rgb(153,153,153)'}}>AWS::EC2::Subnet</span>                    <span style={{color:'rgb(153,153,153)'}}>create</span>      <span style={{color:'rgb(153,153,153)'}}>00:20</span><br />   <span style={{color:'rgb(170,170,170)'}}>⊘</span>    <span style={{color:'rgb(248,113,113)'}}>lifeline-public-subnet-1-assoc</span>                        <span style={{color:'rgb(248,113,113)'}}>AWS::EC2::SubnetRouteTableAssocia…</span>  <span style={{color:'rgb(248,113,113)'}}>create</span>      <span style={{color:'rgb(248,113,113)'}}>—</span><br />   <span style={{color:'rgb(170,170,170)'}}>⊘</span>    <span style={{color:'rgb(248,113,113)'}}>lifeline-public-subnet-2</span>                              <span style={{color:'rgb(248,113,113)'}}>AWS::EC2::Subnet</span>                    <span style={{color:'rgb(248,113,113)'}}>create</span>      <span style={{color:'rgb(248,113,113)'}}>—</span><br />   <span style={{color:'rgb(170,170,170)'}}>⊘</span>    <span style={{color:'rgb(248,113,113)'}}>lifeline-public-subnet-2-assoc</span>                        <span style={{color:'rgb(248,113,113)'}}>AWS::EC2::SubnetRouteTableAssocia…</span>  <span style={{color:'rgb(248,113,113)'}}>create</span>      <span style={{color:'rgb(248,113,113)'}}>—</span><br />   <span style={{color:'rgb(170,170,170)'}}>⊘</span>    <span style={{color:'rgb(248,113,113)'}}>lifeline-task-http-ingress</span>                            <span style={{color:'rgb(248,113,113)'}}>AWS::EC2::SecurityGroupIngress</span>      <span style={{color:'rgb(248,113,113)'}}>create</span>      <span style={{color:'rgb(248,113,113)'}}>—</span><br />   <span style={{color:'rgb(170,170,170)'}}>⊘</span>    <span style={{color:'rgb(248,113,113)'}}>lifeline-task-sg</span>                                      <span style={{color:'rgb(248,113,113)'}}>AWS::EC2::SecurityGroup</span>             <span style={{color:'rgb(248,113,113)'}}>create</span>      <span style={{color:'rgb(248,113,113)'}}>—</span><br />   <span style={{color:'rgb(232,232,232)'}}>✓</span>    <span style={{color:'rgb(153,153,153)'}}>lifeline-vpc</span>                                          <span style={{color:'rgb(153,153,153)'}}>AWS::EC2::VPC</span>                       <span style={{color:'rgb(153,153,153)'}}>create</span>      <span style={{color:'rgb(153,153,153)'}}>00:03</span><br /><br /><span style={{color:'rgb(85,85,102)'}}>────────────────────────────────────────────────────────────────────────────────────────────────────────────────────</span></div>
</div>

## See also

* [Troubleshoot a failed command](/documentation/guides/troubleshoot-a-failed-command): find out which resource broke and why.
* [Incidents and recovery](/documentation/guides/incidents-and-recovery): fix a live incident with a patch and settle up afterwards.
* [CLI reference](/documentation/reference/cli): full flags for `apply`, `cancel`, `status`, `inventory`, and `destroy`.
