1
votes

I have created my own EC2 instance in AWS. That AMI is AWS ECS optimized AMI for launching ecs service from my EC2 instance. I previously discussed the same thing. And tried with that approach. The link is below,

Microservice Deployment Using AWS ECS Service

I created my cluster and configured that cluster name when I am creating optimized AMI by following code snippet in advanced userdata section,

#!/bin/bash
echo ECS_CLUSTER=your_cluster_name >> /etc/ecs/ecs.config

I followed the documentation of cluster creation from following link,

https://docs.aws.amazon.com/AmazonECS/latest/developerguide/create_cluster.htmlecs

But, no result - when creating cluster and ECS task definitions it creates and launches into one EC2. And again creating another EC2 by specifying above code. So total 2 Ec2. I already created my own ECS optimized.

I am finding for launching ECS service from my own AMI (that I created). Actually I need to launch my ECS service from my Ec2 (I had created my machine Amazon optimized AMI).

The reason behind this requirement is I don't want to launch my services in machine that owned by others. I need to launch from my machine. And also I need to host my angular application in the same my machine. So I need control of my machine. How can I do this?

1
Can you elaborate on what you mean by "no result"? Are you saying your instance doesn't show up in your cluster or something else? - MrDuk
Can you check updated notes. When Creating cluster and services it launches into one AMI (us-east-1 - ami-28456852). When I am following steps for launching instances, It creating another Ec2 Instance. Link - docs.aws.amazon.com/AmazonECS/latest/developerguide/… . Adding cluster name in userdata section as mentioned above. It not loading into my own EC2 machine. That is my pblm. - Jacob
UserData is only executed during instance launch - if you're adding your cluster configuration after the instance has launched, it will have no effect. - MrDuk
Ok. Can you give any documentation URL for reference please for the steps that i need to follow? - Jacob

1 Answers

1
votes

Sounds like you just need to create a Launch Configuration. With this you can specify the User Data settings that should be applied when a host is setup.

After you create your Launch Configuration, create a new Auto Scaling Group based off of it (there's a drop-down to select the launch configuration you want to use).

From here, any new instances launched under that ASG will apply the settings you've configured in the associated Launch Configuration.