Launching ECS service from our own AMI - amazon-ec2

I am trying to deploy my sample Spring Cloud Microservice into AWS ECS service. I found that Fargate method and EC2 launch method. Here actually I am looking for to launch ECS service from my own EC2 instance. Now I have only Ubuntu 16.04 AMI. I am planning to use AWS ECS optimized AMI as my EC2. So I need to launch ECS using my own EC2. So I am confused about the launching by optimized my own EC2.
I am seeking useful links or documentation for launching using above method. Since I am beginning stage on AWS Cloud.

The AMI you've configured for your instance doesn't matter (generally). Once your EC2 instance is created, go over to the ECS section of AWS and create a cluster containing your host.
In ECS you need to define a task containing your container, the repo to pull it from, and all the other necessary details. From here you can go to your cluster and launch your task on your host, either manually, or by defining a service to automate the launching for you.

Related

ECS to EC2 connect for GITHUB actions runner

I have github actions self hosted runner in ECS which needs to access a file from a folder in an EC2 instance. Both are in the same AWS VPC.
How can i do this. I am unable to figure out the connection from ECS to EC2.
Any suggestion would be highly appreciated.
Thanks

Can we spin up a scalable application server using aws ecs ? I mean like a ec2 instnace with amazon linux ami

I want to know the possibility of having a application server (linux machine) spinned up using ecs ?
I.e An Ec2 instance running an application which serves user requests .
To be more clear.. can we spin up a ec2 via a container ?

Creating a RethinkDB cluster on Amazon ECS

I am using the official Docker image for RethinkDB. I am trying to use AWS EC2 Container Services to create a RethinkDB cluster. I can easily get stand alone instances to run, but have had no luck creating a RethinkDB cluster.
I have tried various security group settings. I even made everything wide open, but no luck. When I launch the Docker image, I pass in --bind all and --join [ip]:29015, but nothing.
Has anyone got this to work?
The default networking for docker on amazon ECS is the docker0 bridge. This means multiple containers on the same EC2 instance can talk to each other through the bridge but not to other EC2 instances and containers across the ECS cluster.
You could set the networkMode in your task definition to 'host' which should then let you use the network on your EC2 instances directly and use the security groups you have defined See http://docs.aws.amazon.com/AmazonECS/latest/developerguide/task_definition_parameters.html#network_mode.
The alternative is to setup an overlay network using something like flannel, weave, openvswitch etc. See https://aws.amazon.com/blogs/apn/architecting-microservices-using-weave-net-and-amazon-ec2-container-service/ for an example using weave.

How to deploy a Docker container on EC2 ECS from Docker Hub private repo?

I have an image in a private Docker Hub repository, which I'm trying to deploy on Amazon's Elastic Container Service. There seems to be nice web console to run a container from a public repository, but nothing for private. I've read and tried to understand the documentation for this, but I don't understand what that has to do with deploying my container, as it states "The Amazon ECS container agent allows container instances to connect to your cluster".
As an alternative to using the web console, I see mentions of setting up a task definition. It sounds like that's the manual version of what the web console does. I suspect my best bet is with this method, possibly with the help of the script here.
What is the simplest way for me to run an existing image on ECS that's hosted in a private repository?
Right, so a container instance is just the EC2 machine that happens to run the services defined in the cluster. The cluster can then connect to the EC2 machine as a container instance, but unless the EC2 machine is appropriately configured, it can't run your private repository.

Getting information about deployment from within an instance of AWS Elastic Beanstalk

My specific need is to get the list of EC2 instances in the deployment from within one of the instances.
I've tried using AWS command line for example aws elb describe-load-balancers however it would just give details of all my AWS services. I know you can specify an instances name with --load-balancer-name but I just don't have access to that from within the instance automatically.
Perhaps a file can be created on instance creation by placing something in .ebextensions?
You can do it in a two step process using the AWS CLI.
First you get the endpoint for your Elastic Beanstalk application:
aws elasticbeanstalk describe-environments --query='Environments[?ApplicationName==`Your-application-name`].EndpointURL'
Then you use the endpoint to get the instances:
aws elb describe-load-balancers --query='LoadBalancerDescriptions[?DNSName==`load-balancer-end-point-from-previous-step`].Instances[0]'

Resources