forked from aws/aws-cdk
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
198 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
import ec2 = require('@aws-cdk/aws-ec2'); | ||
// import ecr = require('@aws-cdk/aws-ecr'); | ||
// import cloudmap = require('@aws-cdk/aws-servicediscovery'); | ||
import cdk = require('@aws-cdk/cdk'); | ||
import ecs = require('../../lib'); | ||
|
||
const app = new cdk.App(); | ||
const stack = new cdk.Stack(app, 'aws-ecs-integ-ecs'); | ||
|
||
const vpc = new ec2.VpcNetwork(stack, 'Vpc', { maxAZs: 2 }); | ||
|
||
const cluster = new ecs.Cluster(stack, 'EcsCluster', { vpc }); | ||
|
||
cluster.addDefaultAutoScalingGroupCapacity({ | ||
instanceType: new ec2.InstanceType('t2.micro') | ||
}); | ||
|
||
const domainName = "scorekeep.com"; | ||
cluster.addNamespace(domainName); | ||
|
||
// Create frontend service | ||
const frontendTD = new ecs.Ec2TaskDefinition(stack, 'frontendTD'); | ||
|
||
// const frontendImage = new ecr.Repository(stack, 'scorekeep-frontend'); | ||
const frontend = frontendTD.addContainer('frontend', { | ||
// image: ecs.ContainerImage.fromEcrRepository("arn:aws:ecr:us-west-2:794715269151:repository/scorekeep-frontend"), | ||
// image: ecs.ContainerImage.fromEcrRepository(frontendImage), | ||
image: ecs.ContainerImage.fromDockerHub("amazon/amazon-ecs-sample"), | ||
memoryLimitMiB: 256, | ||
}); | ||
|
||
frontend.addPortMappings({ | ||
containerPort: 80, | ||
hostPort: 8080, | ||
protocol: ecs.Protocol.Tcp | ||
}); | ||
|
||
const frontendService = new ecs.Ec2Service(stack, "FrontendService", { | ||
cluster, | ||
taskDefinition: frontendTD, | ||
}); | ||
|
||
// Create backend service | ||
// const apiTD = new ecs.Ec2TaskDefinition(stack, 'TaskDef'); | ||
|
||
// const apiImage = new ecr.Repository(stack, 'scorekeep-api'); | ||
// const api = apiTD.addContainer('api', { | ||
// image: ecs.ContainerImage.fromEcrRepository(apiImage), | ||
// memoryLimitMiB: 256, | ||
// }); | ||
|
||
// api.addPortMappings({ | ||
// containerPort: 80, | ||
// hostPort: 5000, | ||
// protocol: ecs.Protocol.Tcp | ||
// }); | ||
|
||
// const apiService = new ecs.Ec2Service(stack, "APIService", { | ||
// cluster, | ||
// taskDefinition: apiTD, | ||
// }); | ||
|
||
// NOTE: Passing in the cluster's serviceDiscoveryNamespaceId is a little clunky, would have liked to have | ||
// enableServiceDiscovery not take any argument and look it up on the cluster, but that would have involved adding | ||
// cluster as a member on service which may have called for a breaking change. This is a also little more explicit | ||
const namespaceId = cluster.serviceDiscoveryNamespaceId; | ||
|
||
frontendService.enableServiceDiscovery({ | ||
name: "frontend", | ||
namespaceId, | ||
}); | ||
|
||
// apiService.enableServiceDiscovery({ | ||
// namespaceId, | ||
// }); | ||
|
||
app.run(); |
1 change: 1 addition & 0 deletions
1
packages/@aws-cdk/aws-servicediscovery/lib/public-dns-namespace.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters