Skip to content

Commit

Permalink
Use bare-bones AWS clients
Browse files Browse the repository at this point in the history
  • Loading branch information
komiya-atsushi committed Oct 19, 2024
1 parent d935d7b commit d05b415
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 14 deletions.
6 changes: 2 additions & 4 deletions packages/example-bolt-dynamodb/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {App, ExpressReceiver, LogLevel} from '@slack/bolt';
import serverlessExpress from '@codegenie/serverless-express';
import {DynamoDB} from '@aws-sdk/client-dynamodb';
import {DynamoDBClient} from '@aws-sdk/client-dynamodb';
import {
BinaryInstallationCodec,
DynamoDbInstallationStore,
Expand All @@ -16,16 +16,14 @@ function ensureNotUndefined(envName: string): string {

const clientId = ensureNotUndefined('SLACK_CLIENT_ID');

const dynamoDb = new DynamoDB({region: process.env.AWS_REGION});

const installationCodec = BinaryInstallationCodec.createDefault(
ensureNotUndefined('INSTALLATION_STORE_ENCRYPTION_PASSWORD'),
ensureNotUndefined('INSTALLATION_STORE_ENCRYPTION_SALT')
);

const installationStore = DynamoDbInstallationStore.create({
clientId,
dynamoDb,
dynamoDb: new DynamoDBClient(),
tableName: ensureNotUndefined('DYNAMODB_TABLE_NAME'),
partitionKeyName: 'PK',
sortKeyName: 'SK',
Expand Down
1 change: 0 additions & 1 deletion packages/example-bolt-dynamodb/template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ Globals:
SLACK_CLIENT_SECRET: !Ref ClientSecret
SLACK_SIGNING_SECRET: !Ref SigningSecret
SLACK_STATE_SECRET: !Ref StateSecret
REGION: !Ref AWS::Region
INSTALLATION_STORE_ENCRYPTION_PASSWORD: !Ref InstallationEncryptionPassword
INSTALLATION_STORE_ENCRYPTION_SALT: !Ref InstallationEncryptionSalt

Expand Down
6 changes: 2 additions & 4 deletions packages/example-bolt-s3/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {App, ExpressReceiver, LogLevel} from '@slack/bolt';
import serverlessExpress from '@codegenie/serverless-express';
import {S3} from '@aws-sdk/client-s3';
import {S3Client} from '@aws-sdk/client-s3';
import {BinaryInstallationCodec, S3InstallationStore} from '@k11i/bolt-s3';

function ensureNotUndefined(envName: string): string {
Expand All @@ -13,16 +13,14 @@ function ensureNotUndefined(envName: string): string {

const clientId = ensureNotUndefined('SLACK_CLIENT_ID');

const s3Client = new S3({region: process.env.S3_REGION});

const installationCodec = BinaryInstallationCodec.createDefault(
ensureNotUndefined('S3_INSTALLATION_STORE_ENCRYPTION_PASSWORD'),
ensureNotUndefined('S3_INSTALLATION_STORE_ENCRYPTION_SALT')
);

const installationStore = S3InstallationStore.create({
clientId,
s3: s3Client,
s3: new S3Client(),
bucketName: ensureNotUndefined('S3_BUCKET_NAME'),
options: {
historicalDataEnabled: true,
Expand Down
5 changes: 0 additions & 5 deletions packages/example-bolt-s3/template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ Parameters:
Type: String
StateSecret:
Type: String
S3Region:
Type: String
InstallationEncryptionPassword:
Type: String
InstallationEncryptionSalt:
Expand All @@ -27,15 +25,12 @@ Globals:
SLACK_CLIENT_SECRET: !Ref ClientSecret
SLACK_SIGNING_SECRET: !Ref SigningSecret
SLACK_STATE_SECRET: !Ref StateSecret
S3_REGION: !Ref S3Region
S3_INSTALLATION_STORE_ENCRYPTION_PASSWORD: !Ref InstallationEncryptionPassword
S3_INSTALLATION_STORE_ENCRYPTION_SALT: !Ref InstallationEncryptionSalt

Resources:
S3InstallationStore:
Type: AWS::S3::Bucket
Properties:
BucketName: bolt-s3-example-app

SlackEventReceiver:
Type: AWS::Serverless::Function
Expand Down

0 comments on commit d05b415

Please sign in to comment.