Skip to content

Commit

Permalink
fix: add aws credentials to config
Browse files Browse the repository at this point in the history
  • Loading branch information
Roger Torres committed Sep 12, 2023
1 parent 0e54290 commit 8cdb3fa
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 5 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/ci-cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ jobs:
PG_DATABASE: postgres
AWS_REGION: us-east-1
AWS_DYNAMO_ENDPOINT: http://localhost:8000
AWS_CREDENTIALS_ACCESS_KEY_ID: accesskeyid
AWS_CREDENTIALS_SECRET_ACCESS_KEY: secretaccesskey

- name: coveralls
uses: coverallsapp/github-action@master
Expand Down
3 changes: 2 additions & 1 deletion libs/eventually-aws/src/DynamoStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ import { config } from "./config";
export const DynamoStore = (table: string): Store => {
const client = new DynamoDBClient({
region: config.aws.region,
endpoint: config.aws.dynamo?.endpoint
endpoint: config.aws.dynamo?.endpoint,
credentials: config.aws.credentials
});
const name = `DynamoStore:${table}`;

Expand Down
3 changes: 2 additions & 1 deletion libs/eventually-aws/src/DynamoSubscriptionStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ import { config } from "./config";
export const DynamoSubscriptionStore = (table: string): SubscriptionStore => {
const client = new DynamoDBClient({
region: config.aws.region,
endpoint: config.aws.dynamo?.endpoint
endpoint: config.aws.dynamo?.endpoint,
credentials: config.aws.credentials
});
const name = `DynamoSubscriptionStore:${table}`;

Expand Down
20 changes: 19 additions & 1 deletion libs/eventually-aws/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ type Region = (typeof Regions)[number];
const Schema = z.object({
aws: z.object({
region: z.enum(Regions).optional(),
credentials: z
.object({
accessKeyId: z.string(),
secretAccessKey: z.string()
})
.optional(),
dynamo: z
.object({
endpoint: z.string().optional()
Expand All @@ -15,7 +21,12 @@ const Schema = z.object({
})
});

const { AWS_REGION, AWS_DYNAMO_ENDPOINT } = process.env;
const {
AWS_REGION,
AWS_DYNAMO_ENDPOINT,
AWS_CREDENTIALS_ACCESS_KEY_ID,
AWS_CREDENTIALS_SECRET_ACCESS_KEY
} = process.env;

/**
* AWS configuration options
Expand All @@ -24,6 +35,13 @@ export const config = extend(
{
aws: {
region: AWS_REGION as Region,
credentials: AWS_CREDENTIALS_ACCESS_KEY_ID
? {
accessKeyId: AWS_CREDENTIALS_ACCESS_KEY_ID,
secretAccessKey:
AWS_CREDENTIALS_SECRET_ACCESS_KEY ?? "missing-secret"
}
: undefined,
dynamo: AWS_DYNAMO_ENDPOINT
? { endpoint: AWS_DYNAMO_ENDPOINT }
: undefined
Expand Down
2 changes: 1 addition & 1 deletion libs/eventually-pg/src/PostgresStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export const PostgresStore = (table: string): Store => {
},

reset: async (): Promise<void> => {
await pool.query(`TRUNCATE TABLE "${table}"`);
await pool.query(`DROP TABLE IF EXISTS "${table}"`);
},

query: async <E extends Messages>(
Expand Down
2 changes: 1 addition & 1 deletion libs/eventually-pg/src/PostgresSubscriptionStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export const PostgresSubscriptionStore = (table: string): SubscriptionStore => {
},

reset: async (): Promise<void> => {
await pool.query(`TRUNCATE TABLE "${table}"`);
await pool.query(`DROP TABLE IF EXISTS "${table}"`);
},

poll: async <E extends Messages>(
Expand Down

0 comments on commit 8cdb3fa

Please sign in to comment.