Skip to content

buildEnvironment does not pass correct params to build process #15

Open
@timkaas

Description

@timkaas

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 RustFunctions, 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions