Open
Description
Using the latest build 1.2.1, it seems that specifying buildEnvironment as a param to multiple RustFunction instances causes only the first passed env vars for the first hit RustFunction instance to be passed for all following creations of RustFunction.
Minimum example:
const foo_lambda = new RustFunction(this, 'foo_lambda', {
directory: path.resolve(path.join(__dirname, '../lambda')),
package: 'foo',
buildEnvironment: {
FOO_ENV: 'foo',
},
})
const bar_lambda = new RustFunction(this, 'bar_lambda', {
directory: path.resolve(path.join(__dirname, '../lambda')),
package: 'bar',
buildEnvironment: {
BAR_ENV: 'bar'
},
})
With the rust code doing e.g.:
const FOO_ENV: &str = env!("FOO_ENV");
const BAR_ENV: &str = env!("BAR_ENV");
I'm getting the error when compiling the second rust functionenvironment variable "BAR_ENV" not defined
, however - the FOO_ENV is available for the second function. If reversing the order of the two RustFunction
s, now BAR_ENV is available, and compilation will fail with FOO_ENV not defined.
This issue can be worked-around by building each package individually by doing:
import { Settings } from 'rust.aws-cdk-lambda'
Settings.BUILD_INDIVIDUALLY = true