投稿時間:2022-10-23 21:15:22 RSSフィード2022-10-23 21:00 分まとめ(19件)

カテゴリー等 サイト名等 記事タイトル・トレンドワード等 リンクURL 頻出ワード・要約等/検索ボリューム 登録日
python Pythonタグが付けられた新着投稿 - Qiita エスペラント語を漢字変換するpythonコードを書いてみた https://qiita.com/kuu_kai/items/5747f10bf6efbf6c7af6 漢字 2022-10-23 20:24:03
python Pythonタグが付けられた新着投稿 - Qiita pythonでテキストデータをローカル保存する方法 約40選 https://qiita.com/payaneco/items/74d554c6660662d492fe 設定 2022-10-23 20:15:24
python Pythonタグが付けられた新着投稿 - Qiita サーバ上のpythonとブラウザ上のjavascriptとデータ通信を行う https://qiita.com/shibaura/items/48bca63ac992c2f93b9d javascript 2022-10-23 20:06:59
js JavaScriptタグが付けられた新着投稿 - Qiita サーバ上のpythonとブラウザ上のjavascriptとデータ通信を行う https://qiita.com/shibaura/items/48bca63ac992c2f93b9d javascript 2022-10-23 20:06:59
Ruby Rubyタグが付けられた新着投稿 - Qiita rubizipでzipファイル中のzipファイルにアクセスしてみた https://qiita.com/shinichi-yamaura/items/fef176fab1b67486854b rubizip 2022-10-23 20:11:42
AWS AWSタグが付けられた新着投稿 - Qiita Apacheが入っているLinuxにNginxをインストールする https://qiita.com/mkuwan/items/a8906ee658e95ec92dba apache 2022-10-23 20:59:59
Docker dockerタグが付けられた新着投稿 - Qiita WSL2 with Windows Docker Desktop 上の krustlet-wasi で node が 404 エラーで作れない問題 (k8s v1.22 以降) https://qiita.com/nt-7/items/5e745ad3b295c777602f krustletvalpha 2022-10-23 20:40:49
Docker dockerタグが付けられた新着投稿 - Qiita 【docker】M1 Macでdockerのmysqlが爆死するけど何故?【mysql】 https://qiita.com/tsuchinoko0102/items/a19993a282c81d101765 debian 2022-10-23 20:08:14
海外TECH DEV Community SlackApi Bolt-python App With AWS Lambda And AWS CDK https://dev.to/aws-builders/slackapi-bolt-python-app-with-aws-lambda-and-aws-cdk-4h5d SlackApi Bolt python App With AWS Lambda And AWS CDK AbstractThe story Since the retirement of rtm start and Slack recommends to not use the custom integration any more so we need to move to new slack appsWith new Slack App feature and The Bolt family of SDKs we can implement Slack bot with AWS serverless using Slash command or at mention This post will follow and extend the example from slackapi bolt python and manage infrasture as code it using AWS CDK typescript Table Of ContentsPre requisiteCreate Slack AppCreate lambda function with function URLLambda handlerTest the Slash commandConclusion Pre requisite You need slack workspace free to create slack appGetting started with AWS CDK Create Slack App First create slack app provide permission for the bot user through OAuth amp Permissions and then install to workspace You can follow the guide from slack pageGet Bot User OAuth Token from OAuth Tokens for Your Workspace under OAuth amp PermissionsGet Signing secret from App Credentials under Basic Information Store Bot token and signing secret to env file and ensure you already set ignore env in gitignore file For better security we can let lambda function to get the credential from SSM parameter store or secret manager but it will slow down lambda operation a bit Create lambda function with function URL Why do we need lambda function URL here let s have a look at following overview diagramThe lambda function URL is used as Request URL of Slash Command Not sure about the flow but the lambda function requires permission to invoke itself otherwise we will get following error Failed to run a middleware middleware error An error occurred AccessDeniedException when calling the Invoke operation User arn aws sts assumed role sin d slack app lambda role sin d slack app lambda handler is not authorized to perform lambda InvokeFunction on resource arn aws lambda ap southeast function sin d slack app lambda handler because no identity based policy allows the lambda InvokeFunction action The CDK construct here is simple since we do not run any real process or use other AWS services The stack includes IAM role attached to the lambda function with enabling function URL Note that the default timeout of lambda function s is not enough to run process request so we need to set timeout Duration seconds import PythonFunction from aws cdk aws lambda python alpha import App Duration Stack StackProps from aws cdk lib import Role ServicePrincipal from aws cdk lib aws iam import FunctionUrlAuthType Runtime from aws cdk lib aws lambda import RetentionDays from aws cdk lib aws logs import Construct from constructs import join from path import SLACK BOT TOKEN SLACK SIGNING SECRET from shared configs import devEnv EnvironmentConfig from shared environment export class SlackAppTest extends Stack constructor scope Construct id string reg EnvironmentConfig props StackProps super scope id props const prefix reg pattern reg stage slack app const role new Role this prefix lambda role roleName prefix lambda role assumedBy new ServicePrincipal lambda amazonaws com managedPolicies managedPolicyArn arn aws iam aws policy service role AWSLambdaBasicExecutionRole managedPolicyArn arn aws iam aws policy service role AWSLambdaRole const lambda new PythonFunction this prefix lambda handler functionName prefix lambda handler runtime Runtime PYTHON environment SLACK BOT TOKEN SLACK BOT TOKEN SLACK SIGNING SECRET SLACK SIGNING SECRET entry join dirname lambda handler logRetention RetentionDays ONE DAY role role timeout Duration seconds lambda addFunctionUrl authType FunctionUrlAuthType NONE const app new App new SlackAppTest app SlackAppLambda devEnv description Create Slack App with lambda function env devEnv app synth Now deploy the stack with following command cdk deploy method direct SlackAppLambda updating stack SlackAppLambda Deployment time s Outputs SlackAppLambda sindslackappfunctionUrl Stack ARN arn aws cloudformation ap southeast stack SlackAppLambda c ff ed bec edc Total time s Lambda handler Lambda handler here index py has two partsProcesses belong to slack bolt python The important one is verifying signing request to clarify the request is sent from Slack app it is implemented as a middleware enabled by default when you instantiate the app see attribute request verification enabled Process event Handle main operations Lazy listeners FaaS In the lambda handler you see the lazy function what is it Lazy Listeners are a feature at the time of this post python support only which make it easier to deploy Slack apps to FaaS Function as a Service environments Calling ack is responsible for returning an immediate HTTP response to Slack API servers within seconds By contrast lazy functions are not supposed to return any response They can do anything by leveraging all the listener args apart from ack utility Also they are completely free from second timeouts As the lazy is a list you can set multiple lazy functions to a single listener The lazy functions will be executed in parallel Test the Slash command Create slash command with Command name is the exact command we set in the lambda handler get the output of lambda function URL after running cdk deploy and add to Request URLOnce installed to a Slack workspace try typing hello bolt python lambda hello in any channel Test the app at mention We need to subscribe to the app mention bot event Your Apps gt Event Subscriptions gt Subscribe to bot events and provide lambda function url at Request URLWith this event subscribed to you can check if things are working by sending a message such as hello yourbotname to a channel that your bot is a member of sending this message will give you the option to add your bot to the channel too If everything is working you should get a response in channel from your bot Hope this helps Conclusion With lambda function url we don t need to host slackbot in an instance server all is serverless And with AWS CDK all is managed through code and deploy by cdk pipelineThere re many feature from new slack app that you can find out more in the slack API page References Vu Dao Follow AWSome Devops AWS Community Builder AWS SA ️CloudOpz ️ vumdao vumdao 2022-10-23 11:26:12
海外ニュース Japan Times latest articles Technology-sharing a sticking point as Renault, Nissan hash out reset, sources say https://www.japantimes.co.jp/news/2022/10/23/business/corporate-business/renault-nissan-reset/ Technology sharing a sticking point as Renault Nissan hash out reset sources sayRenault and Nissan said this month they were in talks about the future of their alliance including Nissan potentially investing in an electric vehicle business 2022-10-23 20:09:17
ニュース BBC News - Home Boris Johnson 'clearly' going to stand to be PM, backer Jacob Rees-Mogg says https://www.bbc.co.uk/news/uk-politics-63363420?at_medium=RSS&at_campaign=KARANGA rishi 2022-10-23 11:36:30
ニュース BBC News - Home Russian fighter plane crashes in Siberian city of Irkutsk https://www.bbc.co.uk/news/world-europe-63365241?at_medium=RSS&at_campaign=KARANGA irkutsk 2022-10-23 11:40:12
ニュース BBC News - Home How many backers do Boris Johnson, Rishi Sunak and Penny Mordaunt have? https://www.bbc.co.uk/news/uk-politics-63343308?at_medium=RSS&at_campaign=KARANGA minister 2022-10-23 11:22:34
北海道 北海道新聞 新潟市長に中原氏が再選確実 共産、社民推薦の新人破る https://www.hokkaido-np.co.jp/article/749687/ 任期満了 2022-10-23 20:25:00
北海道 北海道新聞 キハ281系特急気動車 ファン惜しむ中ラストラン https://www.hokkaido-np.co.jp/article/749681/ 運行 2022-10-23 20:24:00
北海道 北海道新聞 湧別の国定公園内、車両無断侵入で男9人逮捕・送検 密漁目的か https://www.hokkaido-np.co.jp/article/749677/ 国定公園 2022-10-23 20:22:00
北海道 北海道新聞 ヤクルトのつば九郎の「家」 網走ビールとのコラボに注目 https://www.hokkaido-np.co.jp/article/749639/ 設定 2022-10-23 20:18:11
北海道 北海道新聞 帯広の80代女性が840万円詐欺被害 https://www.hokkaido-np.co.jp/article/749644/ 詐欺被害 2022-10-23 20:16:25
北海道 北海道新聞 宗谷管内16人、留萌管内13人感染 新型コロナ https://www.hokkaido-np.co.jp/article/749680/ 宗谷管内 2022-10-23 20:07:00

コメント

このブログの人気の投稿

投稿時間:2021-06-17 05:05:34 RSSフィード2021-06-17 05:00 分まとめ(1274件)

投稿時間:2021-06-20 02:06:12 RSSフィード2021-06-20 02:00 分まとめ(3871件)

投稿時間:2020-12-01 09:41:49 RSSフィード2020-12-01 09:00 分まとめ(69件)