Skip to content

Commit

Permalink
chore(aws-cdk-readme): replace deprecated method used in aws-chatbot …
Browse files Browse the repository at this point in the history
…README.md

Currently addLambdaInvokeCommandPermissions method used to get the permissions,
which is a deprecated method now.
Use addToPolicy method to get necessary permissions.
  • Loading branch information
BLasan committed Mar 11, 2021
1 parent 7711981 commit d1aa705
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions packages/@aws-cdk/aws-chatbot/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,21 @@ This module is part of the [AWS Cloud Development Kit](https://github.com/aws/aw

```ts
import * as chatbot from '@aws-cdk/aws-chatbot';
import * as lambda from '@aws-cdk/aws-lambda';

const slackChannel = new chatbot.SlackChannelConfiguration(this, 'MySlackChannel', {
slackChannelConfigurationName: 'YOUR_CHANNEL_NAME',
slackWorkspaceId: 'YOUR_SLACK_WORKSPACE_ID',
slackChannelId: 'YOUR_SLACK_CHANNEL_ID',
});

slackChannel.addLambdaInvokeCommandPermissions();
slackChannel.addNotificationPermissions();
slackChannel.addSupportCommandPermissions();
slackChannel.addReadOnlyCommandPermissions();
const invokeCommandStatement = new iam.PolicyStatement({
effect: iam.Effect.ALLOW,
resources: ['RESOURCE_ARNS_ALLOWED'],
actions: ['INVOKING_ACTION_ALLOWED'],
});

slackChannel.addToRolePolicy(invokeCommandStatement);

slackChannel.addToPrincipalPolicy(new iam.PolicyStatement({
effect: iam.Effect.ALLOW,
Expand All @@ -46,6 +50,13 @@ slackChannel.addToPrincipalPolicy(new iam.PolicyStatement({
],
resources: ['arn:aws:s3:::abc/xyz/123.txt'],
}));

const lambdaFn = new lambda.Function(this, 'MyChatbotHandler', {
code: lambda.Code.fromAsset('./code'),
runtime: lambda.Runtime.NODE_JS_14_X,
handler: 'FILE_NAME.handler',
});
lambdaFn.grantInvoke(slackChannel.role)
```

## Log Group
Expand Down

0 comments on commit d1aa705

Please sign in to comment.