Skip to content
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

fix(ecs): remove unnecessary error when adding volume to external task definition #19774

Merged
merged 1 commit into from
Apr 5, 2022
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import {
ITaskDefinition,
NetworkMode,
TaskDefinition,
Volume,
} from '../base/task-definition';

/**
Expand Down Expand Up @@ -75,13 +74,6 @@ export class ExternalTaskDefinition extends TaskDefinition implements IExternalT
});
}

/**
* Overridden method to throw error, as volumes are not supported for external task definitions
*/
public addVolume(_volume: Volume) {
throw new Error('External task definitions doesnt support volumes');
}

/**
* Overriden method to throw error as interface accelerators are not supported for external tasks
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -601,17 +601,30 @@ describe('external task definition', () => {
Annotations.fromStack(stack).hasWarning('/Default/ExternalTaskDef/web', "Proper policies need to be attached before pulling from ECR repository, or use 'fromEcrRepository'.");
});

test('correctly sets volumes from', () => {
test('correctly sets volumes', () => {
// GIVEN
const stack = new cdk.Stack();
const taskDefinition = new ecs.ExternalTaskDefinition(stack, 'ExternalTaskDef', {});

// THEN
expect(() => taskDefinition.addVolume({
// WHEN
taskDefinition.addVolume({
host: {
sourcePath: '/tmp/cache',
},
name: 'scratch',
})).toThrow('External task definitions doesnt support volumes' );
});

// THEN
Template.fromStack(stack).hasResourceProperties('AWS::ECS::TaskDefinition', {
Volumes: [
{
Host: {
SourcePath: '/tmp/cache',
},
Name: 'scratch',
},
],
});
});

test('error when interferenceAccelerators set', () => {
Expand Down