109 points · by ingve · 7y ago · 63 comments
- using Terraform instead of cloud formation
- not using the default create a VPC wizard like anyone new would.
- he said if we wanted to use lambda functions he would still have to setup networking. It depends on what he was doing. If he used a regular database, yes he would have had to setup a subnet for his RDS cluster, but if he used DynamoDB, he wouldn’t need to do that. But even then, the default VPC wizard that most people would have used would have been good enough. But either way, that has nothing to do with K8s vs Fargate.
No even when you run a lambda “inside your VPC”, you don’t get more security. The lambda is never running inside your VPC. It is running inside an AWS VPC and connecting to your VPC via a network interface (ENI).
- If he were to use lambda, he would not have had to worry half as much. He wouldn’t have needed a load balancer. Also, he was using a third party ssl certificate when he could have had a free one that was automatically managed by AWS with Amazon Certificate Manager. Using API Gateway and just using a lambda proxy would have done the same thing. No, there is no “lock-in” from using lambda and a lambda-proxy interface. You write your same C#/WebAPI, Node/Express, Python/Django code just like you always would and add the proxy on top of it.
The CF console is opaque, slow and worst of all lazy evaluates. This is exacerbated when doing anything docker service related. If you make a mistake it can be three hours before an update timeout is triggered, then another three hours for a rollback to complete.
The other _really_ annoying thing is that TF gets the features first. For example its not possible with CF to use SSM variables in environment vars. But as TF uses the AWS API, it can.
I dislike TF because I've not used it overly much, and it makes me have horror flashbacks of puppet.
However, what you say about the lambda is basically spot on. They are much simpler and easer, "true" serverless if you will. Or more likly /cgi-bin/lambda, if you are old enough.
How is it opaque? It’s a wizard that lets you upload a template from a file or S3. Most of the time though it’s part of my CodePipeline anyway. I don’t use the console in day to day use.
For a quick and dirty I use the CLI.
The other _really_ annoying thing is that TF gets the features first. For example its not possible with CF to use SSM variables in environment vars. But as TF uses the AWS API, it can.
Yes you can....
https://aws.amazon.com/blogs/mt/integrating-aws-cloudformati...
But there is one benefit to CloudFormation if you have the business support plan - AWS’s chat support is excellent.
The one that got me this week was that CF cannot define global Dynamo tables, you have to find an alternative way to turn them on.
However the new feature where you just dump in the SSM name in the environment variable and it unencrypts at execution is not supported in CF yet.
It was the same ECS/fargate/batch task creation for a long time.
As for the CF Console, its the same data in the CLI or on the web, the data comes from the same point.
1) it lazy evaluates, so it gets 90% of the way through a deploy only to find that there is a spelling mistake. That is inexcusable.
2) yes you can download the template via S3, but if you have a circular dependency, it won't tell you the line numbers. It won't even tell you the occurrences that are causing it to be over constrained.
3) It won't tell you the order in which your stuff will come up.
pro level startup: set it manually and use cloudformer.
+1 on the comments regarding wiring and lambda in non-vpc vs vpc context
also, if you want K8s, there is this thing called EKS.
Alas, that never really works with multi account setups. Its sometimes useful for seeing which magic line one is missing, but the level of incorrect boilerplate out there on github is staggering.
I probably could have figured it out, but why bother when we are paying for the business support plan?
also, compared to terraform, cloudformation is state-of-the-art when it comes to actually bringing shit up
Which is absurdly overpriced. $1,728/yr just to run an empty cluster.
Working through permissions in AWS does suck, and the transparency problem in why a container fails to start in Fargate is especially frustrating.
Serverless and devops in general isn't about putting ops folks out of a job. It's about leveling the playing field on both sides of the coin so that someone who focuses on application development and someone who focuses on networking and infrastructure can collaborate easier, with more solid contracts and interfaces.
So long as the more adversarial perspective persists, we'll see a lot more digging in of the heels around kubernetes. As usual, I implore my friends in ops not to rely on the inherent bus factor that the mastery of kubernetes requires for job security.
I was recently asked to set up a recurring Fargate task with a container of an app I developed. Despite knowing nothing about the ecosystem, I was able to get it up and running with Terraform in a few days, with pretty much no headaches, friction, or confusing issues. I didn't touch the AWS console even once, other than to verify that it appeared to be set up correctly after running "terraform apply".
I considered using Cloudformation, but it just seemed kind of messy and confusing to me. It also felt very visually noisy. (And YAML wasn't the issue; I read and write YAML very often, and actually really like YAML and use it in all of my personal projects.)
Despite going into it totally blind, by contrast, I found Terraform very intuitive and sensible within the first few minutes of using it. It felt much more structured and organized, and just generally simpler to read and write. I also liked that it was provider-agnostic. And the "terraform plan" feature was super helpful.
I "cheated" a little bit by using these Terraform templates as a base: https://github.com/turnerlabs/terraform-ecs-fargate-schedule.... I didn't have to change too much to get things working. I'm sure it would've taken longer if I wrote the whole thing from scratch.
I guess I'm asking: am I wasting my time investing in learning things like Terraform? Every reply in this thread is either recommending AWS-native alternatives to Terraform, criticizing Terraform, or both. For some reason I thought it was generally recommended over Cloudformation due to the lack of lock-in.
But no lock-in is not a reason at all. There is effectively no amount of terraform config that will plug and play into a different cloud.
It seems that it was pitched that way. But if you write anything in terraform for AWS you will have to fully rewrite it for GCP or DO. But at least you will be used to the syntax and conventions.
If you ever work for a company that uses AWS, they probably have a business support plan where you can get instant and excellent customer support on CF.
The author has already hit a use-case that is not currently supported by Cloud formation (creating a SecureString SSM parameter)--that's something that Troposphere or the CDK won't help you with (unless you use them to create the resource via the API rather than Cloud formation).
To do it properly, the author could have created an AWS KMS key, encrypted the password with that key, and then stored the encrypted password in source control. Then password goes in as a regular, plain-text parameter, and the container decrypts it thanks to having the proper IAM permissions for the AWS Key. It's slightly more complicated but you get 1) ability to store the (encrypted) password in source control and 2) the ability to let anyone work with the stack without giving them the plaintext pw.
If you do want to stick to SSM for whatever reason, you can also use SSM parameters as Inputs to CloudFormation, so you can use a custom resource OR an out-of-band process to set the password up. It's wouldn't be great, but it's not the right tool for the job in the first place.
https://svdgraaf.nl/2018/04/13/CloudFormation-ssm-secure-str...
I wanted to add that we switched from ECS without Fargate (managing our own EC2 instanced) to ECS with Fargate and it has been a pure improvement. It’s simpler and easier to manage with less moving parts. I would recommend to anyone currently on ECS to give Fargate a try
The real value-add of Fargate is pay-for-what-you-use, when your task queue is idle and your bill drops to zero with no extra orchestration (something that the article seemingly completely missed).
Fargate isn’t less config than a helm chart, but you’re on your own, in that there isn’t much of a public config ecosystem that I’m aware of. I also wrote it off due to 2.3-3X instance pricing vs EC2.
One of the biggest factors that intimidates developers in my experience is needing to determine resources. It would seem that such a task could be done with automatic testing, but I haven’t found or developed a technique to do so. In theory I would have my script test different RAM/CPU values against a load tester, have live cost data and compute an optimum. I suppose one can come from the opposite angle and determine the program’s needs based on data structures and libraries. That is beyond my skills.
I suppose network interface throughput would be another factor, but unfortunately with Fargate and Lambda that is largely opaque ( and I believe linked to CPU allocation ).
This just goes to say that in addition to managing the complexity of configuration code, the underlying abstractions are harder to grok than a VM or even Kubernetes nodes and resource allocations.
I had drank the Docker kool-aid pretty hard and spinning up individual nodes was easy, until I started projecting forward what the final architecture would look like - patching, failover, backup, disaster recovery etc.
Eventually I convinced my boss to pay for Heroku and went home early.
Then I started questioning, is this any better than 1 container per ec2 instance and running docker myself?
Assume that 1 fargate task definition == 1 ec2 instance.
I can't really think of any way that fargate would win in cost.
The management overhead for ec2 seems to be limited to starting docker daemon and launching your containers.
Should I migrate off of fargate onto ec2?
Where Fargate shines is situations that require rapid scaling or where the infrastructure can be more on-demand. The startup time for Fargate is lower than EC2 in my experience.
I would advocate for continuing to use ECS instead of self-managed docker, just use reserved EC2 instances.
Average task start time is about 3min on fargate. And there is no caching at all built-in.
I wish it was more like 5secs... :(
Really I wish I could run my app on Lambda but my app is too large at the moment, and has a lot of large/streaming/otherwise unusual HTTP requests that may be a bear to integrate with lambda...