AWS CloudFormation provisioning... UserData vs. Ansible or the likes? [closed] - amazon-web-services

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 6 years ago.
Improve this question
What is the difference between provisioning using AWS CloudFormation UserData vs. Ansible?
I know that in relation to Puppet for example, it enforces provisioning rules even when a change is done (changes it back to reflect the manifest).
But are there more differences which are worth taking into consideration?

To clarify, "UserData" is part of an EC2 instance, not part of CloudFormation itself. EC2 instances can be launched with User Data, which can be used by the AMI to perform dynamic operations on startup. If CloudFormation is used to launch an EC2 instance, it can provide User Data to the EC2 instance by setting the UserData property on the AWS::EC2::Instance Resource.
Typically, user data is processed by Cloud-Init, and is typically formatted as a simple User-Data Script which is just a shell script that gets invoked on the instance when it is first launched.
That said, 'Shell script vs. Ansible' is an apples-to-oranges comparison. Whether or not Ansible is the appropriate software for your use-case depends on whether you need to use the extra layers of abstraction built into Ansible versus a standard shell script to provision what's needed on your instance. Read the Ansible Documentation and decide for yourself.
It is worth mentioning that aside from the normal 'push' method of running Ansible to provision your instance via SSH, you can also run Ansible in an inverted, 'Ansible-pull' mode, using a User-Data Script to perform the initial 'bootstrap' installation on the EC2 instance.

The short answer is: Use CloudFormation or Terraform
Ansible is a configuration managment tool for many diffrent purposes. The most significant diffrence to many of the other tools is, that is is working in a push mode, so there are no agents on the remote server polling for changes.
It is great when it's about installing packages, creating files and so on.
CloudFormation is desinged to create AWS enviroments. This is good if you onyl use Amazon and nothing else.
Ansible can do the job, but i would recommend to use a tool like CloudFormation or Terraform. The Ansible modules for this are ok, but tools like Terraform have a fokus on creating enviroments and they are much smarter when doing the job.

Related

Terraform and EC2 Provisioning [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed last month.
Improve this question
I have been looking around for best practices provisioning a server but have yet to find one. The problem I am trying to solve is configuring an nginx.conf file in the new server setup by Terraform. So I guess my question is: Is Terraform actually used to install packages and configure the server after it is spun up? Or am I supposed to use something else entirely alongside Terraform (i.e Chef)? In the Terraform docs it mentioned removing support for Chef, Puppet and Ansible. It also mentions using the "provisioner" block for this functionality is frowned upon.
I have tried using the Terraform resource user_data block and a custom provisioning shell script to do this, but this just seems pretty hacky and difficult to read. I would like to stay away from using a pre-defined AMI as well, which I have also tried.
Specifying user_data is about the best you can do with Terraform for this type of thing. EC2 user-data support is implemented using cloud-init. There is a cloud-init Terraform Provider that helps you create user-data scripts and templates, which helps a lot with the readability.
If that isn't to your liking, then you have to look elsewhere, such as using something like Ansible, or possibly AWS Systems Manager, to install/configure your EC2 instances. However, these would be disconnected from Terraform so you may need to use a provisioner to trigger them after a Terraform apply.

How to use AWS to deploy multi-container Docker App [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 months ago.
Improve this question
I have been programming a full-stack application consisting of a NodeJS frontend, .Net Backend, and SQL Server DB and I have managed to fully dockerize the application using docker-compose. I have come a long way since I started this project but I still need a bit more help to finalize it. I am now in the process of deploying my docker containers into AWS (somehow) and I am having a bit of a problem on my end. Please bear in mind I am a beginner and this is quite complex to me.
So far this is the closest I have come to an actual solution to properly deploying all 3 parts of the app.
Created a security group w/ Inbound to all IPv4s and IPv6s, Outbound to all IPv4s
Created a load balancer listening on port 80 with default VPC
Created a key pair to SSH
Created a cluster with 3 instances (backend, frontend, db) default VPC, SG created, default role
Created ECR and pushed all my docker images seperately, 3 ECRs
Created EC2 task def, no role, 512 mem, container with each ECR url, 512 mem, 0:80 mapping
(Unsure if necessary) Created a service to link the LB etc.
When I do this, I am able to run all 3 tasks at the same time with no issues so it seems like progress to me. However, I am doing something wrong when it comes to the ports or IPs since I am not able to access the public DNS or even SSH to any of the instances, it times out.
Question:
Have I made an error anywhere? Specifically, in the ports or IP, I am not sure where the mistake is
Notes:
This is a simple project which I will have up for maybe 1-2 months, I do not plan on spending more than $5-$10. It is just a simple project with CRUD operations.
The end goal is simply to have everything up on AWS and running together, so I can perform CRUD on the DB, nothing long-term or complex.
P.S I MUST use AWS
The simplest way to achieve your goal considering the amount you want to spend would be to move your solution to EC2 as described by you. What issues do you face doing so?
You may also explore the integration of Docker Compose and ECS
Also check this out -
https://aws.amazon.com/blogs/containers/deploy-applications-on-amazon-ecs-using-docker-compose/

What's the best way to setup a docker based cluster on AWS? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 1 year ago.
Improve this question
We are building a small micro service architecture which we would like to deploy to AWS.
The number of services is growing, so we need solution that allows scaling (horizontal).
What's the best way to build this on AWS? We don't have too much experience with docker, we used EC2 based stuff in the past.
I'm thinking about something like:
Use ECR, create a private docker repository. We push release images there.
Use ECS to automatically deploy those images.
Is this correct? Or should we go for Kubernetes instead? Which one is better?
Our needs:
Automated deployments based on docker images
Deploy to test and prod environments
Prod cluster should be able to handle multiple instances of certain services with load balancing.
Thanks in advance for any advice!
AWS container service team member here. Agreed with others that answers may potentially be very skewed to personal opinions. If you come in with good AWS knowledge but no container knowledge I would suggest ECS/Fargate. Note that deploying on ECS would require a bit of CloudFormation mechanics because you need to deploy a number of resources (load balancers, IAM roles, etc) in addition to ECS tasks that embeds your containers. It could be daunting if not abstracted.
We have created a few tools that allows you to offload some of that boiler plating. In order of what I would suggest for your use case:
Copilot which is a CLI tool that can prepare environments and deploy your app according to specific patterns. Have a look here
Docker Compose integration with ECS. This is a new integration we built with Docker that allows you to start from a simple Docker Compose file and deploy to ECS/Fargate. See here.
CDK is a sw development framework to define your AWS infrastructure as code. See here. These are the specific CDK ECS patterns if you want to go down that route.

Create own cluster structure with AWS CloudFormation [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 2 years ago.
Improve this question
I would like to create my own cluster structure on Amazon Cloudformation. I have 3 servers. 2 server Nginx and other one MySQL server. I create a cluster structure with my own shell script. Is it possible to create with AWS CloudFormation ? How can I get MySQL server IP address then how can I use this IP address in my shell script? (on Nginx servers).
Thanks for your all help.
If the CloudFormation template is creating a resource (eg an Amazon EC2 instance), other parts of the template can refer (!Ref) to that resource.
While defining the EC2 instances running nginx, you would be providing a User Data script that will be executed when the instance starts. Inside the CloudFormation template, where the script is defined, it is possible to !Ref another part of the script. CloudFormation will automatically insert that referenced information (such as the database instance's IP address).
For some examples, see:
Resources - AWS CloudFormation
Reference Parameter Value in UserData in AWS Cloudformation
Understanding AWS CloudFormation !Sub Syntax

How to run `docker-compose` web application on AWS? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 3 years ago.
Improve this question
I'm using an image annotation tool (coco-annotator based on Vue.js) locally and I would like to run it on a AWS webserver, to be able to access it from anywhere.
The source code contains some docker files and can locally be run using
docker-compose up
Does someone know, what are the high-level steps to run this application on a AWS webserver?
AWS seems quite complicated as it has a million options, so I'd like to know
What "product" should I choose? ("EC2" (virtual machine)? "Elatic Beanstalk" (web application)?
What pre-installation should I choose? ("Docker - single instance"?)
How do I tell AWS, how to launch the command for the coco-annotator? (login via ssh and run the command manually? or is there some pre-configuration that enters the respective source folder automatically and runs docker-compose up on startup?)
Solution
Select a AWS EC2
As virtual machine chose "t2.micro" (free tier eligible) for example with Ubuntu 18.04
Login to your EC2 virtual machine instance via ssh and run manually install the coco-annotator (or other software) -> note the local port that the server is running on
make the IP-Adress to your ec2 instance permanent (click)
make your EC2 instance accessible via the browser (click) --> Add Rule for "TCP/IP" + access from anywhere
sudo apt-get install nginx -> enter your domain in the default config file of nginx
Use the AWS "Route 53"-Service to create a "hosted zone"
Register a free domain, eg here at freenom
On AWS - Route 53: "Create Record Set" -> Name: "www.yourWebdomain.com" Value: "yourAwsEc2IpAddress"
note the nameservers provided by Amazon (ns-.awsdns-20.) and enter them as custom nameservers on the config page of your domain provider (freenom). Do not use URL forwarding!
now the communication between nginx, and your AWS EC2 instance should be working
This is a very loaded question and you'd probably get a better response with a more direct question with an example. With that said, if your app is containerized you can use ECS or Elastic Beanstalk. If your application is stateless (you don't need local disk storage this is persistent between restarts of your application, you can still use a database or other services for storage) the easiest is probably ECS using Fargate tasks.
There are numerous blogs and tutorials online because, as you've already said, there are very many different types of applications, deployment and configuration options. Start reading some blogs and the docs for using docker compose to deploy contained to AWS.
A place to get started might be here.
https://docs.aws.amazon.com/AmazonECS/latest/developerguide/ecs-cli-tutorial-fargate.html
Edit:
I see you cross posted here https://github.com/jsbroks/coco-annotator/issues/231. The OP there said they used a VM. In AWS this is an EC2 instance. The get started https://github.com/jsbroks/coco-annotator/wiki/Getting-Started#dedicated-servervps-setup also says this requires a dedicated server or VSP. That would also point to EC2. If you want to use ECS or Beanstalk you need to deploy a container. I don't know if this app supports running in a container and if you want to pursue that routeyour best place to ask is probably in that projects community not SO.