-
I started the migration from the v1 to v2 and I'm bundling the software with webpack to run it as a Lambda.
my package.json "dependencies": {
"aws-crt": "^1.15.5",
"aws-iot-device-sdk-v2": "^1.9.0", In v1 I created only a
A local setup and using certificates works pretty well on the other hand.
If it is a coding issue does anyone have the correct code for Lambda. It seems a lot of people are running the v2 maybe someone has a solution or workaround already. I wish there would be a migrations guide from v1 to v2 for Lambda usage. ---- update 230123 --- const path = require('path');
const nodeExternals = require('webpack-node-externals');
const webpack = require('webpack')
function srcPath(subdir) {
return path.join(__dirname, "src", subdir);
}
var config = {
entry: path.join(__dirname, '/src/lambda.ts'),
watch: false,
target: 'node',
plugins: [
new webpack.IgnorePlugin({ resourceRegExp: /^hiredis$/ })
],
output: {
path: path.join(__dirname, 'dist'),
filename: 'xxxxx.js',
library: 'xxxx',
libraryTarget: 'umd',
libraryExport: 'default',
umdNamedDefine: true
},
optimization: {
moduleIds: "named", // deprecated namedModules: true,
chunkIds: "named",// deprecated namedChunks: true,
nodeEnv: false,
minimize: false,
flagIncludedChunks: false,
concatenateModules: false,
splitChunks: {
hidePathInfo: false,
minSize: 10000,
maxAsyncRequests: Infinity,
maxInitialRequests: Infinity,
},
emitOnErrors: true,
checkWasmTypes: false,
removeAvailableModules: false
},
externals: [
{
"aws-sdk": "aws-sdk"
},
// nodeExternals({
// whitelist: []
// })
],
module: {
rules: [
{
test: /\.tsx?$/,
loader: 'ts-loader',
exclude: /node_modules/,
},
{
// test: /.\/mqtt\/.\.js$/, // add all files that are known to have a shebang, (alternatively could use it for all files)
loader: "shebang-loader",
}
]
},
resolve: {
extensions: [".tsx", ".ts", ".js"],
alias: {
"backend": srcPath('backend'),
.....
},
}
};
module.exports = (env, argv) => {
if (argv.mode === 'development') {
//place specific dev configuration here
}
if (argv.mode === 'production') {
//place specific prod configuration here
}
return config;
}; |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 6 replies
-
While we don't currently have a migration guide for v1 to v2 (we are working on one), we do have a sample for how to use this sdk with webpack. so you might want to take a look at that below. You do the
Please let me know if you have any more questions. |
Beta Was this translation helpful? Give feedback.
-
Hello! Reopening this discussion to make it searchable. |
Beta Was this translation helpful? Give feedback.
No, this is not something that this sdk currently provides. But you can find instructions for creating a layer here. Please let me know if you have any problems with this