AWS lambda function to restart one of the ECS cluster service - aws-lambda

We are deploying multiple service in ECS cluster with fargate, On the front end we are using nginx service. On the backend some services are getting deployed frequently. Once any of the backend service deployed we manually need to update nginx service forcefully. Do we have any approach to update only nginx service forcefully when any of the new service deployed successfully?
How we can achieve this ? using lambda or cloudwatch....
Any help is appreciated, Thanks in advance

When the backend Services are updated you can use cloud watch to trigger a lambda. This lambda can use the AWS SDK to to restart the Nginx container service/task. You could also version your Nginx container along with all your backend services so that that the a new Nginx image is push up when your backend changes and the task definition is changed contains the new image. Providing your using AWS ECS Service it can update it self.
See here for more information: https://docs.aws.amazon.com/AmazonECS/latest/developerguide/update-service.html

Related

how to create a http proxy api gateway from serverless without creating lambda function

I have to create http proxy api gateway from serverless code for this flow: https://aws.amazon.com/blogs/compute/using-amazon-api-gateway-with-microservices-deployed-on-amazon-ecs/
You only need to know how to build an ECS cluster including a Load Balancer, then you can enable HTTP proxy on API Gateway console.
How to build an ECS cluster?
a) Create an ECS Cluster
b) Create a Task Definition and set your image on it
c) Create a Load Balancer and Target Group
d) Create an ECS Service and attach Load Balancer and Task Definition
You can follow the official guide here:
https://docs.aws.amazon.com/AmazonECS/latest/developerguide/ecs-cli-tutorial-ec2.html

Continuously deploying features to Spring Boot application hosted by AWS

I am looking for advice/ideas on how to continuously deploy new features to a Spring Boot web application that is hosted on an AWS EC2 instance. My current workflow:
bootRepackage my application to create a war file.
Upload that file to AWS.
Add a new feature to my application.
bootRepackage again.
Remove the current war from AWS, and upload the new one.
This is obviously not a good workflow, as the application needs to be restarted which could result in 1) downtime and 2) entries in the database being lost (if I'm using Spring's default H2 database - I am not, I'm using a standalone SQL server, but just making the point for this question) so I am wanting to streamline it.
Is there any way to add a new feature to the current instance of the service on AWS? Is it possible to recompile the code "one the fly" to prevent the need to restart the application?
Is there any way of creating a better setup that would allow me to just merge a new branch to master locally, and push that with the same instance still in prod except with this new feature?
Thank you in advance!
Update, is this really the correct answer?
If you using single instance of aws and deploying the application to EC2 instance, please assign Elastic IP for the AWS EC2 instance.
An Elastic IP address is a static IPv4 address designed for dynamic
cloud computing. An Elastic IP address is associated with your AWS
account. With an Elastic IP address, you can mask the failure of an
instance or software by rapidly remapping the address to another
instance in your account.
Deploy the new version of the application in another AWS EC2 instance
When the application is ready, reassign the Elastic IP from the existing EC2 instance to new EC2 instance
Elastic IPs are the simplest way to implement the blue-green switch.

How to install Datadog agent in AWS lambda

We want to collect metrics from machines running AWS lambda in AWS. How can I get access to these machines and get DD agent installed on them.
Lambda is serverless. Datadog agent is for the host. While running lambda you have absolutely no control over the host as you are not managing it.
Hence, You can monitor application running on lambda using datadog integration of lambda for the different application.
You may follow below link for AWS Integration of datadog.
Ref: https://docs.datadoghq.com/integrations/amazon_lambda/

An EC2 instance behind a load balancer is not terminating after reboot but load balancer is going out of service

There is single EC2 instance deployed behind a ELB using Cloud Formation and now I am trying to add cron jobs to crontab by updating CF stack, however after updating the stack I rebooted the server but the changes are not reflecting on the server.
It seems like the application on the server is only rebooted not the OS of the server. When I checked status of ELB after reboot, instance state is out of service and instance state on the EC2 tab is showing running.
Note: There is no autoscaling group attached.
Check if your application on EC2 instance is listening on the port mentioned in loadbalancer.

How can I setup and deploy a database with Deis (PaaS)

I'm trying to setup a database with Deis. I know this is possible, but there doesn't seem to be any documentation about how to do it other than setting an ENV variable.How could I setup say a MongoDB or Cassandra docker container and then deploy that and have my deis app use it?
If you're trying to deploy now, a possible solution is to set up a docker container, have it publicly route-able, and then configure your application to use that container through an environment variable following Heroku's 12 factor app best practices. There is a feature request for a Deis service gateway that will act like Heroku's Add-on Marketplace, but it's not there yet.

Resources