Skip to content

feat(core): DockerBuildOptions support network param #34725

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/@aws-cdk/aws-lambda-go-alpha/lib/bundling.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ export class Bundling implements cdk.BundlingOptions {
IMAGE: Runtime.GO_1_X.bundlingImage.image, // always use the GO_1_X build image
},
platform: props.architecture.dockerPlatform,
network: props.network,
})
: cdk.DockerImage.fromRegistry('dummy'); // Do not build if we don't need to

Expand Down
2 changes: 2 additions & 0 deletions packages/@aws-cdk/aws-lambda-go-alpha/test/bundling.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ test('bundling', () => {
environment: {
KEY: 'value',
},
network: 'host',
});

expect(Code.fromAsset).toHaveBeenCalledWith(path.dirname(moduleDir), {
Expand All @@ -65,6 +66,7 @@ test('bundling', () => {
IMAGE: expect.stringMatching(/build-go/),
}),
platform: 'linux/amd64',
network: 'host',
}));
});

Expand Down
12 changes: 6 additions & 6 deletions packages/@aws-cdk/aws-lambda-python-alpha/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -210,12 +210,12 @@ new python.PythonFunction(this, 'function', {
entry,
runtime: Runtime.PYTHON_3_8,
bundling: {
network: 'host',
securityOpt: 'no-new-privileges',
user: 'user:group',
volumesFrom: ['777f7dc92da7'],
volumes: [{ hostPath: '/host-path', containerPath: '/container-path' }],
},
network: 'host',
securityOpt: 'no-new-privileges',
user: 'user:group',
volumesFrom: ['777f7dc92da7'],
volumes: [{ hostPath: '/host-path', containerPath: '/container-path' }],
},
});
```

Expand Down
1 change: 1 addition & 0 deletions packages/@aws-cdk/aws-lambda-python-alpha/lib/bundling.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ export class Bundling implements CdkBundlingOptions {
IMAGE: runtime.bundlingImage.image,
},
platform: architecture.dockerPlatform,
network: props.network,
});
this.command = props.command ?? ['bash', '-c', chain(bundlingCommands)];
this.entrypoint = props.entrypoint;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ test('Bundling a function without dependencies', () => {
entry: entry,
runtime: Runtime.PYTHON_3_7,
architecture: Architecture.X86_64,
network: 'host',
});

// Correctly bundles
Expand All @@ -48,6 +49,7 @@ test('Bundling a function without dependencies', () => {
IMAGE: expect.stringMatching(/build-python/),
}),
platform: 'linux/amd64',
network: 'host',
}));

const files = fs.readdirSync(assetCode.path);
Expand Down Expand Up @@ -426,7 +428,6 @@ test('Bundling with volumes from other container', () => {
entry: entry,
runtime: Runtime.PYTHON_3_7,
volumesFrom: ['777f7dc92da7'],

});

expect(Code.fromAsset).toHaveBeenCalledWith(entry, expect.objectContaining({
Expand All @@ -442,7 +443,6 @@ test('Bundling with custom volume paths', () => {
entry: entry,
runtime: Runtime.PYTHON_3_7,
volumes: [{ hostPath: '/host-path', containerPath: '/container-path' }],

});

expect(Code.fromAsset).toHaveBeenCalledWith(entry, expect.objectContaining({
Expand Down Expand Up @@ -474,7 +474,6 @@ test('Bundling with custom user', () => {
entry: entry,
runtime: Runtime.PYTHON_3_7,
user: 'user:group',

});

expect(Code.fromAsset).toHaveBeenCalledWith(entry, expect.objectContaining({
Expand All @@ -490,7 +489,6 @@ test('Bundling with custom securityOpt', () => {
entry: entry,
runtime: Runtime.PYTHON_3_7,
securityOpt: 'no-new-privileges',

});

expect(Code.fromAsset).toHaveBeenCalledWith(entry, expect.objectContaining({
Expand All @@ -506,7 +504,6 @@ test('Bundling with custom network', () => {
entry: entry,
runtime: Runtime.PYTHON_3_7,
network: 'host',

});

expect(Code.fromAsset).toHaveBeenCalledWith(entry, expect.objectContaining({
Expand All @@ -522,7 +519,6 @@ test('Bundling with docker copy variant', () => {
entry: entry,
runtime: Runtime.PYTHON_3_7,
bundlingFileAccess: BundlingFileAccess.VOLUME_COPY,

});

expect(Code.fromAsset).toHaveBeenCalledWith(entry, expect.objectContaining({
Expand Down
Loading
Loading