automated-actions/AWS_EBS_VOLUME_LOST/SydneySummitDemo/aws_ebs_vol_lost_importantapp-cfn.yaml [73:110]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  CustomLookupAmi:
    Type: Custom::LookupAmi
    Version: 1.0
    Properties:
      ServiceToken: !GetAtt LambdaLookupAmi.Arn
      Region: !Ref 'AWS::Region'
  LambdaLookupAmi:
        Type: "AWS::Lambda::Function"
        Properties:
          Handler: index.lambda_handler
          Role: !GetAtt ExecutionRole.Arn
          Runtime: python3.6
          Timeout: 60
          Code:
            ZipFile: |
              import boto3
              import cfnresponse
              from dateutil import parser

              def lambda_handler(event, context):
                  try:
                      if event['RequestType'] == 'Delete':
                        responseData = {'Delete': 'SUCCESS'}
                        cfnresponse.send(event, context, cfnresponse.SUCCESS, responseData)
                      else:
                        region = event['ResourceProperties']['Region']

                        def newest_image(list_of_images):
                            latest = None
                            for image in list_of_images:
                                if not latest:
                                    latest = image
                                    continue
                                if parser.parse(image['CreationDate']) > parser.parse(latest['CreationDate']):
                                    latest = image
                            return latest

                        client = boto3.client('ec2', region_name=region)
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



automated-actions/AWS_EBS_VOLUME_LOST/stepbystep/step_2_app_reinvent_workshop.yml [118:155]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  CustomLookupAmi:
    Type: Custom::LookupAmi
    Version: 1.0
    Properties:
      ServiceToken: !GetAtt LambdaLookupAmi.Arn
      Region: !Ref 'AWS::Region'
  LambdaLookupAmi:
        Type: "AWS::Lambda::Function"
        Properties:
          Handler: index.lambda_handler
          Role: !GetAtt ExecutionRole.Arn
          Runtime: python3.6
          Timeout: 60
          Code:
            ZipFile: |
              import boto3
              import cfnresponse
              from dateutil import parser

              def lambda_handler(event, context):
                  try:
                      if event['RequestType'] == 'Delete':
                        responseData = {'Delete': 'SUCCESS'}
                        cfnresponse.send(event, context, cfnresponse.SUCCESS, responseData)
                      else:
                        region = event['ResourceProperties']['Region']

                        def newest_image(list_of_images):
                            latest = None
                            for image in list_of_images:
                                if not latest:
                                    latest = image
                                    continue
                                if parser.parse(image['CreationDate']) > parser.parse(latest['CreationDate']):
                                    latest = image
                            return latest

                        client = boto3.client('ec2', region_name=region)
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



