ソースを参照

feat:raw s3 file to prep s3 csv 함수 생성

ds.seo 4 年 前
コミット
a8fcb2be7c

+ 25 - 65
.serverless/cloudformation-template-update-stack.json

@@ -71,16 +71,10 @@
         }
       }
     },
-    "TestDashosLogGroup": {
-      "Type": "AWS::Logs::LogGroup",
-      "Properties": {
-        "LogGroupName": "/aws/lambda/hnw-wallpad-etl-dev-test-os"
-      }
-    },
     "PrepDashfLogGroup": {
       "Type": "AWS::Logs::LogGroup",
       "Properties": {
-        "LogGroupName": "/aws/lambda/hdci-wallpad-raw-to-consumpt"
+        "LogGroupName": "/aws/lambda/hdci-wallpad-raw-to-prep"
       }
     },
     "IamRoleLambdaExecution": {
@@ -125,10 +119,7 @@
                   ],
                   "Resource": [
                     {
-                      "Fn::Sub": "arn:${AWS::Partition}:logs:${AWS::Region}:${AWS::AccountId}:log-group:/aws/lambda/hdci-wallpad-raw-to-consumpt:*"
-                    },
-                    {
-                      "Fn::Sub": "arn:${AWS::Partition}:logs:${AWS::Region}:${AWS::AccountId}:log-group:/aws/lambda/hnw-wallpad-etl-dev*:*"
+                      "Fn::Sub": "arn:${AWS::Partition}:logs:${AWS::Region}:${AWS::AccountId}:log-group:/aws/lambda/hdci-wallpad-raw-to-prep:*"
                     }
                   ]
                 },
@@ -139,19 +130,24 @@
                   ],
                   "Resource": [
                     {
-                      "Fn::Sub": "arn:${AWS::Partition}:logs:${AWS::Region}:${AWS::AccountId}:log-group:/aws/lambda/hdci-wallpad-raw-to-consumpt:*:*"
-                    },
-                    {
-                      "Fn::Sub": "arn:${AWS::Partition}:logs:${AWS::Region}:${AWS::AccountId}:log-group:/aws/lambda/hnw-wallpad-etl-dev*:*:*"
+                      "Fn::Sub": "arn:${AWS::Partition}:logs:${AWS::Region}:${AWS::AccountId}:log-group:/aws/lambda/hdci-wallpad-raw-to-prep:*:*"
                     }
                   ]
                 },
                 {
                   "Effect": "Allow",
                   "Action": [
-                    "s3:*"
+                    "s3:ListBucket",
+                    "s3:GetObject"
+                  ],
+                  "Resource": "arn:aws:s3:::homenetwork-data/*"
+                },
+                {
+                  "Effect": "Allow",
+                  "Action": [
+                    "s3:PutObject"
                   ],
-                  "Resource": "arn:aws:s3:::homenetwork-data*"
+                  "Resource": "arn:aws:s3:::hdci-wallpad-prep/*"
                 }
               ]
             }
@@ -173,31 +169,6 @@
         }
       }
     },
-    "TestDashosLambdaFunction": {
-      "Type": "AWS::Lambda::Function",
-      "Properties": {
-        "Code": {
-          "S3Bucket": {
-            "Ref": "ServerlessDeploymentBucket"
-          },
-          "S3Key": "serverless/hnw-wallpad-etl/dev/1617672916005-2021-04-06T01:35:16.005Z/test-os.zip"
-        },
-        "Handler": "handler.main",
-        "Runtime": "python3.8",
-        "FunctionName": "hnw-wallpad-etl-dev-test-os",
-        "MemorySize": 1024,
-        "Timeout": 180,
-        "Role": {
-          "Fn::GetAtt": [
-            "IamRoleLambdaExecution",
-            "Arn"
-          ]
-        }
-      },
-      "DependsOn": [
-        "TestDashosLogGroup"
-      ]
-    },
     "PrepDashfLambdaFunction": {
       "Type": "AWS::Lambda::Function",
       "Properties": {
@@ -205,13 +176,18 @@
           "S3Bucket": {
             "Ref": "ServerlessDeploymentBucket"
           },
-          "S3Key": "serverless/hnw-wallpad-etl/dev/1617672916005-2021-04-06T01:35:16.005Z/preprocess-hdci-wallpad-raw-to-consumpt.zip"
+          "S3Key": "serverless/hnw-wallpad-etl/dev/1617779857545-2021-04-07T07:17:37.545Z/preprocess-hdci-wallpad-raw-to-prep.zip"
         },
         "Handler": "preprocess/lambda_function.lambda_handler",
         "Runtime": "python3.8",
-        "FunctionName": "hdci-wallpad-raw-to-consumpt",
+        "FunctionName": "hdci-wallpad-raw-to-prep",
         "MemorySize": 1024,
         "Timeout": 180,
+        "Environment": {
+          "Variables": {
+            "PREP_BUCKET": "hdci-wallpad-prep"
+          }
+        },
         "Role": {
           "Fn::GetAtt": [
             "IamRoleLambdaExecution",
@@ -223,24 +199,14 @@
         "PrepDashfLogGroup"
       ]
     },
-    "TestDashosLambdaVersionAbMY2W421EV7Onbqh1U3velQvEWnt8Xz9joty1rhuDk": {
-      "Type": "AWS::Lambda::Version",
-      "DeletionPolicy": "Retain",
-      "Properties": {
-        "FunctionName": {
-          "Ref": "TestDashosLambdaFunction"
-        },
-        "CodeSha256": "h5R5cTSRBhXaR8NKeYHgDTvM1SjLJ0zZd9RqBBRL81Q="
-      }
-    },
-    "PrepDashfLambdaVersionOivXBbd96ShcQRZiAZWj8yDOP9YhLHKHFKRrwPoW7Y": {
+    "PrepDashfLambdaVersion6kG0JfRlaV9PcfPIfqXoZs7UXmFownZER3v6tOps6iY": {
       "Type": "AWS::Lambda::Version",
       "DeletionPolicy": "Retain",
       "Properties": {
         "FunctionName": {
           "Ref": "PrepDashfLambdaFunction"
         },
-        "CodeSha256": "uFdeqlWzPgDniaXKgNQCyJdCfevjHzxrbAllyupe/i0="
+        "CodeSha256": "pzZFpQxx/iOmdihZHN62crmDKmGlSChnGjtFpayNX28="
       }
     },
     "PrepDashfCustomS31": {
@@ -257,7 +223,7 @@
             "Arn"
           ]
         },
-        "FunctionName": "hdci-wallpad-raw-to-consumpt",
+        "FunctionName": "hdci-wallpad-raw-to-prep",
         "BucketName": "homenetwork-data",
         "BucketConfigs": [
           {
@@ -363,7 +329,7 @@
           "S3Bucket": {
             "Ref": "ServerlessDeploymentBucket"
           },
-          "S3Key": "serverless/hnw-wallpad-etl/dev/1617672916005-2021-04-06T01:35:16.005Z/custom-resources.zip"
+          "S3Key": "serverless/hnw-wallpad-etl/dev/1617779857545-2021-04-07T07:17:37.545Z/custom-resources.zip"
         },
         "FunctionName": "hnw-wallpad-etl-undefined-custom-resource-existing-s3",
         "Handler": "s3/handler.handler",
@@ -388,16 +354,10 @@
         "Ref": "ServerlessDeploymentBucket"
       }
     },
-    "TestDashosLambdaFunctionQualifiedArn": {
-      "Description": "Current Lambda function version",
-      "Value": {
-        "Ref": "TestDashosLambdaVersionAbMY2W421EV7Onbqh1U3velQvEWnt8Xz9joty1rhuDk"
-      }
-    },
     "PrepDashfLambdaFunctionQualifiedArn": {
       "Description": "Current Lambda function version",
       "Value": {
-        "Ref": "PrepDashfLambdaVersionOivXBbd96ShcQRZiAZWj8yDOP9YhLHKHFKRrwPoW7Y"
+        "Ref": "PrepDashfLambdaVersion6kG0JfRlaV9PcfPIfqXoZs7UXmFownZER3v6tOps6iY"
       }
     }
   }

+ 37 - 84
.serverless/serverless-state.json

@@ -7,6 +7,7 @@
     "provider": {
       "name": "aws",
       "runtime": "python3.8",
+      "lambdaHashingVersion": "20201221",
       "stage": "dev",
       "region": "ap-northeast-2",
       "memorySize": 1024,
@@ -15,11 +16,22 @@
         {
           "Effect": "Allow",
           "Action": [
-            "s3:*"
+            "s3:ListBucket",
+            "s3:GetObject"
           ],
-          "Resource": "arn:aws:s3:::homenetwork-data*"
+          "Resource": "arn:aws:s3:::homenetwork-data/*"
+        },
+        {
+          "Effect": "Allow",
+          "Action": [
+            "s3:PutObject"
+          ],
+          "Resource": "arn:aws:s3:::hdci-wallpad-prep/*"
         }
       ],
+      "environment": {
+        "PREP_BUCKET": "hdci-wallpad-prep"
+      },
       "variableSyntax": "\\${([^{}:]+?(?:\\(|:)(?:[^:{}][^{}]*?)?)}",
       "versionFunctions": true,
       "compiledCloudFormationTemplate": {
@@ -95,16 +107,10 @@
               }
             }
           },
-          "TestDashosLogGroup": {
-            "Type": "AWS::Logs::LogGroup",
-            "Properties": {
-              "LogGroupName": "/aws/lambda/hnw-wallpad-etl-dev-test-os"
-            }
-          },
           "PrepDashfLogGroup": {
             "Type": "AWS::Logs::LogGroup",
             "Properties": {
-              "LogGroupName": "/aws/lambda/hdci-wallpad-raw-to-consumpt"
+              "LogGroupName": "/aws/lambda/hdci-wallpad-raw-to-prep"
             }
           },
           "IamRoleLambdaExecution": {
@@ -149,10 +155,7 @@
                         ],
                         "Resource": [
                           {
-                            "Fn::Sub": "arn:${AWS::Partition}:logs:${AWS::Region}:${AWS::AccountId}:log-group:/aws/lambda/hdci-wallpad-raw-to-consumpt:*"
-                          },
-                          {
-                            "Fn::Sub": "arn:${AWS::Partition}:logs:${AWS::Region}:${AWS::AccountId}:log-group:/aws/lambda/hnw-wallpad-etl-dev*:*"
+                            "Fn::Sub": "arn:${AWS::Partition}:logs:${AWS::Region}:${AWS::AccountId}:log-group:/aws/lambda/hdci-wallpad-raw-to-prep:*"
                           }
                         ]
                       },
@@ -163,15 +166,15 @@
                         ],
                         "Resource": [
                           {
-                            "Fn::Sub": "arn:${AWS::Partition}:logs:${AWS::Region}:${AWS::AccountId}:log-group:/aws/lambda/hdci-wallpad-raw-to-consumpt:*:*"
-                          },
-                          {
-                            "Fn::Sub": "arn:${AWS::Partition}:logs:${AWS::Region}:${AWS::AccountId}:log-group:/aws/lambda/hnw-wallpad-etl-dev*:*:*"
+                            "Fn::Sub": "arn:${AWS::Partition}:logs:${AWS::Region}:${AWS::AccountId}:log-group:/aws/lambda/hdci-wallpad-raw-to-prep:*:*"
                           }
                         ]
                       },
                       {
                         "$ref": "$[\"service\"][\"provider\"][\"iamRoleStatements\"][0]"
+                      },
+                      {
+                        "$ref": "$[\"service\"][\"provider\"][\"iamRoleStatements\"][1]"
                       }
                     ]
                   }
@@ -193,31 +196,6 @@
               }
             }
           },
-          "TestDashosLambdaFunction": {
-            "Type": "AWS::Lambda::Function",
-            "Properties": {
-              "Code": {
-                "S3Bucket": {
-                  "Ref": "ServerlessDeploymentBucket"
-                },
-                "S3Key": "serverless/hnw-wallpad-etl/dev/1617672916005-2021-04-06T01:35:16.005Z/test-os.zip"
-              },
-              "Handler": "handler.main",
-              "Runtime": "python3.8",
-              "FunctionName": "hnw-wallpad-etl-dev-test-os",
-              "MemorySize": 1024,
-              "Timeout": 180,
-              "Role": {
-                "Fn::GetAtt": [
-                  "IamRoleLambdaExecution",
-                  "Arn"
-                ]
-              }
-            },
-            "DependsOn": [
-              "TestDashosLogGroup"
-            ]
-          },
           "PrepDashfLambdaFunction": {
             "Type": "AWS::Lambda::Function",
             "Properties": {
@@ -225,13 +203,18 @@
                 "S3Bucket": {
                   "Ref": "ServerlessDeploymentBucket"
                 },
-                "S3Key": "serverless/hnw-wallpad-etl/dev/1617672916005-2021-04-06T01:35:16.005Z/preprocess-hdci-wallpad-raw-to-consumpt.zip"
+                "S3Key": "serverless/hnw-wallpad-etl/dev/1617779857545-2021-04-07T07:17:37.545Z/preprocess-hdci-wallpad-raw-to-prep.zip"
               },
               "Handler": "preprocess/lambda_function.lambda_handler",
               "Runtime": "python3.8",
-              "FunctionName": "hdci-wallpad-raw-to-consumpt",
+              "FunctionName": "hdci-wallpad-raw-to-prep",
               "MemorySize": 1024,
               "Timeout": 180,
+              "Environment": {
+                "Variables": {
+                  "PREP_BUCKET": "hdci-wallpad-prep"
+                }
+              },
               "Role": {
                 "Fn::GetAtt": [
                   "IamRoleLambdaExecution",
@@ -243,24 +226,14 @@
               "PrepDashfLogGroup"
             ]
           },
-          "TestDashosLambdaVersionAbMY2W421EV7Onbqh1U3velQvEWnt8Xz9joty1rhuDk": {
-            "Type": "AWS::Lambda::Version",
-            "DeletionPolicy": "Retain",
-            "Properties": {
-              "FunctionName": {
-                "Ref": "TestDashosLambdaFunction"
-              },
-              "CodeSha256": "h5R5cTSRBhXaR8NKeYHgDTvM1SjLJ0zZd9RqBBRL81Q="
-            }
-          },
-          "PrepDashfLambdaVersionOivXBbd96ShcQRZiAZWj8yDOP9YhLHKHFKRrwPoW7Y": {
+          "PrepDashfLambdaVersion6kG0JfRlaV9PcfPIfqXoZs7UXmFownZER3v6tOps6iY": {
             "Type": "AWS::Lambda::Version",
             "DeletionPolicy": "Retain",
             "Properties": {
               "FunctionName": {
                 "Ref": "PrepDashfLambdaFunction"
               },
-              "CodeSha256": "uFdeqlWzPgDniaXKgNQCyJdCfevjHzxrbAllyupe/i0="
+              "CodeSha256": "pzZFpQxx/iOmdihZHN62crmDKmGlSChnGjtFpayNX28="
             }
           },
           "PrepDashfCustomS31": {
@@ -277,7 +250,7 @@
                   "Arn"
                 ]
               },
-              "FunctionName": "hdci-wallpad-raw-to-consumpt",
+              "FunctionName": "hdci-wallpad-raw-to-prep",
               "BucketName": "homenetwork-data",
               "BucketConfigs": [
                 {
@@ -383,7 +356,7 @@
                 "S3Bucket": {
                   "Ref": "ServerlessDeploymentBucket"
                 },
-                "S3Key": "serverless/hnw-wallpad-etl/dev/1617672916005-2021-04-06T01:35:16.005Z/custom-resources.zip"
+                "S3Key": "serverless/hnw-wallpad-etl/dev/1617779857545-2021-04-07T07:17:37.545Z/custom-resources.zip"
               },
               "FunctionName": "hnw-wallpad-etl-undefined-custom-resource-existing-s3",
               "Handler": "s3/handler.handler",
@@ -408,16 +381,10 @@
               "Ref": "ServerlessDeploymentBucket"
             }
           },
-          "TestDashosLambdaFunctionQualifiedArn": {
-            "Description": "Current Lambda function version",
-            "Value": {
-              "Ref": "TestDashosLambdaVersionAbMY2W421EV7Onbqh1U3velQvEWnt8Xz9joty1rhuDk"
-            }
-          },
           "PrepDashfLambdaFunctionQualifiedArn": {
             "Description": "Current Lambda function version",
             "Value": {
-              "Ref": "PrepDashfLambdaVersionOivXBbd96ShcQRZiAZWj8yDOP9YhLHKHFKRrwPoW7Y"
+              "Ref": "PrepDashfLambdaVersion6kG0JfRlaV9PcfPIfqXoZs7UXmFownZER3v6tOps6iY"
             }
           }
         }
@@ -536,24 +503,10 @@
     ],
     "pluginsData": {},
     "functions": {
-      "test-os": {
-        "handler": "handler.main",
-        "events": [],
-        "name": "hnw-wallpad-etl-dev-test-os",
-        "module": ".",
-        "package": {
-          "artifact": "C:\\Users\\icontrols\\PycharmProjects\\hnw_wallpad_etl\\.serverless\\test-os.zip"
-        },
-        "memory": 1024,
-        "timeout": 180,
-        "runtime": "python3.8",
-        "vpc": {},
-        "versionLogicalId": "TestDashosLambdaVersionAbMY2W421EV7Onbqh1U3velQvEWnt8Xz9joty1rhuDk"
-      },
       "prep-f": {
         "handler": "preprocess/lambda_function.lambda_handler",
         "module": "preprocess",
-        "name": "hdci-wallpad-raw-to-consumpt",
+        "name": "hdci-wallpad-raw-to-prep",
         "events": [
           {
             "s3": {
@@ -564,13 +517,13 @@
           }
         ],
         "package": {
-          "artifact": ".serverless\\preprocess-hdci-wallpad-raw-to-consumpt.zip"
+          "artifact": ".serverless\\preprocess-hdci-wallpad-raw-to-prep.zip"
         },
         "memory": 1024,
         "timeout": 180,
         "runtime": "python3.8",
         "vpc": {},
-        "versionLogicalId": "PrepDashfLambdaVersionOivXBbd96ShcQRZiAZWj8yDOP9YhLHKHFKRrwPoW7Y"
+        "versionLogicalId": "PrepDashfLambdaVersion6kG0JfRlaV9PcfPIfqXoZs7UXmFownZER3v6tOps6iY"
       }
     },
     "configValidationMode": "warn",
@@ -592,7 +545,7 @@
           "**/requirements.txt",
           "venv/**"
         ],
-        "artifactDirectoryName": "serverless/hnw-wallpad-etl/dev/1617672916005-2021-04-06T01:35:16.005Z"
+        "artifactDirectoryName": "serverless/hnw-wallpad-etl/dev/1617779857545-2021-04-07T07:17:37.545Z"
       },
       "custom": {
         "$ref": "$[\"service\"][\"custom\"]"
@@ -605,7 +558,7 @@
   },
   "package": {
     "individually": true,
-    "artifactDirectoryName": "serverless/hnw-wallpad-etl/dev/1617672916005-2021-04-06T01:35:16.005Z",
+    "artifactDirectoryName": "serverless/hnw-wallpad-etl/dev/1617779857545-2021-04-07T07:17:37.545Z",
     "artifact": ""
   }
 }

+ 43 - 10
preprocess/lambda_function.py

@@ -2,24 +2,34 @@ import logging
 import s3fs
 import pandas as pd
 import ast
+import os
 
 logger = logging.getLogger(__name__)
 logger.setLevel(logging.INFO)
-s3 = s3fs.S3FileSystem()
+s3fs = s3fs.S3FileSystem()
 
 
 def lambda_handler(event, context):
-    # region, bucket_name, object_key = parse_event(event)
-    bucket_name = 'homenetwork-data'
-    object_key = '2021/03/30/09/homenetwork-data-firehose-1-2021-03-30-09-57-23-269c4651-2ee0-49a5-a074-039a34f1f8dd'
+    region, bucket_name, object_key = parse_event(event)
+    # bucket_name = 'homenetwork-data'
+    # object_key = '2021/03/30/02/homenetwork-data-firehose-1-2021-03-30-02-28-48-5de99bd1-d81a-4abb-ab0f-7aa47bab1553'
     s3_path = "{}/{}".format(bucket_name, object_key)
 
-    with s3.open(s3_path, "rt", encoding='utf-8') as f:
-        d = f.read()
-    s = d.replace('}{', '}\n{')
-    to_lst = s.split('\n')
+    logger.info("start etl for file : %s", s3_path)
+
+    item_lst = get_s3_file(s3_path)
 
-    print(parse_raw_to_csv(to_lst))
+    csv, target_date = parse_raw_to_csv(item_lst)
+
+    save_path = get_save_path(target_date, object_key)
+
+    try:
+        with s3fs.open(save_path, 'w', encoding='utf-8') as f:
+            f.write(csv)
+    except Exception as e:
+        logger.error('Cannot write csv to s3 : %s', e)
+
+    logger.info("save success as file name : %s", save_path)
 
 
 def parse_event(event):
@@ -38,6 +48,18 @@ def parse_event(event):
     return region, bucket_name, object_key
 
 
+def get_s3_file(s3_path):
+    with s3fs.open(s3_path, "r", encoding='utf-8') as f:
+        d = f.read()
+    logger.info("success load from %s", s3_path)
+
+    s = d.replace('}{', '}\n{')
+    to_lst = s.split('\n')
+    logger.info("raw total count : %s", len(to_lst))
+
+    return to_lst
+
+
 def parse_raw_to_csv(to_lst):
     raw_lst = []
     for i in to_lst:
@@ -55,5 +77,16 @@ def parse_raw_to_csv(to_lst):
     columns = ['timestamp', 'wallpadip', 'dong', 'ho', 'source', 'ui', 'type', 'menu', 'function', 'value']
 
     df = pd.DataFrame(data=flat_lst, columns=columns)
+    max_date = df['timestamp'].max()
+    logger.info("csv total count : %s for max date %s", len(df), max_date)
+
+    csv = df.to_csv()
+    return csv, max_date
+
 
-    return df
+def get_save_path(target_date, object_key):
+    save_bucket_name = os.getenv("PREP_BUCKET")
+    date_part = target_date.split('T')[0].replace('-', '/')
+    key_part = "{}_{}.csv".format(target_date.replace(':', '-'), object_key.split('/')[-1])
+    path = "{}/{}/{}".format(save_bucket_name, date_part, key_part)
+    return path

+ 11 - 78
serverless.yml

@@ -1,16 +1,3 @@
-# Welcome to Serverless!
-#
-# This file is the main config file for your service.
-# It's very minimal at this point and uses default values.
-# You can always add more config options for more control.
-# We've included some commented out config examples here.
-# Just uncomment any of them to get that config option.
-#
-# For full config options, check the docs:
-#    docs.serverless.com
-#
-# Happy Coding!
-
 service: hnw-wallpad-etl
 
 plugins:
@@ -30,22 +17,19 @@ provider:
   iamRoleStatements:
     - Effect: "Allow"
       Action:
-        - "s3:*"
+        - "s3:ListBucket"
+        - "s3:GetObject"
+      Resource:
+        - "arn:aws:s3:::homenetwork-data/*"
+    - Effect: "Allow"
+      Action:
+        - "s3:PutObject"
       Resource:
-        - "arn:aws:s3:::homenetwork-data*"
-#    - Effect: "Allow"
-#      Action:
-#        - "s3:PutObject"
-#      Resource:
-#        Fn::Join:
-#          - ""
-#          - - "arn:aws:s3:::"
-#            - "Ref" : "ServerlessDeploymentBucket"
-#            - "/*"
+        - "arn:aws:s3:::hdci-wallpad-prep/*"
 
 # you can define service wide environment variables here
-#  environment:
-#    variable1: value1
+  environment:
+    PREP_BUCKET: hdci-wallpad-prep
 
 # you can add packaging information here
 package:
@@ -82,60 +66,9 @@ functions:
   prep-f:
     handler: preprocess/lambda_function.lambda_handler
     module: preprocess
-    name: hdci-wallpad-raw-to-consumpt
+    name: hdci-wallpad-raw-to-prep
     events:
       - s3:
           bucket: homenetwork-data
           event: s3:ObjectCreated:*
           existing: true
-#    The following are a few example events you can configure
-#    NOTE: Please make sure to change your handler code to work with those events
-#    Check the event documentation for details
-#    events:
-#      - httpApi:
-#          path: /users/create
-#          method: get
-#      - websocket: $connect
-#      - s3: ${env:BUCKET}
-#      - schedule: rate(10 minutes)
-#      - sns: greeter-topic
-#      - stream: arn:aws:dynamodb:region:XXXXXX:table/foo/stream/1970-01-01T00:00:00.000
-#      - alexaSkill: amzn1.ask.skill.xx-xx-xx-xx
-#      - alexaSmartHome: amzn1.ask.skill.xx-xx-xx-xx
-#      - iot:
-#          sql: "SELECT * FROM 'some_topic'"
-#      - cloudwatchEvent:
-#          event:
-#            source:
-#              - "aws.ec2"
-#            detail-type:
-#              - "EC2 Instance State-change Notification"
-#            detail:
-#              state:
-#                - pending
-#      - cloudwatchLog: '/aws/lambda/hello'
-#      - cognitoUserPool:
-#          pool: MyUserPool
-#          trigger: PreSignUp
-#      - alb:
-#          listenerArn: arn:aws:elasticloadbalancing:us-east-1:XXXXXX:listener/app/my-load-balancer/50dc6c495c0c9188/
-#          priority: 1
-#          conditions:
-#            host: example.com
-#            path: /hello
-
-#    Define function environment variables here
-#    environment:
-#      variable2: value2
-
-# you can add CloudFormation resource templates here
-#resources:
-#  Resources:
-#    NewResource:
-#      Type: AWS::S3::Bucket
-#      Properties:
-#        BucketName: my-new-bucket
-#  Outputs:
-#     NewOutput:
-#       Description: "Description for the output"
-#       Value: "Some output value"