diff --git a/lib/pattern/EcsService/index.ts b/lib/pattern/EcsService/index.ts index 2aa88c1..f86a243 100644 --- a/lib/pattern/EcsService/index.ts +++ b/lib/pattern/EcsService/index.ts @@ -24,6 +24,7 @@ export interface EcsServiceProps { } export class EcsService extends cdk.Construct { + public readonly applicationName: string; public readonly listeners: Listeners; public readonly targetGroups: TargetGroups; @@ -33,6 +34,7 @@ export class EcsService extends cdk.Construct { constructor(scope: cdk.Construct, id: string, props: EcsServiceProps) { super(scope, id); + this.applicationName = props.names.applicationName; /** * @@ -65,7 +67,7 @@ export class EcsService extends cdk.Construct { * Task Containers */ const container = new TaskContainer(this, "Task-Containers", { - appName: props.names.applicationName, + appName: this.applicationName, }); /** @@ -73,8 +75,8 @@ export class EcsService extends cdk.Construct { * Ecs Task Definition */ this.taskDef = new TaskDef(this, "Ecs-TaskDef", { + appName: this.applicationName, familyName: props.names.familyName, - appName: props.names.applicationName, taskContainers: container.allContainers, }); @@ -85,7 +87,7 @@ export class EcsService extends cdk.Construct { this.service = new Service(this, "Ecs-Service", { cluster: this.cluster, taskDefinition: this.taskDef, - serviceName: props.names.applicationName, + serviceName: this.applicationName, }); /** diff --git a/lib/stack/index.ts b/lib/stack/index.ts index e69de29..4857f77 100644 --- a/lib/stack/index.ts +++ b/lib/stack/index.ts @@ -0,0 +1,26 @@ +import * as config from "@config"; +import * as cdk from "@aws-cdk/core"; +import { Resources } from "@pattern/Resources"; +import { EcsService } from "@pattern/EcsService"; + +export class Infrastructure extends cdk.Stack { + constructor(scope: cdk.Construct, id: string) { + super(scope, id); + + /** + * + * Base Resources + */ + const resources = new Resources(this, "Base-Resources"); + + /** + * + * Ecs Service + */ + new EcsService(this, "Ecs-Service", { + vpc: resources.vpc, + elb: resources.loadBalancer, + names: config.resource_names, + }); + } +}