237 points · by calvinfo · 10y ago · 58 comments
The Segment Stack is a good showcase of best-practices for AWS ... only one thing I didn't understand, why a NAT instance is needed in each subnet? https://github.com/segmentio/stack/blob/master/vpc/main.tf#L... It seems a little wasteful. Couldn't you just allow traffic between the subnets?
Played with an external tool call [terraforming] that creates a terraform setup from your existing boxes, but that, too, was way more than I wanted.
Terraform is a very neat tool, but learning the AWS ecosystem _and_ this third-party tool that has its own very strong set of best practices was too much for me. If you're experienced, and especially if you're already using CloudFormation heavily, you can probably get a lot of mileage out of terraform.
Doing a quick search to make sure I'm not crazy, it looks like terraform 0.7 will start to support importing, so that's something: https://github.com/hashicorp/terraform/issues/581
[tfstate file]: https://www.terraform.io/docs/state/remote
[terraforming]: https://github.com/dtan4/terraforming
- Terraform vs. Ansible: /u/mitchellh (I think that's his HN name) started terraform and explained his "Terraform vs. Alternatives" in a Google Groups Post[1].
In addition to that post, Terraform also has nice support of multiple providers, so you can mix AWS, Azure, and others in one set of templates.
In general, Terraform is doing a lot of cutting-edge thinking with orchestration tools and represents IMO a best-of-breed approach.
That being said, there are a lot of bugs, especially around eventual consistency issues in AWS. They're getting better, and most of them are recoverable, though.
[1] https://groups.google.com/d/msg/terraform-tool/6Fxnl_bejX4/0...
https://aws.amazon.com/blogs/aws/new-managed-nat-network-add...
> In general, Terraform is doing a lot of cutting-edge thinking with orchestration tools and represents IMO a best-of-breed approach.
Terraform isn't really doing anything that snazzy compared to Cloudformation [1] (an AWS tool) unless you're also orchestrating in concert with non-AWS services.
I'd disagree with that. Just take a look at the Terraform Changelog[1] for some of the latest & greatest.
For example, the concept of "Data sources" is pretty cool. Basically, you can reference pre-existing data, potentially do rich queries against it, and get a read-only value back. For example, you can use a Data source to find the latest AMI for a given search string.[2]
CloudFormation has a concept of Custom Resources[3] which could achieve similar functionality, but not without a lot of hassle.
Terraform has also been building up a rich language of interpolation functions [4] that can be used for string replacement, hash generation, and even arithmetic.
There's a lot more, too. I think it goes well beyond "cloud-agnostic."
[1] https://github.com/hashicorp/terraform/blob/master/CHANGELOG...
[2] https://github.com/hashicorp/terraform/blob/master/website/s...
[3] http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuid...
[4] https://www.terraform.io/docs/configuration/interpolation.ht...
I don't think it's strictly needed, but it's best practice because instances in each AZ remain independent from failures in other AZs. Were the AZ with the single NAT to go down, then instances in the other AZs wouldn't be able to communicate outside the VPC (ie. to the rest of the internet)
There's also a side benefit of much lower latency using a NAT in the same AZ vs going across AZ (unscientific benchmark is 0.1ms in same AZ vs 0.3ms across AZ)
As you say, it's not strictly needed. It really depends on your use case. If your use-case suffers for the NAT being down, then you need HA on it. If it can wait, then no. With the new managed NAT in AWS, you may as well go with that if you need HA - it's cheapest is roughly twice the price of a micro anyway, and it's one less bit of clutter in your instance list.
Oh I see. Though assuming app servers are wired up behind an ELB, the service will only be partially degraded (no app server outbound connectivity, like you said).
The one-NAT per AZ is a more robust design but at $30/mo each (for NAT gateway) seems expensive ;) Even at $10/mo (small do-it-yourself NAT instance) it's not free.
So, as you change your config, terraform will come up with a plan to move from your present AWS state to the desired AWS state.
Terraform allows you to easily express the dependencies in your infrastructure, and also knows about the various dependencies that naturally come with AWS services, which allows it to make better decisions in its planning compared to tools like ansible, chef, etc.
I've been working on an open source stack that is somewhat similar and serves the same purpose. Allowing startups to bootstrap their stack on AWS.
http://docs.the-startup-stack.com
Great work on open sourcing this. I will see what I can do to contribute.
I am developing everything "in the open" so feel free to contribute / ask questions.
I spent the last 3 months collecting usage information from startups using the-startup-stack and about to make another effort to commit all that knowledge back into the project.
"Not Invented Here" is a big problem in this industry in general. We tend to be too comfortable cobbling a solution together from stone knives and bearskins, rather than using someone else's solution (and paying for it). If you are running a business, though, you shouldn't be building things that aren't what you sell, unless you really cannot otherwise buy them.
I'd add the above. Otherwise AWS would have never been built.
Using the "aws specific" features that are always touted as the reason it's expensive, have a secondary "invisible" cost to them that many don't or won't recognise: you're tying your business directly to a single provider, and one that has a history of predatory pricing to gain market control.
You don't need to buy physical servers to not use aws. There's lots of middle ground that can be achieved for equal or lower costs, with less lock-in and more control for your business.
Also I wouldn't even consider DigitalOcean a competitor to AWS. Not even close.
The thing that's more difficult to do on physical hardware, obviously, is scaling down every day if your peak load is some insane multiple of your base load for a 24h cycle. That's where AWS makes a lot of sense.
I don't think there's an obvious 'best' answer -- it depends on what you need.
It just bugs me that the current state of Ops/Infrastructure sometimes looks so much like the worst parts of the Javascript ecosystem.
- We wrote our own terraform testing framework to validate that every change to our modules doesn't break functionality - We actively update our modules based on feedback from new client engagements - We provide commercial support for each module - We combine our modules with consulting and training as needed
And of course, there are many similarities - We give 100% of the source code to our clients - Everything runs in the client's AWS account - Everything is self-documented, modularized, and can be combined/composed as the needs of different teams require
I didn't mean for this to be a shameless plug; more just that I found it interesting to compare the open source vs. commercial approach to solving this same problem. Props to the Segment team for sharing this.
Building an open source solution with a "pro" level all setup included in it. I had a very hard time quantifying how much companies will pay for this and whether they even will.
How I see it, you are either on Heroku (or other similar) and you don't care about anything except `git push` or you have a full blown stack.
I know the middle ground between the two is where the stack is but I just couldn't figure out how many companies are actually experiencing those difficulties and how much are they willing to pay for the help.
Since it's not a startup for me, it's just an open source project I decided not to worry about it, but would still be nice to get some input.
[0] https://segment.com/blog/the-segment-aws-stack/images/main.p...
This seems custom to me, maybe Sketch or something.