'Unable to deploy a Ec2Service
I am trying to create ECS Service and point Application Balancer to it but it just stuck on creating Ec2Service
const cluster = new Cluster(this, `TestCluster`, {
vpc: vpc,
clusterName: `TestCluster`,
});
// Add capacity to it
const autoScalingGroup = new AutoScalingGroup(this, 'ASG', {
vpc,
instanceType: new InstanceType('t2.micro'),
machineImage: EcsOptimizedImage.amazonLinux2(),
minCapacity: 1,
maxCapacity: 2,
});
const capacityProvider = new AsgCapacityProvider(this, 'AsgCapacityProvider', {
autoScalingGroup,
});
const dockerFile = `./build/auth/`;
const dockerImageAsset = new DockerImageAsset(stackRef, `authDockerImage`, {
directory: dockerFile,
});
// create task defination
const taskDefinition = new Ec2TaskDefinition(stackRef, `authTaskDefination`, {
networkMode: NetworkMode.AWS_VPC
});
//add container
const container = taskDefinition.addContainer('AuthContainer', {
image: ContainerImage.fromDockerImageAsset(dockerImageAsset),
memoryLimitMiB: 512,
logging: LogDrivers.awsLogs({
streamPrefix: `authService`,
logRetention: RetentionDays.ONE_DAY
}),
containerName: `auth`,
portMappings: [{
containerPort: 80
}],
});
//create taskService
const service = new Ec2Service(stackRef, `${taskName}TaskService`, {
cluster: cluster,
taskDefinition: taskDefinition
});
if I remove Ec2Service and use FargateService its deployed successfully, I tried several times but it just got stuck on deploying EC2Service
Solution 1:[1]
It was memory issue + ENI issue due to which service never get deployed
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Anwar Javed |
