Skip to content

Commit

Permalink
Merge branch 'main' into Update-maintainers-guilde
Browse files Browse the repository at this point in the history
  • Loading branch information
srajiang committed Jul 26, 2022
2 parents e2bd9c1 + 151dec0 commit 180551d
Show file tree
Hide file tree
Showing 22 changed files with 188 additions and 185 deletions.
20 changes: 10 additions & 10 deletions docs/_deployments/aws-lambda.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ When you’re finished, you’ll have this ⚡️[Deploying to AWS Lambda app][d

---

### Set up AWS Lambda
### Set up AWS Lambda {#set-up-aws-lambda}

[AWS Lambda][aws-lambda] is a serverless, Function-as-a-Service (FaaS) platform that allows you to run code without managing servers. In this section, we'll configure your local machine to access AWS Lambda.

Expand Down Expand Up @@ -62,13 +62,13 @@ That wraps up configuring your local machine to access AWS. 👏 Next, let's do

---

### Set up Serverless Framework
### Set up Serverless Framework {#set-up-serverless-framework}

The [Serverless Framework][serverless-framework] includes tools that let you easily configure, debug, and deploy your app to AWS Lambda.

**1. Install the Serverless Framework CLI**

The Serverless tools are available as a Command Line Interface (CLI) and can be [installed on macOS, Windows, or Linux](https://www.serverless.com/framework/docs/getting-started/). Check out the [Serverless Getting Started documentation](https://www.serverless.com/framework/docs/getting-started/) for instructions on how to install.
The Serverless tools are available as a Command Line Interface (CLI) and can be installed on macOS, Windows, or Linux. Check out the [Serverless Getting Started documentation](https://www.serverless.com/framework/docs/getting-started/) for instructions on how to install.

Once the installation is complete, test the Serverless CLI by displaying the commands available to you:

Expand All @@ -80,7 +80,7 @@ You're now set up with the Serverless tools! Let's move on to preparing your Bol

---

### Get a Bolt Slack app
### Get a Bolt Slack app {#get-a-bolt-slack-app}

If you haven't already built your own Bolt app, you can use our [Getting Started guide][getting-started-guide] or clone the template app below:

Expand All @@ -98,7 +98,7 @@ Now that you have an app, let's prepare it for AWS Lambda and the Serverless Fra

---

### Prepare the app
### Prepare the app {#prepare-the-app}

**1. Prepare the app for AWS Lambda**

Expand Down Expand Up @@ -139,7 +139,7 @@ const app = new App({
// When using the AwsLambdaReceiver, processBeforeResponse can be omitted.
// If you use other Receivers, such as ExpressReceiver for OAuth flow support
// then processBeforeResponse: true is required. This option will defer sending back
// the acknowledgement until after your handler has run to ensure your function
// the acknowledgement until after your handler has run to ensure your handler
// isn't terminated early by responding to the HTTP request that triggered it.

// processBeforeResponse: true
Expand Down Expand Up @@ -186,7 +186,7 @@ plugins:
```

> 💡 `SLACK_SIGNING_SECRET` and `SLACK_BOT_TOKEN` must be enviornment variables on your local machine.
> You can [learn how to export Slack environment variables](/bolt-js/tutorial/getting-started#setting-up-your-local-project) in our Getting Started guide.
> You can [learn how to export Slack environment variables](/bolt-js/tutorial/getting-started#setting-up-your-project) in our Getting Started guide.
**3. Install Serverless Offline**

Expand All @@ -202,7 +202,7 @@ Congratulations, you've just prepared your Bolt app for AWS Lambda and Serverles

---

### Run the app locally
### Run the app locally {#run-the-app-locally}

Now that your app is configured to respond to an AWS Lambda function, we'll set up your environment to run the app locally.

Expand Down Expand Up @@ -252,7 +252,7 @@ If you don’t receive a response, check your **Request URL** and try again.
---

### Deploy the app
### Deploy the app {#deploy-the-app}

In the previous section of this tutorial, you ran your app locally and tested it in a live Slack workspace. Now that you have a working app, let's deploy it!

Expand Down Expand Up @@ -323,7 +323,7 @@ When the deploy is complete, you can open a Slack channel that your app has join
---

### Next steps
### Next steps {#next-steps}

You just deployed your first ⚡️[Bolt for JavaScript app to AWS Lambda][deploy-aws-lambda-app]! 🚀

Expand Down
14 changes: 7 additions & 7 deletions docs/_deployments/heroku.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ When you’re finished, you’ll have this ⚡️[Deploying to Heroku app][deplo

---

### Get a Bolt Slack app
### Get a Bolt Slack app {#get-a-bolt-slack-app}

If you haven't already built your own Bolt app, you can use our [Getting Started guide][getting-started-guide] or clone the template app below:

Expand All @@ -34,7 +34,7 @@ Now that you have an app, let's prepare it for Heroku.

---

### Prepare the app for Heroku
### Prepare the app for Heroku {#prepare-the-app-for-heroku}

Heroku is a flexible platform that requires some configuration to host your app. In this section, we'll update your Bolt app to support Heroku.

Expand Down Expand Up @@ -73,7 +73,7 @@ git commit -m "Add Procfile"
---

### Set up the Heroku tools
### Set up the Heroku tools {#set-up-the-heroku-tools}

Now we can set up the Heroku tools on your local machine. These tools will help you manage, deploy, and debug your app on Heroku's platform.

Expand Down Expand Up @@ -114,7 +114,7 @@ You should now be set up with the Heroku tools! Let's move on to the exciting st

---

### Create an app on Heroku
### Create an app on Heroku {#create-an-app-on-heroku}

It’s time to [create a Heroku app](https://devcenter.heroku.com/articles/creating-apps) using the tools that you just installed. When you create an app, you can choose a unique name or have it randomly generated.

Expand Down Expand Up @@ -167,7 +167,7 @@ Now that we have prepared your local app and created a Heroku app, the next step

---

### Deploy the app
### Deploy the app {#deploy-the-app}

To deploy the app, we're going to push your local code to Heroku, update your Slack app's settings, and say "hello" to your Heroku app. ✨

Expand Down Expand Up @@ -225,7 +225,7 @@ Open a Slack channel that your app has joined and say "hello" (lower-case). Just

---

### Deploy an update
### Deploy an update {#deploy-an-update}

As you continue building your Slack app, you'll need to deploy updates. A common flow is to make a change, commit it, and then push it to Heroku.

Expand Down Expand Up @@ -255,7 +255,7 @@ When the deploy is complete, you can open a Slack channel that your app has join

---

### Next steps
### Next steps {#next-steps}

You just deployed your first ⚡️[Bolt for JavaScript app to Heroku][deploy-heroku-app]! 🚀

Expand Down
68 changes: 35 additions & 33 deletions docs/_deployments/ja_aws-lambda.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ permalink: /ja-jp/deployments/aws-lambda

---

### AWS Lambda のセットアップ
### AWS Lambda のセットアップ {#set-up-aws-lambda}

[AWS Lambda][aws-lambda] はサーバーレスの Function-as-a-Service(FaaS)プラットフォームです。AWS Lambda を利用すると、サーバーを管理することなく、コードを実行することができます。このセクションでは、ローカルマシンから AWS Lambda にアクセスするための設定を行います。

Expand Down Expand Up @@ -62,31 +62,25 @@ aws configure

---

### Serverless Framework をセットアップする
### Serverless Framework をセットアップする {#set-up-serverless-framework}

[Serverless Framework](https://www.serverless.com/open-source/) では、AWS Lambda 向けのアプリの設定、デバッグ、デプロイを簡単に行うためのツールが用意されています。
[Serverless Framework][serverless-framework] では、AWS Lambda 向けのアプリの設定、デバッグ、デプロイを簡単に行うためのツールが用意されています。

**1. Serverless Framework CLI をインストールする**

Serverless でも [macOS、Windows、Linux](https://www.serverless.com/framework/docs/getting-started/) にインストールして利用できるコマンドラインインターフェイス(CLI)のツールが用意されています。インストールには npm を使用します。次のコマンドを実行してください。

```shell
npm install --save-dev serverless
```

> 💡 [Serverless CLI をグローバルにインストールする](https://www.serverless.com/framework/docs/getting-started/)こともできます。その場合は`npm install -g serverless` というコマンドを実行します。
Serverless でも macOS、Windows、Linux にインストールして利用できるコマンドラインインターフェイス(CLI)のツールが用意されています。インストールするには Serverless の[入門ガイド(英語)](https://www.serverless.com/framework/docs/getting-started/) をお読みください。

インストールが完了したら Serverless CLI をテストするため、利用可能なコマンドを表示してみましょう。

```shell
npx serverless help
serverless help
```

Serverless のツールのセットアップが完了しました。次に、AWS Lambda 関数として実行する Bolt アプリの準備へと進みましょう。

---

### Bolt Slack アプリを入手する
### Bolt Slack アプリを入手する {#get-a-bolt-slack-app}

まだ Bolt アプリを自分で作成したことがない場合は、[入門ガイド][getting-started-guide]を参照してください。テンプレートのアプリをクローンするには、以下のコマンドを実行します。

Expand All @@ -104,7 +98,7 @@ Bolt アプリを用意できました。次に AWS Lambda と Serverless Framew

---

### アプリをセットアップする
### アプリをセットアップする {#prepare-the-app}

**1. アプリを AWS Lambda に対応させる**

Expand All @@ -119,7 +113,7 @@ const app = new App({
});
```

次に Lambda 関数のイベントに応答するよう、Bolt アプリの [`receiver`](https://slack.dev/bolt-js/ja-jp/concepts#receiver) をカスタマイズします。
次に Lambda 関数のイベントに応答するよう、Bolt アプリの [`receiver`](/bolt-js/ja-jp/concepts#receiver) をカスタマイズします。

`app.js` のソースコードの中で[モジュールのインポートを行う部分](https://github.com/slackapi/bolt-js-getting-started-app/blob/main/app.js#L1)を編集し、Bolt の `AwsLambdaReceiver` モジュールを require します。

Expand All @@ -139,13 +133,16 @@ const awsLambdaReceiver = new AwsLambdaReceiver({

// ボットトークンと、AWS Lambda に対応させたレシーバーを使ってアプリを初期化します。
const app = new App({
token: process.env.SLACK_BOT_TOKEN,
receiver: awsLambdaReceiver,
// `processBeforeResponse` オプションは、あらゆる FaaS 環境で必須です。
// このオプションにより、Bolt フレームワークが `ack()` などでリクエストへの応答を返す前に
// `app.message` などのメソッドが Slack からのリクエストを処理できるようになります。FaaS では
// 応答を返した後にハンドラーがただちに終了してしまうため、このオプションの指定が重要になります。
processBeforeResponse: true
token: process.env.SLACK_BOT_TOKEN,
receiver: awsLambdaReceiver,

// AwsLambdaReceiver を利用する場合は `processBeforeResponse` は省略可能です。
// OAuth フローに対応した ExpressReceiver など、他のレシーバーを使用する場合、
// `processBeforeResponse: true` が必要になります。
// このオプションは、ハンドラーの実行が完了するまで応答を返すのを遅延させます。
// これによってハンドラーがトリガーとなった HTTP リクエストに応答を返すことでただちに終了されることを防ぐことができます。

//processBeforeResponse: true
});
```

Expand Down Expand Up @@ -187,7 +184,7 @@ plugins:
- serverless-offline
```

> 💡 `SLACK_SIGNING_SECRET``SLACK_BOT_TOKEN` の環境変数は、ローカルマシンで設定しておく必要があります。[Slack の環境変数をエクスポートする方法](/bolt-js/tutorial/getting-started#setting-up-your-local-project)を入門ガイドで参照してください。
> 💡 `SLACK_SIGNING_SECRET``SLACK_BOT_TOKEN` の環境変数は、ローカルマシンで設定しておく必要があります。[Slack の環境変数をエクスポートする方法](/bolt-js/ja-jp/tutorial/getting-started#setting-up-your-project)を入門ガイドで参照してください。
**3. serverless-offline モジュールをインストールする**

Expand All @@ -203,17 +200,18 @@ npm install --save-dev serverless-offline

---

### アプリをローカルで実行する
### アプリをローカルで実行する {#run-the-app-locally}

アプリを AWS Lambda 関数に応答させるための準備が完了したので、次にローカルでアプリを実行できるように環境を設定します。

**1. ローカルのサーバーを起動する**

まず、AWS Lambda 関数のイベントをリッスンするため、`serverless offline` コマンドを実行します。
まず、アプリの起動と AWS Lambda 関数のイベントをリッスンするため、`serverless offline` コマンドを実行します。

```zsh
npx serverless offline --noPrependStageInUrl
serverless offline --noPrependStageInUrl
```
> 🏌️ Pro-tip: 別のターミナルで上記のコマンドを実行しておくことで、ターミナル上でアプリのコードを変更することができます。コードの変更を保存する度、アプリは自動的にリロードされます。
次に、ngrok を使って Slack のイベントをローカルマシンに転送します。

Expand Down Expand Up @@ -250,7 +248,9 @@ Slack アプリをテストします。今作った Bolt アプリを Slack の
---

### アプリをデプロイする
### アプリをデプロイする {#deploy-the-app}

今までローカルでアプリを実行し、 Slack ワークスペースでテストをしてきました。さて、動作するアプリができたので、デプロイしてみましょう!

AWS Lambda 向けのアプリのプロビジョニング、パッケージング、デプロイには、Serverless Framework のツールが利用できます。アプリのデプロイが完了したら、アプリのリクエスト URL を更新して、「hello」と入力した時にアプリが応答できるようにします。✨

Expand All @@ -259,7 +259,7 @@ AWS Lambda 向けのアプリのプロビジョニング、パッケージング
次のコマンドを使って AWS Lambda にアプリをデプロイします。

```shell
npx serverless deploy
serverless deploy
# Serverless:Packaging service...
# ...
# endpoints:
Expand Down Expand Up @@ -309,22 +309,24 @@ app.message('goodbye', async ({ message, say }) => {
先ほどと同じコマンドを使って更新をデプロイします。

```shell
npx serverless deploy
serverless deploy
```

デプロイが完了したら、アプリを参加させた Slack チャンネルを開いて、半角の小文字で「goodbye」と入力してみましょう。Slack アプリに「See you later」と表示されるはずです。

> ⛳️ 一つの関数に小さな変更を加える場合、その関数だけをデプロイするためにより高速な `serverless deploy function -f my-function` を実行することができます。より詳細なヘルプを見るには `serverless help deploy function` を実行してください。
---

### 次のステップ
### 次のステップ {#next-steps}

⚡️[AWS Lambda を使った最初の Bolt for JavaScript アプリ][deploy-aws-lambda-app]をデプロイできました。🚀

基本的なアプリのデプロイができましたので、次はアプリのカスタマイズやモニタリングを行う方法を調べてみましょう。

- [AWS Lambda](https://docs.aws.amazon.com/lambda/latest/dg/welcome.html)[Serverless Framework](https://www.serverless.com/framework/docs/providers/aws/guide/intro/) の理解を深める。
- [Bolt の基本的な概念](/bolt-js/concepts#basic)[Serverless のプラグイン](https://www.serverless.com/framework/docs/providers/aws/guide/plugins/)を活用してアプリを拡張する。
- [Bolt の応用コンセプト](/bolt-js/concepts#logging)でログの記録についての知識を深めたり、[Serverless でのログメッセージの表示方法](https://www.serverless.com/framework/docs/providers/aws/cli-reference/logs/)について確認したりする。
- [Bolt の基本的な概念](/bolt-js/ja-jp/concepts#basic)[Serverless のプラグイン](https://www.serverless.com/framework/docs/providers/aws/guide/plugins/)を活用してアプリを拡張する。
- [Bolt の応用コンセプト](/bolt-js/ja-jp/concepts#logging)でログの記録についての知識を深めたり、[Serverless でのログメッセージの表示方法](https://www.serverless.com/framework/docs/providers/aws/cli-reference/logs/)について確認したりする。
- Serverless の [AWS Lambda のテスト環境](https://www.serverless.com/framework/docs/providers/aws/guide/testing/)[デプロイ環境](https://www.serverless.com/framework/docs/providers/aws/guide/deploying/)を本格的に活用する。

[aws-cli-configure]: https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-quickstart.html#cli-configure-quickstart-config
Expand All @@ -339,6 +341,6 @@ npx serverless deploy
[bolt-js]: /bolt-js
[deploy-aws-lambda-app]: https://github.com/slackapi/bolt-js/tree/main/examples/deploy-aws-lambda
[deploy-aws-lambda-app/app.js]: https://github.com/slackapi/bolt-js/tree/main/examples/deploy-aws-lambda/app.js
[getting-started-guide-setting-up-events]: https://slack.dev/bolt-js/tutorial/getting-started#setting-up-events
[getting-started-guide]: /bolt-js/tutorial/getting-started
[getting-started-guide-setting-up-events]: https://slack.dev/bolt-js/ja-jp/tutorial/getting-started#setting-up-events
[getting-started-guide]: /bolt-js/ja-jp/tutorial/getting-started
[serverless-framework]: https://serverless.com/

0 comments on commit 180551d

Please sign in to comment.