title: AWS IoT topic rule deletion by cloudformation failed with NotStabilized error
body: <p>I have deployed successfully this stack:</p>
  <pre><code>AWSTemplateFormatVersion: '2010-09-09'
  Transform: AWS::Serverless-2016-10-31
  Description: &gt;
    some decription
  
  Parameters:
    ImageUri:
      Type: String
  
  Resources:
    SomeLambda:
      Type: AWS::Serverless::Function
      Properties:
        PackageType: Image
        ImageConfig:
          Command: [&quot;src/something&quot;]
        ImageUri: !Ref ImageUri
        Events:
          IoTRule:
            Type: IoTRule
            Properties:
              Sql: SELECT * FROM 'something/+/+'
              AwsIotSqlVersion: 2016-03-23
  
  </code></pre>
  <p>I deploy the above stack as a nested stack of my root stack.</p>
  <p>When im trying to delete the stack, the &quot;AWS::IoT::TopicRule&quot; resource gives me a &quot;DELETE IN PROGRESS&quot; status for about 15 minutes and then &quot;DELETE FAILED&quot; status.</p>
  <p>The error message on cloudformation is:</p>
  <pre><code>Resource handler returned message: &quot;Exceeded attempts to wait&quot; (RequestToken: ***********, HandlerErrorCode: NotStabilized)
  </code></pre>
  <p>I looked at the cloudformation docs of the error codes(<a href="https://docs.aws.amazon.com/es_es/cloudformation-cli/latest/userguide/resource-type-test-contract-errors.html" rel="nofollow noreferrer">https://docs.aws.amazon.com/es_es/cloudformation-cli/latest/userguide/resource-type-test-contract-errors.html</a>),
  it says that:</p>
  <pre><code>NotStabilized
  
  The downstream resource failed to complete all of its ready-state checks.
  
  Type: Terminal
  </code></pre>
  <p>does anyone know how to solve this ?</p>
  <p>Thanks</p>