Boto3 - Delete_snapshot not evaluating variables
<p>I'm trying to run boto3 to loop through snapshots older than 14 days.
It can find all the snapshots older than 14 days fine, and I've verified that all that works okay. The problem is when it runs through the dictionary trying to delete, it looks like the function isn't correctly evaluating the variable (See below). </p>

<p>It seems to just include it as a string. </p>

<p>The loop runs through the dict using a "for snapshot in ..." if'ing the tags to find the snapshots ready for deletion. Here's the 'if' part:</p>

<pre><code> if snap_start_time &lt; expiry: # check if it's more than a &lt;expiry&gt; old
   print "Deleting Snapshot: " + snapshot['SnapshotId']
   response = ec2client.delete_snapshot(
     SnapshotId=snapshot['SnapshotId']
   )
</code></pre>

<p>errors here:</p>

<pre><code>Deleting Snapshot: snap-f4f0079d
Traceback (most recent call last):
  File "./aws-snap.py", line 27, in &lt;module&gt;
SnapshotId=snapshot['SnapshotId']
  File "/usr/lib/python2.6/site-packages/botocore/client.py", line 159, in _api_call
    return self._make_api_call(operation_name, kwargs)
  File "/usr/lib/python2.6/site-packages/botocore/client.py", line 494, in _make_api_call
    raise ClientError(parsed_response, operation_name)
botocore.exceptions.ClientError: An error occurred (InvalidSnapshot.NotFound) when calling the DeleteSnapshot operation: None
</code></pre>

<p>Any clues? \o/</p>

<p>As it turns out, referencing straight from the dictionary is a bad idea. It needs to be wrapped in str() and provided with the DryRun=False option too.</p>

python boto3 amazon-api