// Register new handler with match on command `/start` bh.HandleMessage(func(bot *telego.Bot, message telego.Message) { // Send message with inline keyboard var introduce = "Welcome ~"
serverless Serverless: No project detected. Do you want to create a new one? Yes Serverless: What do you want to make? AWS Node.js Serverless: What do you want to call this project? sample Project successfully created in 'sample' folder. (node:30044) Warning: a promise was created in a handler at domain.js:121:23 but was not returned from it, see http://goo at Object.ret [as lstatAsync] (eval at makeNodePromisifiedEval (C:\Users\DEV\AppData\Roaming\npm\node_modules\serverless\node_modules\bluebird\js\release\promisify.js:184:12), <anonymous>:8:21) You can monitor, troubleshoot, and test your new service with a free Serverless account. Serverless: Would you like to enable this? Yes Serverless: What application do you want to add this to? (Use arrow keys) Serverless: What application do you want to add this to? myapp Your project is setup for monitoring, troubleshooting and testing Deploy your project and monitor, troubleshoot and test it: - Run “serverless deploy” to deploy your service. - Run “serverless dashboard” to view the dashboard.
3. 샘플소스 handler.js
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
'use strict'; module.exports.hello = async event => { return { statusCode: 200, body: JSON.stringify( { message: 'Go Serverless v1.0! Your function executed successfully!', input: event, }, null, 2 ), }; // Use this code if you don't use the http event with the LAMBDA-PROXY integration // return { message: 'Go Serverless v1.0! Your function executed successfully!', event }; };
serverless remove Serverless: Getting all objects in S3 bucket... Serverless: Removing objects in S3 bucket... Serverless: Removing Stack... Serverless: Checking Stack removal progress... ......................... Serverless: Stack removal finished... Serverless: Publishing service to the Serverless Dashboard... Serverless: Successfully published your service to the Serverless Dashboard: https://dashboard.serverless.com/tenants/skarlsla/applications/myapp/services/sample/stage/dev/region/us-east-1
AWSTemplateFormatVersion: '2010-09-09' #SAM 템플릿 Transform: 'AWS::Serverless-2016-10-31' Description: A simple backend with a RESTful API endpoint using Amazon API Gateway. Resources: hello: Type: 'AWS::Serverless::Function' Properties: Handler: handler.hello #실행 함수 Runtime: nodejs8.10 #node.js 로 실행 CodeUri: . #파일 path Description: A simple backend with a RESTful API endpoint using Amazon API Gateway. MemorySize: 512 #function 할당 메모리 Timeout: 10 #호출 타임아웃 Events: Api1: Type: Api #api gateway Properties: Path: /hello #API호출경로 Method: ANY #모든메소드
aws cloudformation package --template-file .\template.yml --s3-bucket sam-test-bucket3 --output-template.yaml Uploading to 7e7043603cb391e49a966292b19ddcf0 42386 / 42386.0 (100.00%) Successfully packaged artifacts and wrote output template to file packaged-template.yaml. Execute the following command to deploy the packaged template
const slackMessage = { channel: slackChannel, text: `${alarmName} state is now ${newState}: ${reason}` };
postMessage(slackMessage, (response) => { if (response.statusCode < 400) { console.info('Message posted successfully'); callback(null); } else if (response.statusCode < 500) { console.error(`Error posting message to Slack API: ${response.statusCode} - ${response.statusMessage}`); callback(null); // Don't retry because the error is due to a problem with the request } else { // Let Lambda retry callback(`Server error when processing message: ${response.statusCode} - ${response.statusMessage}`); } }); }
4. 앱 환경변수
웹훅 url을 KMS로 암호화해서 넣어야한다. 알람을 받을 채널명을 입력한다.
5. KMS로 암호화 aws kms로 이동 후 kms 생성
작업PC에 aws-cli를 설치하고 sdk config를 설정한후 (key, secret, region )