title: AWS Lambda boto3: Filter Instances by Launch Time = today
body: <p>I'm trying to automatically backup my EC2 instances through AWS Lambda.</p>
  
  <p>I used these 2 scripts and they work just fine.
  <a href="https://gist.github.com/bkozora/724e01903a9ad481d21e" rel="nofollow noreferrer">https://gist.github.com/bkozora/724e01903a9ad481d21e</a>
  <a href="https://gist.github.com/bkozora/d4f1cf0e5cf26acdd377" rel="nofollow noreferrer">https://gist.github.com/bkozora/d4f1cf0e5cf26acdd377</a></p>
  
  <p>But I would like to add the functionality that the scripts only delete or backup the instances that have been launched today and have a Backup-Tag.</p>
  
  <p>I think I could achieve this by additionally filtering the list of instances by Launch Time = (date of today) and then execute the function for the filtered list just before midnight.</p>
  
  <p>Sadly I have no idea what the syntax would look like to achieve this since I'm completely new to this.</p>
  
  <p>But just for further clarification the said part of the code should look something like this:</p>
  
  <pre><code>#....
  
  var date = datetime.datetime.now();
  
  Filters=[
              {'Name': 'tag-key', 'Values': ['Backup']},
              {'Name': 'instance.launch_time', 'Values': [date]}        
          ]
  
  #....
  #(and then the code to make a backup of every instance in the filtered list.
  </code></pre>
  
  <p>Couldn't find anything on filtering lists by Launch Time so hopefully someone can help me out here.</p>