title: How do you automate tagging using a Lambda function on AWS?
body: <p>I'm trying to automate tagging for the following resources on AWS:</p>
  
  <ul>
  <li>Amazon RDS</li>
  <li>Amazon DynamoDB</li>
  <li>Amazon Image AMI</li>
  <li>Amazon EC2 Instance</li>
  <li>Amazon Lambda Function</li>
  <li>Amazon RDS Snapshot</li>
  <li>Amazon RDS Security</li>
  <li>Amazon RDS Subnet</li>
  <li>Amazon Route 53 Hosted</li>
  <li>Amazon S3 Bucket</li>
  <li>Amazon CloudFormation</li>
  </ul>
  
  <p>Currently I have a Lambda function that is almost identical to this article: <a href="https://aws.amazon.com/blogs/security/how-to-automatically-tag-amazon-ec2-resources-in-response-to-api-events/" rel="nofollow noreferrer">How to Automatically Tag Amazon EC2 Resources in Response to API Events | AWS Security Blog</a></p>
  
  <p>How can I modify this Lambda function so it tags the above resources as well?</p>
  
  <p>I've tried finding documentation on how to tag these specific resources and I can't seem to find anything that's relevant to tagging using a Lambda function.</p>
  
  <pre><code>elif eventname == 'CreateImage':
      ids.append(detail['responseElements']['imageId'])
      logger.info(ids)
  
  elif eventname == 'CreateSnapshot':
      ids.append(detail['responseElements']['snapshotId'])
      logger.info(ids)
  elif eventname == 'CreateSecurityGroup':
      ids.append(detail['responseElements']['groupId'])
  else:
      logger.warning('Not supported action')
  </code></pre>
  
  <p>The above code is adding tags for EC2, but we need it to add tags to the resources I listed above.</p>