From ce7f3d362808fe5b440c247af5482fcc673da631 Mon Sep 17 00:00:00 2001 From: Hsing-Hui Hsu Date: Mon, 12 Nov 2018 23:15:45 -0800 Subject: [PATCH] Remove DockerHub class Removed in favor of using the ecs.ContainerImage.fromDockerHub syntax --- .../hello-cdk-ecs/index.ts | 4 ++- .../hello-cdk-fargate/index.ts | 2 +- packages/@aws-cdk/aws-ecs/README.md | 8 ++--- .../@aws-cdk/aws-ecs/lib/images/dockerhub.ts | 12 ------- .../load-balanced-fargate-service-applet.ts | 4 +-- .../aws-ecs/test/ec2/integ.lb-awsvpc-nw.ts | 4 +-- .../aws-ecs/test/ec2/integ.lb-bridge-nw.ts | 2 +- .../aws-ecs/test/ec2/test.ec2-service.ts | 28 ++++++++-------- .../test/ec2/test.ec2-task-definition.ts | 12 +++---- .../test/fargate/integ.lb-awsvpc-nw.ts | 2 +- .../test/fargate/test.fargate-service.ts | 6 ++-- .../aws-ecs/test/test.container-definition.ts | 32 +++++++++---------- packages/@aws-cdk/aws-ecs/test/test.l3s.ts | 4 +-- 13 files changed, 55 insertions(+), 65 deletions(-) diff --git a/examples/cdk-examples-typescript/hello-cdk-ecs/index.ts b/examples/cdk-examples-typescript/hello-cdk-ecs/index.ts index 9d3c4b0d7d5c8..3723874e96fda 100644 --- a/examples/cdk-examples-typescript/hello-cdk-ecs/index.ts +++ b/examples/cdk-examples-typescript/hello-cdk-ecs/index.ts @@ -22,9 +22,11 @@ class BonjourECS extends cdk.Stack { const ecsService = new ecs.LoadBalancedEc2Service(this, "Ec2Service", { cluster, memoryLimitMiB: 512, - image: ecs.DockerHub.image("amazon/amazon-ecs-sample"), + image: ecs.ContainerImage.fromDockerHub("amazon/amazon-ecs-sample"), }); + // ecsService.addTracing + // Output the DNS where you can access your service new cdk.Output(this, 'LoadBalancerDNS', { value: ecsService.loadBalancer.dnsName }); } diff --git a/examples/cdk-examples-typescript/hello-cdk-fargate/index.ts b/examples/cdk-examples-typescript/hello-cdk-fargate/index.ts index 7df99aec374c3..531584a438e3f 100644 --- a/examples/cdk-examples-typescript/hello-cdk-fargate/index.ts +++ b/examples/cdk-examples-typescript/hello-cdk-fargate/index.ts @@ -14,7 +14,7 @@ class BonjourFargate extends cdk.Stack { // Instantiate Fargate Service with just cluster and image const fargateService = new ecs.LoadBalancedFargateService(this, "FargateService", { cluster, - image: ecs.DockerHub.image("amazon/amazon-ecs-sample"), + image: ecs.ContainerImage.fromDockerHub("amazon/amazon-ecs-sample"), }); // Output the DNS where you can access your service diff --git a/packages/@aws-cdk/aws-ecs/README.md b/packages/@aws-cdk/aws-ecs/README.md index dd405828938c9..b0edeb60cbf34 100644 --- a/packages/@aws-cdk/aws-ecs/README.md +++ b/packages/@aws-cdk/aws-ecs/README.md @@ -166,12 +166,12 @@ const taskDefinition = new ecs.TaskDefinition(this, 'TaskDef', { #### Images Images supply the software that runs inside the container. Images can be -obtained from either DockerHub or from ECR repositories: +obtained from either DockerHub or from ECR repositories, or built directly from a local Dockerfile. * `ecs.ContainerImage.fromDockerHub(imageName)`: use a publicly available image from DockerHub. -* `ecs.ContaienrImage.fromEcrRepository(repo, tag)`: use the given ECR repository as the image - to start. +* `ecs.ContainerImage.fromEcrRepository(repo, tag)`: use the given ECR repository as the image + to start. If no tag is provided, "latest" is assumed. * `ecs.ContainerImage.fromAsset(this, 'Image', { directory: './image' })`: build and upload an image directly from a `Dockerfile` in your source directory. @@ -240,4 +240,4 @@ EC2 instance group so that your instance count scales with demand. - [ ] Instance AutoScaling - [ ] Service Discovery Integration -- [ ] Private registry authentication \ No newline at end of file +- [ ] Private registry authentication diff --git a/packages/@aws-cdk/aws-ecs/lib/images/dockerhub.ts b/packages/@aws-cdk/aws-ecs/lib/images/dockerhub.ts index d0bb48bd357a1..2b4d04a9f876b 100644 --- a/packages/@aws-cdk/aws-ecs/lib/images/dockerhub.ts +++ b/packages/@aws-cdk/aws-ecs/lib/images/dockerhub.ts @@ -1,18 +1,6 @@ import { ContainerDefinition } from "../container-definition"; import { IContainerImage } from "../container-image"; -/** - * Factory for DockerHub images - */ -export class DockerHub { - /** - * Reference an image on DockerHub - */ - public static image(name: string): IContainerImage { - return new DockerHubImage(name); - } -} - /** * A DockerHub image */ diff --git a/packages/@aws-cdk/aws-ecs/lib/load-balanced-fargate-service-applet.ts b/packages/@aws-cdk/aws-ecs/lib/load-balanced-fargate-service-applet.ts index 1049a19bf7645..894977f9ed172 100644 --- a/packages/@aws-cdk/aws-ecs/lib/load-balanced-fargate-service-applet.ts +++ b/packages/@aws-cdk/aws-ecs/lib/load-balanced-fargate-service-applet.ts @@ -1,7 +1,7 @@ import ec2 = require('@aws-cdk/aws-ec2'); import cdk = require('@aws-cdk/cdk'); import { Cluster } from './cluster'; -import { DockerHub } from './images/dockerhub'; +import { ContainerImage } from './container-image'; import { LoadBalancedFargateService } from './load-balanced-fargate-service'; /** @@ -97,7 +97,7 @@ export class LoadBalancedFargateServiceApplet extends cdk.Stack { memoryMiB: props.memoryMiB, publicLoadBalancer: props.publicLoadBalancer, publicTasks: props.publicTasks, - image: DockerHub.image(props.image), + image: ContainerImage.fromDockerHub(props.image), desiredCount: props.desiredCount, }); } diff --git a/packages/@aws-cdk/aws-ecs/test/ec2/integ.lb-awsvpc-nw.ts b/packages/@aws-cdk/aws-ecs/test/ec2/integ.lb-awsvpc-nw.ts index b40be9b57e319..eb658343bf09b 100644 --- a/packages/@aws-cdk/aws-ecs/test/ec2/integ.lb-awsvpc-nw.ts +++ b/packages/@aws-cdk/aws-ecs/test/ec2/integ.lb-awsvpc-nw.ts @@ -19,7 +19,7 @@ const taskDefinition = new ecs.Ec2TaskDefinition(stack, 'TaskDef', { }); const container = taskDefinition.addContainer('web', { - image: ecs.DockerHub.image("amazon/amazon-ecs-sample"), + image: ecs.ContainerImage.fromDockerHub("amazon/amazon-ecs-sample"), memoryLimitMiB: 256, }); @@ -42,4 +42,4 @@ listener.addTargets('ECS', { new cdk.Output(stack, 'LoadBalancerDNS', { value: lb.dnsName, }); -app.run(); \ No newline at end of file +app.run(); diff --git a/packages/@aws-cdk/aws-ecs/test/ec2/integ.lb-bridge-nw.ts b/packages/@aws-cdk/aws-ecs/test/ec2/integ.lb-bridge-nw.ts index 2d8cf306f3886..50492fa437e05 100644 --- a/packages/@aws-cdk/aws-ecs/test/ec2/integ.lb-bridge-nw.ts +++ b/packages/@aws-cdk/aws-ecs/test/ec2/integ.lb-bridge-nw.ts @@ -21,7 +21,7 @@ const taskDefinition = new ecs.Ec2TaskDefinition(stack, 'TaskDef', { }); const container = taskDefinition.addContainer('web', { - image: ecs.DockerHub.image("amazon/amazon-ecs-sample"), + image: ecs.ContainerImage.fromDockerHub("amazon/amazon-ecs-sample"), memoryLimitMiB: 256, }); container.addPortMappings({ diff --git a/packages/@aws-cdk/aws-ecs/test/ec2/test.ec2-service.ts b/packages/@aws-cdk/aws-ecs/test/ec2/test.ec2-service.ts index 93a0fa4dc4b7f..236264838461c 100644 --- a/packages/@aws-cdk/aws-ecs/test/ec2/test.ec2-service.ts +++ b/packages/@aws-cdk/aws-ecs/test/ec2/test.ec2-service.ts @@ -17,7 +17,7 @@ export = { const taskDefinition = new ecs.Ec2TaskDefinition(stack, 'Ec2TaskDef'); taskDefinition.addContainer("web", { - image: ecs.DockerHub.image("amazon/amazon-ecs-sample"), + image: ecs.ContainerImage.fromDockerHub("amazon/amazon-ecs-sample"), memoryLimitMiB: 512 }); @@ -97,7 +97,7 @@ export = { const taskDefinition = new ecs.Ec2TaskDefinition(stack, 'Ec2TaskDef'); taskDefinition.addContainer("web", { - image: ecs.DockerHub.image("amazon/amazon-ecs-sample"), + image: ecs.ContainerImage.fromDockerHub("amazon/amazon-ecs-sample"), memoryLimitMiB: 512 }); @@ -127,7 +127,7 @@ export = { }); taskDefinition.addContainer("web", { - image: ecs.DockerHub.image("amazon/amazon-ecs-sample"), + image: ecs.ContainerImage.fromDockerHub("amazon/amazon-ecs-sample"), memoryLimitMiB: 512 }); @@ -159,7 +159,7 @@ export = { }); taskDefinition.addContainer("web", { - image: ecs.DockerHub.image("amazon/amazon-ecs-sample"), + image: ecs.ContainerImage.fromDockerHub("amazon/amazon-ecs-sample"), memoryLimitMiB: 512 }); @@ -210,7 +210,7 @@ export = { }); taskDefinition.addContainer("web", { - image: ecs.DockerHub.image("amazon/amazon-ecs-sample"), + image: ecs.ContainerImage.fromDockerHub("amazon/amazon-ecs-sample"), memoryLimitMiB: 512 }); @@ -236,7 +236,7 @@ export = { const taskDefinition = new ecs.Ec2TaskDefinition(stack, 'Ec2TaskDef'); taskDefinition.addContainer("web", { - image: ecs.DockerHub.image("amazon/amazon-ecs-sample"), + image: ecs.ContainerImage.fromDockerHub("amazon/amazon-ecs-sample"), memoryLimitMiB: 512 }); @@ -265,7 +265,7 @@ export = { const taskDefinition = new ecs.Ec2TaskDefinition(stack, 'Ec2TaskDef'); taskDefinition.addContainer("web", { - image: ecs.DockerHub.image("amazon/amazon-ecs-sample"), + image: ecs.ContainerImage.fromDockerHub("amazon/amazon-ecs-sample"), memoryLimitMiB: 512 }); @@ -296,7 +296,7 @@ export = { const taskDefinition = new ecs.Ec2TaskDefinition(stack, 'Ec2TaskDef'); taskDefinition.addContainer("web", { - image: ecs.DockerHub.image("amazon/amazon-ecs-sample"), + image: ecs.ContainerImage.fromDockerHub("amazon/amazon-ecs-sample"), memoryLimitMiB: 512 }); @@ -327,7 +327,7 @@ export = { const taskDefinition = new ecs.Ec2TaskDefinition(stack, 'Ec2TaskDef'); taskDefinition.addContainer("web", { - image: ecs.DockerHub.image("amazon/amazon-ecs-sample"), + image: ecs.ContainerImage.fromDockerHub("amazon/amazon-ecs-sample"), memoryLimitMiB: 512 }); @@ -354,7 +354,7 @@ export = { const taskDefinition = new ecs.Ec2TaskDefinition(stack, 'Ec2TaskDef'); taskDefinition.addContainer("web", { - image: ecs.DockerHub.image("amazon/amazon-ecs-sample"), + image: ecs.ContainerImage.fromDockerHub("amazon/amazon-ecs-sample"), memoryLimitMiB: 512 }); @@ -384,7 +384,7 @@ export = { const taskDefinition = new ecs.Ec2TaskDefinition(stack, 'Ec2TaskDef'); taskDefinition.addContainer("web", { - image: ecs.DockerHub.image("amazon/amazon-ecs-sample"), + image: ecs.ContainerImage.fromDockerHub("amazon/amazon-ecs-sample"), memoryLimitMiB: 512 }); @@ -411,7 +411,7 @@ export = { const taskDefinition = new ecs.Ec2TaskDefinition(stack, 'Ec2TaskDef'); taskDefinition.addContainer("web", { - image: ecs.DockerHub.image("amazon/amazon-ecs-sample"), + image: ecs.ContainerImage.fromDockerHub("amazon/amazon-ecs-sample"), memoryLimitMiB: 512 }); @@ -442,7 +442,7 @@ export = { const taskDefinition = new ecs.Ec2TaskDefinition(stack, 'Ec2TaskDef'); taskDefinition.addContainer("web", { - image: ecs.DockerHub.image("amazon/amazon-ecs-sample"), + image: ecs.ContainerImage.fromDockerHub("amazon/amazon-ecs-sample"), memoryLimitMiB: 512 }); @@ -470,7 +470,7 @@ export = { cluster.addDefaultAutoScalingGroupCapacity({ instanceType: new ec2.InstanceType('t2.micro') }); const taskDefinition = new ecs.Ec2TaskDefinition(stack, 'TD', { networkMode: ecs.NetworkMode.Host }); const container = taskDefinition.addContainer('web', { - image: ecs.DockerHub.image('test'), + image: ecs.ContainerImage.fromDockerHub('test'), memoryLimitMiB: 1024, }); container.addPortMappings({ containerPort: 808 }); diff --git a/packages/@aws-cdk/aws-ecs/test/ec2/test.ec2-task-definition.ts b/packages/@aws-cdk/aws-ecs/test/ec2/test.ec2-task-definition.ts index 5b57fc043e16d..47bbfdff14e6a 100644 --- a/packages/@aws-cdk/aws-ecs/test/ec2/test.ec2-task-definition.ts +++ b/packages/@aws-cdk/aws-ecs/test/ec2/test.ec2-task-definition.ts @@ -48,7 +48,7 @@ export = { const taskDefinition = new ecs.Ec2TaskDefinition(stack, 'Ec2TaskDef'); const container = taskDefinition.addContainer("web", { - image: ecs.DockerHub.image("amazon/amazon-ecs-sample"), + image: ecs.ContainerImage.fromDockerHub("amazon/amazon-ecs-sample"), memoryLimitMiB: 512 // add validation? }); @@ -104,7 +104,7 @@ export = { const taskDefinition = new ecs.Ec2TaskDefinition(stack, 'Ec2TaskDef'); const container = taskDefinition.addContainer("web", { - image: ecs.DockerHub.image("amazon/amazon-ecs-sample"), + image: ecs.ContainerImage.fromDockerHub("amazon/amazon-ecs-sample"), memoryLimitMiB: 512 }); @@ -154,7 +154,7 @@ export = { }); const container = taskDefinition.addContainer("web", { - image: ecs.DockerHub.image("amazon/amazon-ecs-sample"), + image: ecs.ContainerImage.fromDockerHub("amazon/amazon-ecs-sample"), memoryLimitMiB: 512 }); @@ -200,7 +200,7 @@ export = { taskDefinition.addContainer("web", { memoryLimitMiB: 1024, - image: ecs.DockerHub.image("amazon/amazon-ecs-sample") + image: ecs.ContainerImage.fromDockerHub("amazon/amazon-ecs-sample") }); // THEN @@ -226,7 +226,7 @@ export = { // }); // taskDefinition.addContainer("web", { - // image: ecs.DockerHub.image("amazon/amazon-ecs-sample"), + // image: ecs.ContainerImage.fromDockerHub("amazon/amazon-ecs-sample"), // memoryLimitMiB: 512 // }); @@ -243,7 +243,7 @@ export = { // const stack = new cdk.Stack(); // const taskDefinition = new ecs.Ec2TaskDefinition(stack, 'Ec2TaskDef', {}); // const container = taskDefinition.addContainer("web", { - // image: ecs.DockerHub.image("amazon/amazon-ecs-sample"), + // image: ecs.ContainerImage.fromDockerHub("amazon/amazon-ecs-sample"), // memoryLimitMiB: 512 // add validation? // }); diff --git a/packages/@aws-cdk/aws-ecs/test/fargate/integ.lb-awsvpc-nw.ts b/packages/@aws-cdk/aws-ecs/test/fargate/integ.lb-awsvpc-nw.ts index dd0d9343455b7..1c3c05fcbd121 100644 --- a/packages/@aws-cdk/aws-ecs/test/fargate/integ.lb-awsvpc-nw.ts +++ b/packages/@aws-cdk/aws-ecs/test/fargate/integ.lb-awsvpc-nw.ts @@ -16,7 +16,7 @@ const taskDefinition = new ecs.FargateTaskDefinition(stack, 'TaskDef', { }); const container = taskDefinition.addContainer('web', { - image: ecs.DockerHub.image("amazon/amazon-ecs-sample"), + image: ecs.ContainerImage.fromDockerHub("amazon/amazon-ecs-sample"), }); container.addPortMappings({ diff --git a/packages/@aws-cdk/aws-ecs/test/fargate/test.fargate-service.ts b/packages/@aws-cdk/aws-ecs/test/fargate/test.fargate-service.ts index 42c2a83ac7482..b3405a54ac9dd 100644 --- a/packages/@aws-cdk/aws-ecs/test/fargate/test.fargate-service.ts +++ b/packages/@aws-cdk/aws-ecs/test/fargate/test.fargate-service.ts @@ -14,7 +14,7 @@ export = { const taskDefinition = new ecs.FargateTaskDefinition(stack, 'FargateTaskDef'); taskDefinition.addContainer("web", { - image: ecs.DockerHub.image("amazon/amazon-ecs-sample"), + image: ecs.ContainerImage.fromDockerHub("amazon/amazon-ecs-sample"), }); new ecs.FargateService(stack, "FargateService", { @@ -107,7 +107,7 @@ export = { const taskDefinition = new ecs.FargateTaskDefinition(stack, 'FargateTaskDef'); taskDefinition.addContainer("web", { - image: ecs.DockerHub.image("amazon/amazon-ecs-sample"), + image: ecs.ContainerImage.fromDockerHub("amazon/amazon-ecs-sample"), }); new ecs.FargateService(stack, "FargateService", { @@ -128,4 +128,4 @@ export = { test.done(); }, } -}; \ No newline at end of file +}; diff --git a/packages/@aws-cdk/aws-ecs/test/test.container-definition.ts b/packages/@aws-cdk/aws-ecs/test/test.container-definition.ts index 63f7197d4edc3..95eb16f901a94 100644 --- a/packages/@aws-cdk/aws-ecs/test/test.container-definition.ts +++ b/packages/@aws-cdk/aws-ecs/test/test.container-definition.ts @@ -15,7 +15,7 @@ export = { }); const container = taskDefinition.addContainer("Container", { - image: ecs.DockerHub.image("/aws/aws-example-app"), + image: ecs.ContainerImage.fromDockerHub("/aws/aws-example-app"), memoryLimitMiB: 2048, }); @@ -38,7 +38,7 @@ export = { }); const container = taskDefinition.addContainer("Container", { - image: ecs.DockerHub.image("/aws/aws-example-app"), + image: ecs.ContainerImage.fromDockerHub("/aws/aws-example-app"), memoryLimitMiB: 2048, }); @@ -61,7 +61,7 @@ export = { }); const container = taskDefinition.addContainer("Container", { - image: ecs.DockerHub.image("/aws/aws-example-app"), + image: ecs.ContainerImage.fromDockerHub("/aws/aws-example-app"), memoryLimitMiB: 2048, }); @@ -84,7 +84,7 @@ export = { }); const container = taskDefinition.addContainer("Container", { - image: ecs.DockerHub.image("/aws/aws-example-app"), + image: ecs.ContainerImage.fromDockerHub("/aws/aws-example-app"), memoryLimitMiB: 2048, }); @@ -105,12 +105,12 @@ export = { }); const container = taskDefinition.addContainer("Container", { - image: ecs.DockerHub.image("/aws/aws-example-app"), + image: ecs.ContainerImage.fromDockerHub("/aws/aws-example-app"), memoryLimitMiB: 2048, }); const logger = taskDefinition.addContainer("LoggingContainer", { - image: ecs.DockerHub.image("myLogger"), + image: ecs.ContainerImage.fromDockerHub("myLogger"), memoryLimitMiB: 1024, }); @@ -132,12 +132,12 @@ export = { }); const container = taskDefinition.addContainer("Container", { - image: ecs.DockerHub.image("/aws/aws-example-app"), + image: ecs.ContainerImage.fromDockerHub("/aws/aws-example-app"), memoryLimitMiB: 2048, }); const logger = taskDefinition.addContainer("LoggingContainer", { - image: ecs.DockerHub.image("myLogger"), + image: ecs.ContainerImage.fromDockerHub("myLogger"), memoryLimitMiB: 1024, }); @@ -159,7 +159,7 @@ export = { }); const container = taskDefinition.addContainer("Container", { - image: ecs.DockerHub.image("/aws/aws-example-app"), + image: ecs.ContainerImage.fromDockerHub("/aws/aws-example-app"), memoryLimitMiB: 2048, }); @@ -184,7 +184,7 @@ export = { }); const container = taskDefinition.addContainer("Container", { - image: ecs.DockerHub.image("/aws/aws-example-app"), + image: ecs.ContainerImage.fromDockerHub("/aws/aws-example-app"), memoryLimitMiB: 2048, }); @@ -210,7 +210,7 @@ export = { }); const container = taskDefinition.addContainer("Container", { - image: ecs.DockerHub.image("/aws/aws-example-app"), + image: ecs.ContainerImage.fromDockerHub("/aws/aws-example-app"), memoryLimitMiB: 2048, }); @@ -235,7 +235,7 @@ export = { }); const container = taskDefinition.addContainer("Container", { - image: ecs.DockerHub.image("/aws/aws-example-app"), + image: ecs.ContainerImage.fromDockerHub("/aws/aws-example-app"), memoryLimitMiB: 2048, }); @@ -260,7 +260,7 @@ export = { // WHEN taskDefinition.addContainer('cont', { - image: ecs.DockerHub.image('test'), + image: ecs.ContainerImage.fromDockerHub('test'), memoryLimitMiB: 1024, logging: new ecs.AwsLogDriver(stack, 'Logging', { streamPrefix: 'prefix' }) }); @@ -291,7 +291,7 @@ export = { // WHEN taskDefinition.addContainer('cont', { - image: ecs.DockerHub.image('test'), + image: ecs.ContainerImage.fromDockerHub('test'), memoryLimitMiB: 1024, healthCheck: { command: [hcCommand] @@ -323,7 +323,7 @@ export = { // WHEN taskDefinition.addContainer('cont', { - image: ecs.DockerHub.image('test'), + image: ecs.ContainerImage.fromDockerHub('test'), memoryLimitMiB: 1024, healthCheck: { command: [hcCommand], @@ -352,4 +352,4 @@ export = { }, // render extra hosts test -}; \ No newline at end of file +}; diff --git a/packages/@aws-cdk/aws-ecs/test/test.l3s.ts b/packages/@aws-cdk/aws-ecs/test/test.l3s.ts index 9ef60be7cba3d..3d9f6d29dc599 100644 --- a/packages/@aws-cdk/aws-ecs/test/test.l3s.ts +++ b/packages/@aws-cdk/aws-ecs/test/test.l3s.ts @@ -16,7 +16,7 @@ export = { new ecs.LoadBalancedEc2Service(stack, 'Service', { cluster, memoryLimitMiB: 1024, - image: ecs.DockerHub.image('test'), + image: ecs.ContainerImage.fromDockerHub('test'), desiredCount: 2 }); @@ -40,7 +40,7 @@ export = { // WHEN new ecs.LoadBalancedFargateService(stack, 'Service', { cluster, - image: ecs.DockerHub.image('test'), + image: ecs.ContainerImage.fromDockerHub('test'), desiredCount: 2 });