Hi I'm trying to use google cloud secret manager but this error keeps showing up whenever I try to import the SecretManagerServiceClient I tried following the documentation here but still can't make it run I also tried adding fallback: true to the constructor but it keep showing this error
There are multiple errors that are similar to this error message so I didn't copy them but essentially all error are coming from tunnel-agent
./node_modules/tunnel-agent/index.js:6:12-28 - Error: Module not found: Error: Can't resolve 'https' in '/[file path]/node_modules/tunnel-agent'
BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.
This is no longer the case. Verify if you need this module and configure a polyfill for it.
If you want to include a polyfill, you need to:
- add a fallback 'resolve.fallback: { "https": require.resolve("https-browserify") }'
- install 'https-browserify'
If you don't want to include a polyfill, you can use an empty module like this:
resolve.fallback: { "https": false }
btw I am using angular 14.2.12 and using google cloud secret manager version 5.2.0
Any help would be much appreciated thank you.
async accessSecret() {
const client = new SecretManagerServiceClient({ fallback: true });
const [secret] = await client.accessSecretVersion({
name: 'projects/my-project/secrets/my-secret',
});
// The secret payload is a base64-encoded string.sa
const payload = secret.payload.data.toString();
console.log(`The secret payload is: ${payload}`);
console.log('test')
}