Skip to content
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
58 changes: 57 additions & 1 deletion __tests__/validations.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1582,13 +1582,69 @@ describe('Validations Tests', () => {
};
return inputs[name] || '';
});

const result = originalValidations.validateAllInputs();
expect(result.valid).toBe(true);
// Check that warning was not called for S3 parameters
expect(core.warning).not.toHaveBeenCalledWith(expect.stringContaining('s3-bucket'));
expect(core.warning).not.toHaveBeenCalledWith(expect.stringContaining('s3-key'));
});

test('should warn when handler/runtime/layers are provided with Image package type', () => {
core.getInput.mockImplementation((name) => {
const inputs = {
'function-name': 'test-function',
'package-type': 'Image',
'image-uri': '123456789012.dkr.ecr.us-east-1.amazonaws.com/my-repo:latest',
'handler': 'index.handler',
'runtime': 'nodejs20.x',
'layers': '["arn:aws:lambda:us-east-1:123456789012:layer:my-layer:1"]',
'region': 'us-east-1'
};
return inputs[name] || '';
});

const result = originalValidations.validateAllInputs();
expect(result.valid).toBe(true);
expect(core.warning).toHaveBeenCalledWith(expect.stringContaining('handler parameter is ignored when package-type is "Image"'));
expect(core.warning).toHaveBeenCalledWith(expect.stringContaining('runtime parameter is ignored when package-type is "Image"'));
expect(core.warning).toHaveBeenCalledWith(expect.stringContaining('layers parameter is ignored when package-type is "Image"'));
});

test('should not warn about handler/runtime/layers when not provided with Image package type', () => {
core.getInput.mockImplementation((name) => {
const inputs = {
'function-name': 'test-function',
'package-type': 'Image',
'image-uri': '123456789012.dkr.ecr.us-east-1.amazonaws.com/my-repo:latest',
'region': 'us-east-1'
};
return inputs[name] || '';
});

const result = originalValidations.validateAllInputs();
expect(result.valid).toBe(true);
expect(core.warning).not.toHaveBeenCalledWith(expect.stringContaining('handler parameter is ignored'));
expect(core.warning).not.toHaveBeenCalledWith(expect.stringContaining('runtime parameter is ignored'));
expect(core.warning).not.toHaveBeenCalledWith(expect.stringContaining('layers parameter is ignored'));
});

test('should warn when image-config is provided with Zip package type', () => {
core.getInput.mockImplementation((name) => {
const inputs = {
'function-name': 'test-function',
'package-type': 'Zip',
'code-artifacts-dir': './artifacts',
'image-config': '{"Command":["app.handler"]}',
'region': 'us-east-1'
};
return inputs[name] || '';
});

const result = originalValidations.validateAllInputs();
expect(result.valid).toBe(true);
expect(core.warning).toHaveBeenCalledWith('image-config parameter is ignored when package-type is "Zip"');
});
});

describe('Early Return on Invalid Inputs', () => {
Expand Down
6 changes: 2 additions & 4 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,11 @@ inputs:
description: 'The path to a directory of code artifacts to zip and deploy to Lambda. Required when package-type is "Zip".'
required: false
handler:
description: 'The name of the method within your code that Lambda calls to run your function. Required when package-type is "Zip".'
description: 'The name of the method within your code that Lambda calls to run your function. Required when package-type is "Zip". Defaults to "index.handler" when omitted.'
required: false
default: 'index.handler'
runtime:
description: 'The identifier of the runtime. Required when package-type is "Zip".'
description: 'The identifier of the runtime. Required when package-type is "Zip". Defaults to "nodejs20.x" when omitted.'
required: false
default: 'nodejs20.x'
s3-bucket:
description: 'S3 bucket name to use for Lambda deployment package. If provided, S3 deployment method will be used instead of direct upload.'
required: false
Expand Down
21 changes: 20 additions & 1 deletion dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -98237,7 +98237,7 @@ function validateAndResolvePath(userPath, basePath) {
function checkInputConflicts(packageType, additionalInputs) {
const { s3Bucket, s3Key } = additionalInputs;
const sourceKmsKeyArn = core.getInput('source-kms-key-arn', { required: false });

if (packageType === 'Image') {
// Warn about S3-related parameters being ignored for Image package type
if (s3Bucket) {
Expand All @@ -98249,6 +98249,25 @@ function checkInputConflicts(packageType, additionalInputs) {
if (sourceKmsKeyArn) {
core.warning('source-kms-key-arn parameter is ignored when package-type is "Image"');
}
// Warn about Zip-only parameters being ignored for Image package type.
// For container image functions, the runtime, handler, and layers are
// baked into the image itself, so any value supplied here would be
// silently dropped without these warnings.
if (core.getInput('handler', { required: false })) {
core.warning('handler parameter is ignored when package-type is "Image"; the handler is determined by the container image');
}
if (core.getInput('runtime', { required: false })) {
core.warning('runtime parameter is ignored when package-type is "Image"; the runtime is determined by the container image');
}
if (core.getInput('layers', { required: false })) {
core.warning('layers parameter is ignored when package-type is "Image"; layers are not supported for container image functions');
}
} else if (packageType === 'Zip') {
// Warn about Image-only parameters being ignored for Zip package type.
// image-uri is already warned about in validateRequiredInputs.
if (core.getInput('image-config', { required: false })) {
core.warning('image-config parameter is ignored when package-type is "Zip"');
}
}
}

Expand Down
21 changes: 20 additions & 1 deletion validations.js
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ function validateAndResolvePath(userPath, basePath) {
function checkInputConflicts(packageType, additionalInputs) {
const { s3Bucket, s3Key } = additionalInputs;
const sourceKmsKeyArn = core.getInput('source-kms-key-arn', { required: false });

if (packageType === 'Image') {
// Warn about S3-related parameters being ignored for Image package type
if (s3Bucket) {
Expand All @@ -362,6 +362,25 @@ function checkInputConflicts(packageType, additionalInputs) {
if (sourceKmsKeyArn) {
core.warning('source-kms-key-arn parameter is ignored when package-type is "Image"');
}
// Warn about Zip-only parameters being ignored for Image package type.
// For container image functions, the runtime, handler, and layers are
// baked into the image itself, so any value supplied here would be
// silently dropped without these warnings.
if (core.getInput('handler', { required: false })) {
core.warning('handler parameter is ignored when package-type is "Image"; the handler is determined by the container image');
}
if (core.getInput('runtime', { required: false })) {
core.warning('runtime parameter is ignored when package-type is "Image"; the runtime is determined by the container image');
}
if (core.getInput('layers', { required: false })) {
core.warning('layers parameter is ignored when package-type is "Image"; layers are not supported for container image functions');
}
} else if (packageType === 'Zip') {
// Warn about Image-only parameters being ignored for Zip package type.
// image-uri is already warned about in validateRequiredInputs.
if (core.getInput('image-config', { required: false })) {
core.warning('image-config parameter is ignored when package-type is "Zip"');
}
}
}

Expand Down