Terraform and EC2 Provisioning [closed] - amazon-web-services

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.

Related

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/

Hashicorp Vault on aws with cross region active - active setup | CFT, Terraform [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
I need to setup Hashicorp vault on aws with cross region setup in HA. And I gotta do it with complete automation , what would be the best IAC tool , Cloudformation- I found very less documentation on this for vault setup. Or Terraform - ?
has some one achieved it by complete automation method on aws. ?
Terraform is not a Configuration Management tool, It's an IaC tool. You can use Terraform to create underline infrastructure for your Vault setup and it should not use to provision applications in the infrastructure. Of course, you can install applications in your EC2s using exec remote provisioner, but you should use provisioners as the last resort.
So I think of using Terraform for creating the infrastructure of the Vault setup. But you need to use some other tools like Ansible or Puppet to provision software in your infrastructure. Using IaC tools for configuration management will create major technical confusion in the long run.

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.

Different options for creating an AWS EKS Cluster [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 2 years ago.
Improve this question
An AWS EKS Cluster can be created using the AWS CLI or eksctl commands. And AWS is supporting both of them. Both of them at the end of day creates a EKS cluster.
When to use what? I am not able to find any differences between the two.aws
AWS CLI is an imperative way to do it. With eksctl you can use both imperative and declarative way (e.g. when using yaml-manifests).
In addition, you can create EKS cluster declaratively when using CloudFormation EKS cluster or Terraform AWS EKS module.
What is best for you depends on your situation. For laboratory exploration, it is easiest to use imperative commands. But when you are setting up something like a production environment, you want your changes version controlled in e.g. git - so a declarative way to work is a better fit.
What declarative method to use depends on if you e.g. also provision other AWS resources. It is easiest to use same tool for all your infrastructure, e.g. CloudFormation for everything or Terraform for everything. An advantage with Terraform is that it is available for other cloud providers as well, e.g. both AWS and GCP.

AWS CloudFormation provisioning... UserData vs. Ansible or the likes? [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 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.