diff --git a/packages/@aws-cdk/aws-ecs-patterns/lib/fargate/load-balanced-fargate-service-applet.ts b/packages/@aws-cdk/aws-ecs-patterns/lib/fargate/load-balanced-fargate-service-applet.ts deleted file mode 100644 index abd7389b08217..0000000000000 --- a/packages/@aws-cdk/aws-ecs-patterns/lib/fargate/load-balanced-fargate-service-applet.ts +++ /dev/null @@ -1,148 +0,0 @@ -import { Certificate } from '@aws-cdk/aws-certificatemanager'; -import { Vpc } from '@aws-cdk/aws-ec2'; -import { Cluster, ContainerImage } from '@aws-cdk/aws-ecs'; -import { HostedZoneProvider } from '@aws-cdk/aws-route53'; -import cdk = require('@aws-cdk/cdk'); -import { LoadBalancedFargateService } from './load-balanced-fargate-service'; - -/** - * Properties for a LoadBalancedEcsServiceApplet - */ -export interface LoadBalancedFargateServiceAppletProps extends cdk.StackProps { - /** - * The image to start (from DockerHub) - */ - readonly image: string; - - /** - * The number of cpu units used by the task. - * Valid values, which determines your range of valid values for the memory parameter: - * 256 (.25 vCPU) - Available memory values: 0.5GB, 1GB, 2GB - * 512 (.5 vCPU) - Available memory values: 1GB, 2GB, 3GB, 4GB - * 1024 (1 vCPU) - Available memory values: 2GB, 3GB, 4GB, 5GB, 6GB, 7GB, 8GB - * 2048 (2 vCPU) - Available memory values: Between 4GB and 16GB in 1GB increments - * 4096 (4 vCPU) - Available memory values: Between 8GB and 30GB in 1GB increments - * - * This default is set in the underlying FargateTaskDefinition construct. - * - * @default 256 - */ - readonly cpu?: string; - - /** - * The amount (in MiB) of memory used by the task. - * - * This field is required and you must use one of the following values, which determines your range of valid values - * for the cpu parameter: - * - * 0.5GB, 1GB, 2GB - Available cpu values: 256 (.25 vCPU) - * - * 1GB, 2GB, 3GB, 4GB - Available cpu values: 512 (.5 vCPU) - * - * 2GB, 3GB, 4GB, 5GB, 6GB, 7GB, 8GB - Available cpu values: 1024 (1 vCPU) - * - * Between 4GB and 16GB in 1GB increments - Available cpu values: 2048 (2 vCPU) - * - * Between 8GB and 30GB in 1GB increments - Available cpu values: 4096 (4 vCPU) - * - * This default is set in the underlying FargateTaskDefinition construct. - * - * @default 512 - */ - readonly memoryMiB?: string; - - /** - * The container port of the application load balancer attached to your Fargate service. Corresponds to container port mapping. - * - * @default 80 - */ - readonly containerPort?: number; - - /** - * Determines whether the Application Load Balancer will be internet-facing - * - * @default true - */ - readonly publicLoadBalancer?: boolean; - - /** - * Determines whether your Fargate Service will be assigned a public IP address. - * - * @default false - */ - readonly publicTasks?: boolean; - - /** - * Number of desired copies of running tasks - * - * @default 1 - */ - readonly desiredCount?: number; - - /** - * Domain name for the service, e.g. api.example.com - * - * @default - No domain name. - */ - readonly domainName?: string; - - /** - * Route53 hosted zone for the domain, e.g. "example.com." - * - * @default - No Route53 hosted domain zone. - */ - readonly domainZone?: string; - - /** - * Certificate Manager certificate to associate with the load balancer. - * Setting this option will set the load balancer port to 443. - * - * @default - No certificate associated with the load balancer. - */ - readonly certificate?: string; - - /** - * Environment variables to pass to the container - * - * @default - No environment variables. - */ - readonly environment?: { [key: string]: string }; -} - -/** - * An applet for a LoadBalancedFargateService. Sets up a Fargate service, Application - * load balancer, ECS cluster, VPC, and (optionally) Route53 alias record. - */ -export class LoadBalancedFargateServiceApplet extends cdk.Stack { - constructor(scope: cdk.Construct, id: string, props: LoadBalancedFargateServiceAppletProps) { - super(scope, id, props); - - const vpc = new Vpc(this, 'MyVpc', { maxAZs: 2 }); - const cluster = new Cluster(this, 'Cluster', { vpc }); - - let domainZone; - if (props.domainZone) { - domainZone = new HostedZoneProvider(this, { domainName: props.domainZone }).findAndImport(this, 'Zone'); - } - let certificate; - if (props.certificate) { - certificate = Certificate.fromCertificateArn(this, 'Cert', props.certificate); - } - - // Instantiate Fargate Service with just cluster and image - new LoadBalancedFargateService(this, "FargateService", { - cluster, - cpu: props.cpu, - containerPort: props.containerPort, - memoryMiB: props.memoryMiB, - publicLoadBalancer: props.publicLoadBalancer, - publicTasks: props.publicTasks, - image: ContainerImage.fromRegistry(props.image), - desiredCount: props.desiredCount, - environment: props.environment, - certificate, - domainName: props.domainName, - domainZone - }); - } -} \ No newline at end of file diff --git a/packages/@aws-cdk/aws-ecs-patterns/lib/index.ts b/packages/@aws-cdk/aws-ecs-patterns/lib/index.ts index 7024ffd79b2ff..b8ec155b6ffd9 100644 --- a/packages/@aws-cdk/aws-ecs-patterns/lib/index.ts +++ b/packages/@aws-cdk/aws-ecs-patterns/lib/index.ts @@ -4,7 +4,6 @@ export * from './base/queue-worker-service-base'; export * from './ecs/load-balanced-ecs-service'; export * from './fargate/load-balanced-fargate-service'; -export * from './fargate/load-balanced-fargate-service-applet'; export * from './base/load-balanced-service-base'; export * from './ecs/scheduled-ecs-task'; diff --git a/packages/@aws-cdk/aws-ecs-patterns/test/ec2/test.l3s.ts b/packages/@aws-cdk/aws-ecs-patterns/test/ec2/test.l3s.ts index 40f382919ee23..dae71312eb660 100644 --- a/packages/@aws-cdk/aws-ecs-patterns/test/ec2/test.l3s.ts +++ b/packages/@aws-cdk/aws-ecs-patterns/test/ec2/test.l3s.ts @@ -249,95 +249,4 @@ export = { test.done(); }, - - 'test Fargateloadbalanced applet'(test: Test) { - // WHEN - const app = new cdk.App(); - const stack = new ecsPatterns.LoadBalancedFargateServiceApplet(app, 'Service', { - image: 'test', - desiredCount: 2, - environment: { - TEST_ENVIRONMENT_VARIABLE1: "test environment variable 1 value", - TEST_ENVIRONMENT_VARIABLE2: "test environment variable 2 value" - } - }); - - // THEN - stack contains a load balancer and a service - expect(stack).to(haveResource('AWS::ElasticLoadBalancingV2::LoadBalancer')); - - expect(stack).to(haveResource("AWS::ECS::Service", { - DesiredCount: 2, - LaunchType: "FARGATE", - })); - - expect(stack).to(haveResourceLike('AWS::ECS::TaskDefinition', { - ContainerDefinitions: [ - { - Environment: [ - { - Name: "TEST_ENVIRONMENT_VARIABLE1", - Value: "test environment variable 1 value" - }, - { - Name: "TEST_ENVIRONMENT_VARIABLE2", - Value: "test environment variable 2 value" - } - ], - } - ] - })); - - test.done(); - }, - - 'test Fargateloadbalanced applet with TLS'(test: Test) { - // WHEN - const app = new cdk.App(); - const stack = new ecsPatterns.LoadBalancedFargateServiceApplet(app, 'Service', { - image: 'test', - desiredCount: 2, - domainName: 'api.example.com', - domainZone: 'example.com', - certificate: 'helloworld' - }); - - // THEN - stack contains a load balancer and a service - expect(stack).to(haveResource('AWS::ElasticLoadBalancingV2::LoadBalancer')); - - expect(stack).to(haveResource('AWS::ElasticLoadBalancingV2::Listener', { - Port: 443, - Certificates: [{ - CertificateArn: "helloworld" - }] - })); - - expect(stack).to(haveResource("AWS::ECS::Service", { - DesiredCount: 2, - LaunchType: "FARGATE", - })); - - expect(stack).to(haveResource('AWS::Route53::RecordSet', { - Name: 'api.example.com.', - HostedZoneId: "/hostedzone/DUMMY", - Type: 'A', - AliasTarget: { - HostedZoneId: { 'Fn::GetAtt': ['FargateServiceLBB353E155', 'CanonicalHostedZoneID'] }, - DNSName: { 'Fn::GetAtt': ['FargateServiceLBB353E155', 'DNSName'] }, - } - })); - - test.done(); - }, - - "errors when setting domainName but not domainZone on applet"(test: Test) { - // THEN - test.throws(() => { - new ecsPatterns.LoadBalancedFargateServiceApplet(new cdk.App(), 'Service', { - image: 'test', - domainName: 'api.example.com' - }); - }); - - test.done(); - } };