Skip to content

Commit 02c3520

Browse files
authored
Update AWS example documentation with correct AWS Lambda roles required to run. Fixes #632. (#633)
1 parent 1b10a83 commit 02c3520

File tree

2 files changed

+15
-12
lines changed

2 files changed

+15
-12
lines changed

examples/aws_lambda/README.md

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ Instructions on how to set up and deploy each example are provided below.
2424
- Under "Choose a use case", select "Common use cases: Lambda"
2525
- Click "Next: Permissions"
2626
- Under "Attach permission policies", enter "lambda" in the Filter input
27-
- Check the "AWSLambdaBasicExecutionRole" and "AWSLambdaExecute" policies
27+
- Check the "AWSLambdaBasicExecutionRole", "AWSLambdaExecute" and "AWSLambdaRole" policies
2828
- Click "Next: tags"
2929
- Click "Next: review"
3030
- Enter `bolt_python_lambda_invocation` as the Role name. You can change this
@@ -86,17 +86,17 @@ Instructions on how to set up and deploy each example are provided below.
8686
## OAuth Lambda Listener Example Bolt App
8787

8888
### Setup your AWS Account + Credentials
89-
You need an AWS account and your AWS credentials set up on your machine.
89+
You need an AWS account and your AWS credentials set up on your machine.
9090

9191
Once you’ve done that you should have access to AWS Console, which is what we’ll use for the rest of this tutorial.
9292

9393
### Create S3 Buckets to store Installations and State
9494

95-
1. Start by creating two S3 buckets:
95+
1. Start by creating two S3 buckets:
9696
1. One to store installation credentials for each Slack workspace that installs your app.
9797
2. One to store state variables during the OAuth flow.
9898
2. Head over to **Amazon S3** in the AWS Console
99-
3. Give your bucket a name, region, and set access controls. If you’re doing this for the first time, it’s easiest to keep the defaults and edit them later as necessary. We'll be using the names:
99+
3. Give your bucket a name, region, and set access controls. If you’re doing this for the first time, it’s easiest to keep the defaults and edit them later as necessary. We'll be using the names:
100100
1. slack-installations-s3
101101
2. slack-state-store-s3
102102
4. After your buckets are created, in each bucket’s page head over to “Properties” and save the Amazon Resource Name (ARN). It should look something like `arn:aws:s3:::slack-installations-s3`.
@@ -121,7 +121,7 @@ Now let's create a policy that will allow the holder of the policy to take actio
121121
],
122122
"Resource": [
123123
"<your-first-bucket-arn>/*", // don't forget the `/*`
124-
"<your-second-bucket-arn>/*"
124+
"<your-second-bucket-arn>/*"
125125
]
126126
}
127127
]
@@ -130,8 +130,8 @@ Now let's create a policy that will allow the holder of the policy to take actio
130130
4. Edit “Resource” to include the ARNs of the two buckets you created in the earlier step. These need to exactly match the ARNS you copied earlier and end with a `/*`
131131
5. Hit "Next:Tags" and "Next:Review"
132132
6. Review policy
133-
1. Name your policy something memorable enough that you won’t have forgotten it 5 minutes from now when we’ll need to look it up from a list. (e.g. AmazonS3-FullAccess-SlackBuckets)
134-
2. Review the summary, and hit "Create Policy". Once the policy is created you should be redirected to the Policies page and see your new policy show up as Customer managed policy.
133+
1. Name your policy something memorable enough that you won’t have forgotten it 5 minutes from now when we’ll need to look it up from a list. (e.g. AmazonS3-FullAccess-SlackBuckets)
134+
2. Review the summary, and hit "Create Policy". Once the policy is created you should be redirected to the Policies page and see your new policy show up as Customer managed policy.
135135

136136
### Setup an AWS IAM Role with Policies for Executing Your Lambda
137137
Let’s create a user role that will use the custom policy we created as well as other policies to let us execute our lambda, write output logs to CloudWatch.
@@ -142,12 +142,13 @@ Let’s create a user role that will use the custom policy we created as well as
142142
4. Step 1 - Select trusted entity
143143
1. Under "Select type of trusted entity", choose "AWS service"
144144
2. Under "Choose a use case", select "Common use cases: Lambda"
145-
3. Click "Next: Permissions
145+
3. Click "Next: Permissions"
146146
5. Step 2 - Add permissions
147147
1. Add the following policies to the role we’re creating that will allow the user with the role permission to execute Lambda, make changes to their S3 Buckets, log output to CloudWatch
148148
1. `AWSLambdaExecute`
149149
2. `AWSLambdaBasicExecutionRole`
150-
3. `<NameOfRoleYouCreatedEarlier>`
150+
3. `AWSLambdaRole`
151+
4. `<NameOfS3PolicyYouCreatedEarlier>`
151152
6. Step 3 - Name, review, create
152153
1. Enter `bolt_python_s3_storage` as your role name. To use a different name, make sure to update the role name in `aws_lambda_oauth_config.yaml`
153154
2. Optionally enter a description for the role, such as "Bolt Python with S3 access role”
@@ -166,12 +167,12 @@ SLACK_CLIENT_SECRET # Client Secret from Basic Information page
166167
SLACK_SCOPES= "app_mentions:read,chat:write"
167168
SLACK_INSTALLATION_S3_BUCKET_NAME: # The name of installations bucket
168169
SLACK_STATE_S3_BUCKET_NAME: # The name of the state store bucket
169-
export
170+
export
170171
```
171172
6. Let's deploy the Lambda! Run `./deploy_oauth.sh`. By default it deploys to the us-east-1 region in AWS - you can customize this in `aws_lambda_oauth_config.yaml`.
172173
7. Load up AWS Lambda inside the AWS Console - make sure you are in the correct region that you deployed your app to. You should see a `bolt_py_oauth_function` Lambda there.
173174

174-
### Set up AWS API Gateway
175+
### Set up AWS API Gateway
175176
Your Lambda exists, but it is not accessible to the internet, so Slack cannot yet send events happening in your Slack workspace to your Lambda. Let's fix that by adding an AWS API Gateway in front of your Lambda so that your Lambda can accept HTTP requests
176177

177178
1. Click on your `bolt_py_oauth_function` Lambda
@@ -198,7 +199,7 @@ Phew, congrats! Your Slack app is now accessible to the public. On the left side
198199

199200
You can now install the app to any workspace!
200201

201-
### Test it out!
202+
### Test it out!
202203
1. Once installed to a Slack workspace, try typing `/hello-bolt-python-lambda` hello.
203204
2. If you have issues, here are some debugging options:
204205
1. _View lambda activity_: Head to the Monitor tab under your Lambda. Did the Lambda get invoked? Did it respond with an error? Investigate the graphs to see how your Lambda is behaving.

examples/aws_lambda/aws_lambda_oauth.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ def handler(event, context):
4242
# AWS IAM Role: bolt_python_s3_storage
4343
# - AmazonS3FullAccess
4444
# - AWSLambdaBasicExecutionRole
45+
# - AWSLambdaExecute
46+
# - AWSLambdaRole
4547

4648
# rm -rf latest_slack_bolt && cp -pr ../../src latest_slack_bolt
4749
# pip install python-lambda

0 commit comments

Comments
 (0)