Skip to content

Commit 2c7e16d

Browse files
committed
update authenticate with aws part
1 parent b94bb3e commit 2c7e16d

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

src/lib/cassandra.ts

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,24 +9,20 @@ AWS.config.update({
99
// Optionally, configure AWS credentials (from environment or IAM role)
1010
});
1111

12-
const isAwsKeyspaces = process.env.DB_IS_AWS_KEYSPACES === 'true'; // Detect if connecting to AWS Keyspaces
12+
const isAwsKeyspaces = process.env.DB_IS_AWS_KEYSPACES
13+
? process.env.DB_IS_AWS_KEYSPACES === 'true'
14+
: true;
1315

1416
let client: Client;
1517

1618
// Set up Cassandra connection configuration for local and AWS Keyspaces
1719
if (isAwsKeyspaces) {
1820
// AWS Keyspaces connection setup
19-
const credentials = new AWS.Credentials({
20-
accessKeyId: process.env.AWS_ACCESS_KEY_ID,
21-
secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY,
22-
sessionToken: process.env.AWS_SESSION_TOKEN, // Use temporary credentials if needed
23-
});
24-
2521
client = new Client({
2622
contactPoints: [process.env.DB_CONTACT_POINTS || 'cassandra.us-east-1.amazonaws.com'], // AWS Keyspaces endpoint
2723
localDataCenter: process.env.DB_LOCAL_DATACENTER || 'us-east-1',
2824
keyspace: process.env.DB_KEYSPACE || 'your_keyspace',
29-
authProvider: new Cassandra.AwsAuthProvider(credentials), // AWS IAM for authentication
25+
authProvider: new Cassandra.AwsAuthProvider(AWS.config.credentials), // AWS IAM for authentication
3026
sslOptions: { rejectUnauthorized: true }, // Enable SSL for AWS Keyspaces
3127
});
3228
} else {

0 commit comments

Comments
 (0)