Skip to content

Commit

Permalink
fix(ecs): remove unneccessary error when adding volume to external ta…
Browse files Browse the repository at this point in the history
…sk definition
  • Loading branch information
peterwoodworth committed Apr 5, 2022
1 parent 2550589 commit 85fde5c
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 12 deletions.
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

0 comments on commit 85fde5c

Please sign in to comment.