Skip to content

Commit

Permalink
chore: use default creds for dynamo
Browse files Browse the repository at this point in the history
  • Loading branch information
javiersuweijie committed Aug 12, 2024
1 parent 11adfd4 commit fa3f8af
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
1 change: 1 addition & 0 deletions eth/.env_example
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ SLACK_NOTI_NETWORK="TESTNET"
SLACK_NOTI_ETH_ASSET="ETH"
SLACK_WEB_HOOK=""

USE_DEFAULT_CRED_PROVIDER=true
DYNAMO_ACCESS_KEY_ID=""
DYNAMO_SECRET_ACCESS_KEY=""
DYNAMO_REGION=""
1 change: 1 addition & 0 deletions eth/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ services:
- dynamodb-local
container_name: shuttle-eth
environment:
USE_DEFAULT_CRED_PROVIDER: false
DYNAMO_ACCESS_KEY_ID: 'DUMMYIDEXAMPLE'
DYNAMO_SECRET_ACCESS_KEY: 'DUMMYEXAMPLEKEY'
DYNAMO_ENDPOINT: 'http://dynamodb-local:8000'
Expand Down
12 changes: 11 additions & 1 deletion eth/src/DynamoDB.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,17 @@ export class DynamoDB {
client: DynamoDBClient;

constructor() {
this.client = new DynamoDBClient({
this.client = this.createDynamoDBClient();
}

createDynamoDBClient(): DynamoDBClient {
// we don't need to set any of this for an aws service it has a region and a role already
// the aws sdk already knows to look for the default env vars
if (process.env.USE_DEFAULT_CRED_PROVIDER === 'true') {
return new DynamoDBClient({ region: process.env.AWS_REGION });
}
return new DynamoDBClient({
endpoint: process.env.DYNAMO_ENDPOINT,
region: DYNAMO_REGION,
credentials: {
accessKeyId: DYNAMO_ACCESS_KEY_ID,
Expand Down

0 comments on commit fa3f8af

Please sign in to comment.