Include zipped secure connect file when build Next.js app on Amplify

117 Views Asked by At

There was a driver for connecting to the Datastax Astra-DB Cassandra Database in node.js called 'cassandra-driver'. For legacy connection It uses a connection secret key file named secure-connect-{DB-Name}.zip, syntax like this:

const client = new Client({
  cloud: {
    secureConnectBundle: 'Address of the zipped file'
  },
  credentials: {
    username: 'This is client_id',
    password: 'This is client_secret',
  },
});

In local the syntax works well but when I deploy it on AWS Amplify, since the file does not put in Next.js bundle, A file not found error will be raised. Now the Question: Is there any way to keep the file in Amplify itself inside Next.js bundle and not upload it on external storage (like S3 , a silly way!) to access?

1

There are 1 best solutions below

0
On

I encountered the same issue, in my case it was deploying it to Vercel. The issue can be solved this way,

  1. Put your Secure Bundle Zip at the root of your project.
  2. Now modify your code like this:

const client = new Client({
  cloud: {
    secureConnectBundle: path.join(
          process.cwd(),
          "filename.zip"
        )
  },
  credentials: {
    username: 'This is client_id',
    password: 'This is client_secret',
  },
});

Let me know if this works for you