{"id":322496,"date":"2021-05-03T03:00:11","date_gmt":"2021-05-03T03:00:11","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=322496"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=322496","title":{"rendered":"\u041f\u0438\u0448\u0435\u043c \u0442\u0435\u043b\u0435\u0433\u0440\u0430\u043c \u0431\u043e\u0442\u0430 \u043d\u0430 Go \u0438 AWS Lambda"},"content":{"rendered":"\n<div class=\"post__text post__text_v2\" id=\"post-content-body\">\n<h3>\u0427\u0442\u043e \u0431\u0443\u0434\u0435\u043c \u0434\u0435\u043b\u0430\u0442\u044c?<\/h3>\n<p>\u0411\u0443\u0434\u0435\u043c \u043f\u0438\u0441\u0430\u0442\u044c \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u0442\u0435\u043b\u0435\u0433\u0440\u0430\u043c \u0431\u043e\u0442, \u043e\u0442\u0432\u0435\u0447\u0430\u044e\u0449\u0438\u0439 \u0442\u0435\u043c \u0436\u0435 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435\u043c, \u0447\u0442\u043e \u0438 \u043e\u0442\u043f\u0440\u0430\u0432\u0438\u043b\u0438.<\/p>\n<figure class=\"float full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/98b\/812\/9bb\/98b8129bbc2a298fbc41f6d4429a6a5a.jpeg\" width=\"1080\" height=\"1207\"><figcaption><\/figcaption><\/figure>\n<h3>\u041f\u043e\u0447\u0435\u043c\u0443 AWS Lambda ?<\/h3>\n<ol>\n<li>\n<p>\u0423\u0434\u043e\u0431\u0441\u0442\u0432\u043e \u0434\u0435\u043f\u043b\u043e\u044f, \u043f\u0440\u043e\u0441\u0442\u043e \u043f\u0438\u0448\u0435\u0448\u044c <code>sls deploy<\/code>, \u0438 lambda \u0443\u0436\u0435 \u0432\u044b\u0433\u0440\u0443\u0436\u0435\u043d\u0430<\/p>\n<\/li>\n<li>\n<p>\u041f\u043b\u0430\u0442\u0438\u0448\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u0437\u0430 \u0432\u0440\u0435\u043c\u044f, \u043a\u043e\u0433\u0434\u0430 lambda \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442<\/p>\n<\/li>\n<li>\n<p>\u041d\u0435 \u043d\u0430\u0434\u043e \u043d\u0430\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0442\u044c \u043d\u0438\u043a\u0430\u043a\u0438\u0445 \u0441\u0435\u0440\u0432\u0435\u0440\u043e\u0432, \u0438 \u0431\u0435\u0441\u043f\u043e\u043a\u043e\u0438\u0442\u044c\u0441\u044f \u043e \u043c\u0430\u0441\u0448\u0442\u0430\u0431\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0438<\/p>\n<\/li>\n<\/ol>\n<h3>\u0427\u0442\u043e \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u0442\u0441\u044f?<\/h3>\n<ul>\n<li>\n<p>\u0423\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u043d\u044b\u0439 go<\/p>\n<\/li>\n<li>\n<p>Nodejs \u0438 npm \u0434\u043b\u044f \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438 serverless<\/p>\n<\/li>\n<li>\n<p>AWS \u0430\u043a\u043a\u0430\u0443\u043d\u0442 \u0434\u043b\u044f \u0434\u0435\u043f\u043b\u043e\u044f<\/p>\n<\/li>\n<\/ul>\n<h3>TLDR<\/h3>\n<ul>\n<li>\n<p>\u041a\u043b\u043e\u043d\u0438\u0440\u0443\u0435\u043c \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0439 <a href=\"https:\/\/github.com\/R11baka\/echotgbot\" rel=\"noopener noreferrer nofollow\">https:\/\/github.com\/R11baka\/echotgbot<\/a><\/p>\n<\/li>\n<li>\n<p>\u0423\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c \u0432 .env \u0444\u0430\u0439\u043b\u0435 BOT_TOKEN \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e<\/p>\n<\/li>\n<li>\n<p>\u041a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u0443\u0435\u043c \u0431\u0438\u043d\u0430\u0440\u043d\u0438\u043a <code>env GOOS=linux go build  -o bin\/webhook main.go <\/code><\/p>\n<\/li>\n<li>\n<p>\u0412\u044b\u0433\u0440\u0443\u0436\u0430\u0435\u043c \u043b\u044f\u043c\u0431\u0434\u0443 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <code>sls deploy<\/code><\/p>\n<\/li>\n<li>\n<p>\u0423\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c webhook \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e BOT_TOKEN<\/p>\n<\/li>\n<\/ul>\n<h3>\u0420\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0446\u0438\u044f \u0432 AWS<\/h3>\n<ul>\n<li>\n<p>\u0420\u0435\u0433\u0438\u0441\u0442\u0438\u0440\u0438\u0440\u0443\u0435\u043c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0432 AWS <a href=\"https:\/\/console.aws.amazon.com\/console\/home?#\" rel=\"noopener noreferrer nofollow\">aws console<\/a> \u0438 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c aws_access_key_id, \u0438 aws_secret_access_key \u0438 \u043f\u0440\u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u043c \u0438\u0445 \u0432 .aws\/credentials \u0444\u0430\u0439\u043b\u0435<\/p>\n<\/li>\n<\/ul>\n<p>\u0412\u043e\u0442 \u043a\u0430\u043a \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u043c\u043e\u0439 .aws\/credentials<\/p>\n<pre><code class=\"bash\">cat ~\/.aws\/credentials [default] aws_access_key_id = ADEFEFEFFEBDXK3 aws_secret_access_key = Zy6ewfir\/zGaT1B2\/o9JDWDSssdrla region = us-west-1<\/code><\/pre>\n<h3>\u0420\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0446\u0438\u044f \u0431\u043e\u0442\u0430<\/h3>\n<p>\u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430, \u043d\u0430\u043c \u043d\u0430\u0434\u043e \u0437\u0430\u0440\u0435\u0433\u0438\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0431\u043e\u0442\u0430 \u0432 <a href=\"https:\/\/telegram.me\/botfather\" rel=\"noopener noreferrer nofollow\">BotFather<\/a>. \u0418\u0434\u0435\u043c \u043f\u043e <a href=\"https:\/\/telegram.me\/botfather\" rel=\"noopener noreferrer nofollow\">\u0441\u0441\u044b\u043b\u043a\u0435<\/a>, \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u043c \u043a\u043e\u043c\u0430\u043d\u0434\u0443 BotFather <code>\/newbot<\/code>, \u043f\u0440\u0438\u0434\u0443\u043c\u044b\u0432\u0430\u0435\u043c \u0438\u043c\u044f \u0431\u043e\u0442\u0443, \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435. \u0412 \u043a\u043e\u043d\u0446\u0435, BotFather \u0432\u0435\u0440\u043d\u0435\u0442 \u043d\u0430\u043c \u0442\u043e\u043a\u0435\u043d \u0431\u043e\u0442\u0430.\u042d\u0442\u043e\u0442 \u0442\u043e\u043a\u0435\u043d \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u0442\u0441\u044f,\u043d\u0430\u043c \u0434\u043b\u044f \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0435\u0439 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438.<\/p>\n<h3>\u0423\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0430 Serverless<\/h3>\n<p>Serverless-\u044d\u0442\u043e framework, \u043e\u0431\u043b\u0435\u0433\u0447\u0430\u044e\u0449\u0438\u0439 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0443, \u0434\u0435\u043f\u043b\u043e\u0439 AWS Lambda \u0444\u0443\u043d\u043a\u0446\u0438\u0439. \u041d\u0430\u043f\u0438\u0441\u0430\u043d \u043d\u0430 node, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0434\u043b\u044f \u0435\u0433\u043e \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438 \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u0442\u0441\u044f nodejs \u0438 npm. <a href=\"https:\/\/www.serverless.com\/framework\/docs\/getting-started\/\" rel=\"noopener noreferrer nofollow\">\u0423\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c serverless<\/a> \u0447\u0435\u0440\u0435\u0437 npm<\/p>\n<p><code>npm install -g serverless <\/code><\/p>\n<p>\u041f\u043e\u0441\u043b\u0435 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438 serverless \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c, \u0432\u0441\u0435 \u043b\u0438 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u043b\u043e\u0441\u044c<\/p>\n<pre><code class=\"bash\">sls -v Framework Core: 2.35.0 (standalone) Plugin: 4.5.3 SDK: 4.2.2 Components: 3.8.2<\/code><\/pre>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u0438\u0441\u0442\u0443\u043f\u0438\u0442\u044c \u043a \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438 serverless. \u0412\u0441\u0435 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 \u0434\u043b\u044f serverless \u043b\u0435\u0436\u0430\u0442 \u0432 serverless.yml \u0444\u0430\u0439\u043b\u0435,\u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u044b \u0438 \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0441\u043e  \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043a\u043e\u043d\u0442\u0435\u043d\u0442\u043e\u043c<\/p>\n<pre><code>service: echoBot useDotenv: true configValidationMode: error # \u0435\u0441\u043b\u0438 \u0432 \u043a\u043e\u043d\u0444\u0438\u0433\u0435,\u0447\u0442\u043e\u0442\u043e \u043d\u0435\u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e ,\u0442\u043e \u043e\u0448\u0438\u0431\u043a\u0430 frameworkVersion: '&gt;=1.28.0 &lt;2.50.0'  provider:   region: \"us-west-1\"   lambdaHashingVersion: \"20201221\"   name: aws   runtime: go1.x   logRetentionInDays: 30 # \u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0434\u043d\u0435\u0439 \u0445\u0440\u0430\u043d\u0438\u0442\u044c \u043b\u043e\u0433\u0438   endpointType: regional   tracing: # \u0432\u043a\u043b\u044e\u0447\u0430\u0435\u043c \u0442\u0440\u0435\u0439\u0441\u0438\u043d\u0433 \u0434\u043b\u044f \u043b\u044f\u043c\u0431\u0434\u044b     apiGateway: true     lambda: true   iam:     role:       statements:         - Effect: \"Allow\"           Resource: \"*\"           Action:             - \"xray:*\" package:   patterns:     - \"bin\/webhook\" # \u0434\u0435\u043f\u043b\u043e\u0438\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u0431\u0438\u043d\u0430\u0440\u043d\u0438\u043a  functions:   webhook:      handler: bin\/webhook     timeout: 15     description: simple echo bot     memorySize: 128 # \u0440\u0430\u0437\u043c\u0435\u0440 \u043f\u0430\u043c\u044f\u0442\u0438 \u0432 \u043c\u0435\u0433\u0430\u0431\u0430\u0439\u0442\u0430\u0445 \u0434\u043b\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u0438     environment:       BOT_TOKEN: ${env:BOT_TOKEN}     events:       - http:           path: \/webhook           method: ANY           cors: false<\/code><\/pre>\n<h3>\u0418\u043c\u043b\u0435\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044f \u043b\u043e\u0433\u0438\u043a\u0438 \u0431\u043e\u0442\u0430 \u043d\u0430 Go<\/h3>\n<ol>\n<li>\n<p> \u0423\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 telebot.v2 \u0438 aws-lambda-go<\/p>\n<pre><code class=\"bash\">\u279c  go mod init testBot go: creating new go.mod: module testBot \u279c  go get -u gopkg.in\/tucnak\/telebot.v2 go: gopkg.in\/tucnak\/telebot.v2 upgrade =&gt; v2.3.5 go: github.com\/pkg\/errors upgrade =&gt; v0.9.1 \u279c go get github.com\/aws\/aws-lambda-go go: github.com\/aws\/aws-lambda-go upgrade =&gt; v1.23.0<\/code><\/pre>\n<\/li>\n<\/ol>\n<p>2.   \u0421\u043e\u0437\u0434\u0430\u0435\u043c \u0444\u0430\u0439\u043b main.go \u0441 \u043a\u043e\u043d\u0442\u0435\u043d\u0442\u043e\u043c<\/p>\n<pre><code>package main  import ( \t\"encoding\/json\" \t\"fmt\" \t\"github.com\/aws\/aws-lambda-go\/events\" \t\"github.com\/aws\/aws-lambda-go\/lambda\" \ttb \"gopkg.in\/tucnak\/telebot.v2\" \t\"os\" )  func main() { \tsettings := tb.Settings{ \t\tToken:       os.Getenv(\"BOT_TOKEN\"), \t\tSynchronous: true, \t\tVerbose:     true, \t} \ttgBot, err := tb.NewBot(settings) \tif err != nil { \t\tfmt.Println(err) \t\tpanic(\"can't create bot\") \t} \ttgBot.Handle(tb.OnText, func(m *tb.Message) { \t\tmessage := m.Text \t\ttgBot.Send(m.Sender, message) \t}) \tlambda.Start(func(req events.APIGatewayProxyRequest) (events.APIGatewayProxyResponse, error) { \t\tvar u tb.Update \t\tif err = json.Unmarshal([]byte(req.Body), &amp;u); err == nil { \t\t\ttgBot.ProcessUpdate(u) \t\t} \t\treturn events.APIGatewayProxyResponse{Body: \"ok\", StatusCode: 200}, nil  \t}) }<\/code><\/pre>\n<p>\u0422\u0435\u043a\u0443\u0449\u0430\u044f \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044f \u0432 tucnak\/telebot.v2 \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u0443\u0441\u0442\u0430\u0440\u0435\u043b\u0430, \u0438 \u0435\u0441\u043b\u0438 \u043f\u0440\u043e\u0441\u0442\u043e \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c return \u0432\u043c\u0435\u0441\u0442\u043e <code>return events.APIGatewayProxyResponse{Body: \"ok\", StatusCode: 200}, nil<\/code>, \u0442\u043e \u0442\u0435\u043b\u0435\u0433\u0440\u0430\u043c \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u0432\u0442\u043e\u0440\u043d\u043e \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f \u043a \u0431\u043e\u0442\u0443.<\/p>\n<h3>Deploy \u0431\u043e\u0442\u0430<\/h3>\n<ul>\n<li>\n<p>\u0421\u043e\u0437\u0434\u0430\u0435\u043c \u0444\u0430\u0439\u043b .env \u0438 \u0432\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u043c API_TOKEN \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u0439 \u043e\u0442 BotFather<\/p>\n<pre><code>echo API_TOKEN={API_TOKEN_FROM_BOTFATHER} &gt; .env<\/code><\/pre>\n<\/li>\n<li>\n<p>\u041f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c serverlss \u043a\u043e\u043d\u0444\u0438\u0433 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043a\u043e\u043c\u0430\u043d\u0434\u044b. \u041d\u0435 \u0434\u043e\u043b\u0436\u043d\u043e \u0431\u044b\u0442\u044c \u043d\u0438\u043a\u0430\u043a\u0438\u0445 \u043e\u0448\u0438\u0431\u043e\u043a.<\/p>\n<pre><code>sls print<\/code><\/pre>\n<\/li>\n<li>\n<p>\u041f\u043e\u0442\u043e\u043c \u0441\u043e\u0431\u0438\u0440\u0430\u0435\u043c \u0431\u0438\u043d\u0430\u0440\u043d\u0438\u043a<\/p>\n<pre><code>env GOOS=linux go build  -o bin\/webhook main.go <\/code><\/pre>\n<\/li>\n<li>\n<p>\u0418 \u0432\u044b\u0433\u0440\u0443\u0436\u0430\u0435\u043c \u0435\u0433\u043e \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e serverless<\/p>\n<pre><code>serverless deploy  -v<\/code><\/pre>\n<p> \u041f\u0440\u0438 \u0443\u0441\u043f\u0435\u0448\u043d\u043e\u0439 \u0432\u044b\u0433\u0440\u0443\u0437\u043a\u0435, \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u043c \u0432 \u043a\u043e\u043d\u0446\u0435<\/p>\n<pre><code>Service Information service: echoBot stage: dev region: us-west-1 stack: echoBot-dev resources: 11 api keys: None endpoints: ANY - https:\/\/y7p31bwnu1.execute-api.us-west-1.amazonaws.com\/dev\/webhook functions: webhook: echoBot-dev-webhook layers: None<\/code><\/pre>\n<p><a href=\"https:\/\/y7p31bwnu1.execute-api.us-west-1.amazonaws.com\/dev\/webhook\" rel=\"noopener noreferrer nofollow\">https:\/\/y7p31bwnu1.execute-api.us-west-1.amazonaws.com\/dev\/webhook<\/a> =&gt; \u044d\u0442\u043e\u0442 \u044d\u043d\u0434\u043f\u043e\u0438\u043d\u0442 \u0438 token \u0431\u043e\u0442\u0430 \u043d\u0443\u0436\u0435\u043d \u043d\u0430\u043c, \u0447\u0442\u043e\u0431\u044b \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c webhook<\/p>\n<\/li>\n<\/ul>\n<h3>\u0418\u043d\u0442\u0435\u0433\u0440\u0430\u0446\u0438\u044f \u0441 telegram<\/h3>\n<p>\u041e\u0441\u0442\u0430\u043b\u043e\u0441\u044c \u0441\u043e\u043e\u0431\u0449\u0438\u0442\u044c \u0442\u0435\u043b\u0435\u0433\u0440\u0430\u043c\u0443, \u043a\u0430\u043a\u043e\u0439 \u044d\u043d\u0434\u043f\u043e\u0438\u043d\u0442 \u0434\u0435\u0440\u0433\u0430\u0442\u044c \u043f\u0440\u0438 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0438 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f. \u0414\u0435\u043b\u0430\u0435\u0442\u0441\u044f \u044d\u0442\u043e \u043a\u043e\u043c\u0430\u043d\u0434\u043e\u0439 setWebhook<\/p>\n<pre><code>curl https:\/\/api.telegram.org\/bot{YOUR_TOKEN}\/setWebhook?url={YOUR_DEPLOYED_AWS_URL} <\/code><\/pre>\n<p>\u041f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u0447\u0442\u043e webhook \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d, \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e getWebhookInfo<\/p>\n<pre><code>\u279c  ~ curl https:\/\/api.telegram.org\/bot1324913549:AAE1zYMH6K3hF2TOgUQoIP-E1g4rMIamck\/setWebhook\\?url\\= https:\/\/y7p31bwnu1.execute-api.us-west-1.amazonaws.com\/dev\/webhook {\"ok\":true,\"result\":true,\"description\":\"Webhook was set\"} \u279c  ~ curl https:\/\/api.telegram.org\/bot1324913549:AAE1zYMH6K3hF2TOgUQoIP-E1g4rMIamck\/getWebhookInfo {\"ok\":true,\"result\":{\"url\":\"https:\/\/y7p31bwnu1.execute-api.us-west-1.amazonaws.com\/dev\/webhook\",\"has_custom_certificate\":false,\"pending_update_count\":0,\"max_connections\":40,\"ip_address\":\"184.169.148.254\"}} <\/code><\/pre>\n<h3>\u041e\u0448\u0438\u0431\u043a\u0438<\/h3>\n<p>\u0415\u0441\u043b\u0438 \u0447\u0442\u043e-\u0442\u043e \u043f\u043e\u0448\u043b\u043e \u043d\u0435 \u0442\u0430\u043a,\u0438\u0434\u0435\u043c \u0432 <a href=\"https:\/\/us-west-1.console.aws.amazon.com\/\" rel=\"noopener noreferrer nofollow\">CloudWatch<\/a> \u0438 \u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043b\u043e\u0433\u0438,\u0438\u043b\u0438 \u0436\u0435 \u0438\u0437 \u043a\u043e\u043d\u0441\u043e\u043b\u0438 \u0442\u0430\u043a\u0436\u0435 \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u043b\u043e\u0433\u0438<\/p>\n<pre><code>sls logs -f webhook<\/code><\/pre>\n<\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/post\/555518\/\"> https:\/\/habr.com\/ru\/post\/555518\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"\n<div class=\"post__text post__text_v2\" id=\"post-content-body\">\n<h3>\u0427\u0442\u043e \u0431\u0443\u0434\u0435\u043c \u0434\u0435\u043b\u0430\u0442\u044c?<\/h3>\n<p>\u0411\u0443\u0434\u0435\u043c \u043f\u0438\u0441\u0430\u0442\u044c \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u0442\u0435\u043b\u0435\u0433\u0440\u0430\u043c \u0431\u043e\u0442, \u043e\u0442\u0432\u0435\u0447\u0430\u044e\u0449\u0438\u0439 \u0442\u0435\u043c \u0436\u0435 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435\u043c, \u0447\u0442\u043e \u0438 \u043e\u0442\u043f\u0440\u0430\u0432\u0438\u043b\u0438.<\/p>\n<figure class=\"float full-width\"><figcaption><\/figcaption><\/figure>\n<h3>\u041f\u043e\u0447\u0435\u043c\u0443 AWS Lambda ?<\/h3>\n<ol>\n<li>\n<p>\u0423\u0434\u043e\u0431\u0441\u0442\u0432\u043e \u0434\u0435\u043f\u043b\u043e\u044f, \u043f\u0440\u043e\u0441\u0442\u043e \u043f\u0438\u0448\u0435\u0448\u044c <code>sls deploy<\/code>, \u0438 lambda \u0443\u0436\u0435 \u0432\u044b\u0433\u0440\u0443\u0436\u0435\u043d\u0430<\/p>\n<\/li>\n<li>\n<p>\u041f\u043b\u0430\u0442\u0438\u0448\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u0437\u0430 \u0432\u0440\u0435\u043c\u044f, \u043a\u043e\u0433\u0434\u0430 lambda \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442<\/p>\n<\/li>\n<li>\n<p>\u041d\u0435 \u043d\u0430\u0434\u043e \u043d\u0430\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0442\u044c \u043d\u0438\u043a\u0430\u043a\u0438\u0445 \u0441\u0435\u0440\u0432\u0435\u0440\u043e\u0432, \u0438 \u0431\u0435\u0441\u043f\u043e\u043a\u043e\u0438\u0442\u044c\u0441\u044f \u043e \u043c\u0430\u0441\u0448\u0442\u0430\u0431\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0438<\/p>\n<\/li>\n<\/ol>\n<h3>\u0427\u0442\u043e \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u0442\u0441\u044f?<\/h3>\n<ul>\n<li>\n<p>\u0423\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u043d\u044b\u0439 go<\/p>\n<\/li>\n<li>\n<p>Nodejs \u0438 npm \u0434\u043b\u044f \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438 serverless<\/p>\n<\/li>\n<li>\n<p>AWS \u0430\u043a\u043a\u0430\u0443\u043d\u0442 \u0434\u043b\u044f \u0434\u0435\u043f\u043b\u043e\u044f<\/p>\n<\/li>\n<\/ul>\n<h3>TLDR<\/h3>\n<ul>\n<li>\n<p>\u041a\u043b\u043e\u043d\u0438\u0440\u0443\u0435\u043c \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0439 <a href=\"https:\/\/github.com\/R11baka\/echotgbot\" rel=\"noopener noreferrer nofollow\">https:\/\/github.com\/R11baka\/echotgbot<\/a><\/p>\n<\/li>\n<li>\n<p>\u0423\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c \u0432 .env \u0444\u0430\u0439\u043b\u0435 BOT_TOKEN \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e<\/p>\n<\/li>\n<li>\n<p>\u041a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u0443\u0435\u043c \u0431\u0438\u043d\u0430\u0440\u043d\u0438\u043a <code>env GOOS=linux go build  -o bin\/webhook main.go <\/code><\/p>\n<\/li>\n<li>\n<p>\u0412\u044b\u0433\u0440\u0443\u0436\u0430\u0435\u043c \u043b\u044f\u043c\u0431\u0434\u0443 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <code>sls deploy<\/code><\/p>\n<\/li>\n<li>\n<p>\u0423\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c webhook \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e BOT_TOKEN<\/p>\n<\/li>\n<\/ul>\n<h3>\u0420\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0446\u0438\u044f \u0432 AWS<\/h3>\n<ul>\n<li>\n<p>\u0420\u0435\u0433\u0438\u0441\u0442\u0438\u0440\u0438\u0440\u0443\u0435\u043c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0432 AWS <a href=\"https:\/\/console.aws.amazon.com\/console\/home?#\" rel=\"noopener noreferrer nofollow\">aws console<\/a> \u0438 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c aws_access_key_id, \u0438 aws_secret_access_key \u0438 \u043f\u0440\u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u043c \u0438\u0445 \u0432 .aws\/credentials \u0444\u0430\u0439\u043b\u0435<\/p>\n<\/li>\n<\/ul>\n<p>\u0412\u043e\u0442 \u043a\u0430\u043a \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u043c\u043e\u0439 .aws\/credentials<\/p>\n<pre><code class=\"bash\">cat ~\/.aws\/credentials [default] aws_access_key_id = ADEFEFEFFEBDXK3 aws_secret_access_key = Zy6ewfir\/zGaT1B2\/o9JDWDSssdrla region = us-west-1<\/code><\/pre>\n<h3>\u0420\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0446\u0438\u044f \u0431\u043e\u0442\u0430<\/h3>\n<p>\u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430, \u043d\u0430\u043c \u043d\u0430\u0434\u043e \u0437\u0430\u0440\u0435\u0433\u0438\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0431\u043e\u0442\u0430 \u0432 <a href=\"https:\/\/telegram.me\/botfather\" rel=\"noopener noreferrer nofollow\">BotFather<\/a>. \u0418\u0434\u0435\u043c \u043f\u043e <a href=\"https:\/\/telegram.me\/botfather\" rel=\"noopener noreferrer nofollow\">\u0441\u0441\u044b\u043b\u043a\u0435<\/a>, \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u043c \u043a\u043e\u043c\u0430\u043d\u0434\u0443 BotFather <code>\/newbot<\/code>, \u043f\u0440\u0438\u0434\u0443\u043c\u044b\u0432\u0430\u0435\u043c \u0438\u043c\u044f \u0431\u043e\u0442\u0443, \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435. \u0412 \u043a\u043e\u043d\u0446\u0435, BotFather \u0432\u0435\u0440\u043d\u0435\u0442 \u043d\u0430\u043c \u0442\u043e\u043a\u0435\u043d \u0431\u043e\u0442\u0430.\u042d\u0442\u043e\u0442 \u0442\u043e\u043a\u0435\u043d \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u0442\u0441\u044f,\u043d\u0430\u043c \u0434\u043b\u044f \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0435\u0439 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438.<\/p>\n<h3>\u0423\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0430 Serverless<\/h3>\n<p>Serverless-\u044d\u0442\u043e framework, \u043e\u0431\u043b\u0435\u0433\u0447\u0430\u044e\u0449\u0438\u0439 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0443, \u0434\u0435\u043f\u043b\u043e\u0439 AWS Lambda \u0444\u0443\u043d\u043a\u0446\u0438\u0439. \u041d\u0430\u043f\u0438\u0441\u0430\u043d \u043d\u0430 node, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0434\u043b\u044f \u0435\u0433\u043e \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438 \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u0442\u0441\u044f nodejs \u0438 npm. <a href=\"https:\/\/www.serverless.com\/framework\/docs\/getting-started\/\" rel=\"noopener noreferrer nofollow\">\u0423\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c serverless<\/a> \u0447\u0435\u0440\u0435\u0437 npm<\/p>\n<p><code>npm install -g serverless <\/code><\/p>\n<p>\u041f\u043e\u0441\u043b\u0435 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438 serverless \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c, \u0432\u0441\u0435 \u043b\u0438 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u043b\u043e\u0441\u044c<\/p>\n<pre><code class=\"bash\">sls -v Framework Core: 2.35.0 (standalone) Plugin: 4.5.3 SDK: 4.2.2 Components: 3.8.2<\/code><\/pre>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u0438\u0441\u0442\u0443\u043f\u0438\u0442\u044c \u043a \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438 serverless. \u0412\u0441\u0435 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 \u0434\u043b\u044f serverless \u043b\u0435\u0436\u0430\u0442 \u0432 serverless.yml \u0444\u0430\u0439\u043b\u0435,\u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u044b \u0438 \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0441\u043e  \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043a\u043e\u043d\u0442\u0435\u043d\u0442\u043e\u043c<\/p>\n<pre><code>service: echoBot useDotenv: true configValidationMode: error # \u0435\u0441\u043b\u0438 \u0432 \u043a\u043e\u043d\u0444\u0438\u0433\u0435,\u0447\u0442\u043e\u0442\u043e \u043d\u0435\u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e ,\u0442\u043e \u043e\u0448\u0438\u0431\u043a\u0430 frameworkVersion: '&gt;=1.28.0 &lt;2.50.0'  provider:   region: \"us-west-1\"   lambdaHashingVersion: \"20201221\"   name: aws   runtime: go1.x   logRetentionInDays: 30 # \u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0434\u043d\u0435\u0439 \u0445\u0440\u0430\u043d\u0438\u0442\u044c \u043b\u043e\u0433\u0438   endpointType: regional   tracing: # \u0432\u043a\u043b\u044e\u0447\u0430\u0435\u043c \u0442\u0440\u0435\u0439\u0441\u0438\u043d\u0433 \u0434\u043b\u044f \u043b\u044f\u043c\u0431\u0434\u044b     apiGateway: true     lambda: true   iam:     role:       statements:         - Effect: \"Allow\"           Resource: \"*\"           Action:             - \"xray:*\" package:   patterns:     - \"bin\/webhook\" # \u0434\u0435\u043f\u043b\u043e\u0438\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u0431\u0438\u043d\u0430\u0440\u043d\u0438\u043a  functions:   webhook:      handler: bin\/webhook     timeout: 15     description: simple echo bot     memorySize: 128 # \u0440\u0430\u0437\u043c\u0435\u0440 \u043f\u0430\u043c\u044f\u0442\u0438 \u0432 \u043c\u0435\u0433\u0430\u0431\u0430\u0439\u0442\u0430\u0445 \u0434\u043b\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u0438     environment:       BOT_TOKEN: ${env:BOT_TOKEN}     events:       - http:           path: \/webhook           method: ANY           cors: false<\/code><\/pre>\n<h3>\u0418\u043c\u043b\u0435\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044f \u043b\u043e\u0433\u0438\u043a\u0438 \u0431\u043e\u0442\u0430 \u043d\u0430 Go<\/h3>\n<ol>\n<li>\n<p> \u0423\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 telebot.v2 \u0438 aws-lambda-go<\/p>\n<pre><code class=\"bash\">\u279c  go mod init testBot go: creating new go.mod: module testBot \u279c  go get -u gopkg.in\/tucnak\/telebot.v2 go: gopkg.in\/tucnak\/telebot.v2 upgrade =&gt; v2.3.5 go: github.com\/pkg\/errors upgrade =&gt; v0.9.1 \u279c go get github.com\/aws\/aws-lambda-go go: github.com\/aws\/aws-lambda-go upgrade =&gt; v1.23.0<\/code><\/pre>\n<\/li>\n<\/ol>\n<p>2.   \u0421\u043e\u0437\u0434\u0430\u0435\u043c \u0444\u0430\u0439\u043b main.go \u0441 \u043a\u043e\u043d\u0442\u0435\u043d\u0442\u043e\u043c<\/p>\n<pre><code>package main  import ( \t\"encoding\/json\" \t\"fmt\" \t\"github.com\/aws\/aws-lambda-go\/events\" \t\"github.com\/aws\/aws-lambda-go\/lambda\" \ttb \"gopkg.in\/tucnak\/telebot.v2\" \t\"os\" )  func main() { \tsettings := tb.Settings{ \t\tToken:       os.Getenv(\"BOT_TOKEN\"), \t\tSynchronous: true, \t\tVerbose:     true, \t} \ttgBot, err := tb.NewBot(settings) \tif err != nil { \t\tfmt.Println(err) \t\tpanic(\"can't create bot\") \t} \ttgBot.Handle(tb.OnText, func(m *tb.Message) { \t\tmessage := m.Text \t\ttgBot.Send(m.Sender, message) \t}) \tlambda.Start(func(req events.APIGatewayProxyRequest) (events.APIGatewayProxyResponse, error) { \t\tvar u tb.Update \t\tif err = json.Unmarshal([]byte(req.Body), &amp;u); err == nil { \t\t\ttgBot.ProcessUpdate(u) \t\t} \t\treturn events.APIGatewayProxyResponse{Body: \"ok\", StatusCode: 200}, nil  \t}) }<\/code><\/pre>\n<p>\u0422\u0435\u043a\u0443\u0449\u0430\u044f \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044f \u0432 tucnak\/telebot.v2 \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u0443\u0441\u0442\u0430\u0440\u0435\u043b\u0430, \u0438 \u0435\u0441\u043b\u0438 \u043f\u0440\u043e\u0441\u0442\u043e \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c return \u0432\u043c\u0435\u0441\u0442\u043e <code>return events.APIGatewayProxyResponse{Body: \"ok\", StatusCode: 200}, nil<\/code>, \u0442\u043e \u0442\u0435\u043b\u0435\u0433\u0440\u0430\u043c \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u0432\u0442\u043e\u0440\u043d\u043e \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f \u043a \u0431\u043e\u0442\u0443.<\/p>\n<h3>Deploy \u0431\u043e\u0442\u0430<\/h3>\n<ul>\n<li>\n<p>\u0421\u043e\u0437\u0434\u0430\u0435\u043c \u0444\u0430\u0439\u043b .env \u0438 \u0432\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u043c API_TOKEN \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u0439 \u043e\u0442 BotFather<\/p>\n<pre><code>echo API_TOKEN={API_TOKEN_FROM_BOTFATHER} &gt; .env<\/code><\/pre>\n<\/li>\n<li>\n<p>\u041f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c serverlss \u043a\u043e\u043d\u0444\u0438\u0433 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043a\u043e\u043c\u0430\u043d\u0434\u044b. \u041d\u0435 \u0434\u043e\u043b\u0436\u043d\u043e \u0431\u044b\u0442\u044c \u043d\u0438\u043a\u0430\u043a\u0438\u0445 \u043e\u0448\u0438\u0431\u043e\u043a.<\/p>\n<pre><code>sls print<\/code><\/pre>\n<\/li>\n<li>\n<p>\u041f\u043e\u0442\u043e\u043c \u0441\u043e\u0431\u0438\u0440\u0430\u0435\u043c \u0431\u0438\u043d\u0430\u0440\u043d\u0438\u043a<\/p>\n<pre><code>env GOOS=linux go build  -o bin\/webhook main.go <\/code><\/pre>\n<\/li>\n<li>\n<p>\u0418 \u0432\u044b\u0433\u0440\u0443\u0436\u0430\u0435\u043c \u0435\u0433\u043e \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e serverless<\/p>\n<pre><code>serverless deploy  -v<\/code><\/pre>\n<p> \u041f\u0440\u0438 \u0443\u0441\u043f\u0435\u0448\u043d\u043e\u0439 \u0432\u044b\u0433\u0440\u0443\u0437\u043a\u0435, \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u043c \u0432 \u043a\u043e\u043d\u0446\u0435<\/p>\n<pre><code>Service Information service: echoBot stage: dev region: us-west-1 stack: echoBot-dev resources: 11 api keys: None endpoints: ANY - https:\/\/y7p31bwnu1.execute-api.us-west-1.amazonaws.com\/dev\/webhook functions: webhook: echoBot-dev-webhook layers: None<\/code><\/pre>\n<p><a href=\"https:\/\/y7p31bwnu1.execute-api.us-west-1.amazonaws.com\/dev\/webhook\" rel=\"noopener noreferrer nofollow\">https:\/\/y7p31bwnu1.execute-api.us-west-1.amazonaws.com\/dev\/webhook<\/a> =&gt; \u044d\u0442\u043e\u0442 \u044d\u043d\u0434\u043f\u043e\u0438\u043d\u0442 \u0438 token \u0431\u043e\u0442\u0430 \u043d\u0443\u0436\u0435\u043d \u043d\u0430\u043c, \u0447\u0442\u043e\u0431\u044b \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c webhook<\/p>\n<\/li>\n<\/ul>\n<h3>\u0418\u043d\u0442\u0435\u0433\u0440\u0430\u0446\u0438\u044f \u0441 telegram<\/h3>\n<p>\u041e\u0441\u0442\u0430\u043b\u043e\u0441\u044c \u0441\u043e\u043e\u0431\u0449\u0438\u0442\u044c \u0442\u0435\u043b\u0435\u0433\u0440\u0430\u043c\u0443, \u043a\u0430\u043a\u043e\u0439 \u044d\u043d\u0434\u043f\u043e\u0438\u043d\u0442 \u0434\u0435\u0440\u0433\u0430\u0442\u044c \u043f\u0440\u0438 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0438 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f. \u0414\u0435\u043b\u0430\u0435\u0442\u0441\u044f \u044d\u0442\u043e \u043a\u043e\u043c\u0430\u043d\u0434\u043e\u0439 setWebhook<\/p>\n<pre><code>curl https:\/\/api.telegram.org\/bot{YOUR_TOKEN}\/setWebhook?url={YOUR_DEPLOYED_AWS_URL} <\/code><\/pre>\n<p>\u041f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u0447\u0442\u043e webhook \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d, \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e getWebhookInfo<\/p>\n<pre><code>\u279c  ~ curl https:\/\/api.telegram.org\/bot1324913549:AAE1zYMH6K3hF2TOgUQoIP-E1g4rMIamck\/setWebhook\\?url\\= https:\/\/y7p31bwnu1.execute-api.us-west-1.amazonaws.com\/dev\/webhook {\"ok\":true,\"result\":true,\"description\":\"Webhook was set\"} \u279c  ~ curl https:\/\/api.telegram.org\/bot1324913549:AAE1zYMH6K3hF2TOgUQoIP-E1g4rMIamck\/getWebhookInfo {\"ok\":true,\"result\":{\"url\":\"https:\/\/y7p31bwnu1.execute-api.us-west-1.amazonaws.com\/dev\/webhook\",\"has_custom_certificate\":false,\"pending_update_count\":0,\"max_connections\":40,\"ip_address\":\"184.169.148.254\"}} <\/code><\/pre>\n<h3>\u041e\u0448\u0438\u0431\u043a\u0438<\/h3>\n<p>\u0415\u0441\u043b\u0438 \u0447\u0442\u043e-\u0442\u043e \u043f\u043e\u0448\u043b\u043e \u043d\u0435 \u0442\u0430\u043a,\u0438\u0434\u0435\u043c \u0432 <a href=\"https:\/\/us-west-1.console.aws.amazon.com\/\" rel=\"noopener noreferrer nofollow\">CloudWatch<\/a> \u0438 \u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043b\u043e\u0433\u0438,\u0438\u043b\u0438 \u0436\u0435 \u0438\u0437 \u043a\u043e\u043d\u0441\u043e\u043b\u0438 \u0442\u0430\u043a\u0436\u0435 \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u043b\u043e\u0433\u0438<\/p>\n<pre><code>sls logs -f webhook<\/code><\/pre>\n<\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/post\/555518\/\"> https:\/\/habr.com\/ru\/post\/555518\/<\/a><br \/><\/br><\/br><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-322496","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/322496","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=322496"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/322496\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=322496"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=322496"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=322496"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}