The New Stack Podcast

Terraform's Best Practices and Pitfalls

Episode Summary

Wix is a cloud-based development site for making HTML 5 websites and mobile sites with drag and drop tools. It is suited for the beginning user or the advanced developer, said Hila Fish, senior DevOps engineer for Wix, in an interview for The New Stack Makers at HashiCorp’s HashiConf Global conference in Los Angeles earlier this month.

Episode Notes

Wix is a cloud-based development site for making HTML 5 websites and mobile sites with drag and drop tools. It is suited for the beginning user or the advanced developer, said Hila Fish, senior DevOps engineer for Wix, in an interview for The New Stack Makers at HashiCorp’s HashiConf Global conference in Los Angeles earlier this month.

 

Our questions for Fish focused on Terraform, the open source infrastructure-as-code software tool:

 

 

Fish started using Terraform in an ad-hoc manner back in 2018. Over time she has learned how to use it for scaling operations.

 

“If you want to scale your infrastructure, you need to use Terraform in a way that will allow you to do that,” Fish said. 

 

Terraform can be used ad-hoc to create a machine as a resource, but scale comes with enabling infrastructure that allows the engineers to develop templates that get reused across many servers.

 

“You need to use it in a way that will allow you to scale up as much as you can,” Fish said.

 

Fish said best practices come from how to structure the Terraform code base.

 

Much of it comes down to the teams and how Terraform gets implemented. Engineers each have their way of working. Standard practices can help. In onboarding new teams, a structured code base can be beneficial. New teams onboard and use models already in the code base.

 

And what are some of the pitfalls of using Terraform?

 

We get to that in the recording and more about integrations, why Wix is still on version 0.13, and some new capabilities for developers to use Terraform.

 

Users have historically needed to learn HashiCorp configuration language (HCL) to use the HashiCorp configuration language. At Wix, Fish said, the company is implementing Terraform on the backend with a UI that developers can use without needing to learn HCL.

Episode Transcription

Colleen Coll  0:07  

Welcome to this special edition of the new stack makers on the road. We're here in beautiful Los Angeles had hashey Calm logo, discussions from the show floor with technologists giving you their expertise and insights to help you with your everyday work. Infrastructure enables innovation hashey Corp provides consistent workflows to provision, secure, connect and run any infrastructure for any application.

 

Alex Williams  0:40  

Hey, everyone, we are at hashey. conf in Los Angeles, California, and I'm here with heel of fish, a senior DevOps engineer at Wix, tell us about Wix.

 

Hila Fish  0:56  

So IX, first of all, it's an awesome company to work for, okay. But for a user experience, it's basically a platform for building websites for either tech savvy people or not. So whether you're, you have your ways with computer, then we provide enhanced features for you to incorporate your own code and stuff like that. And if you don't know nothing about computers, we talk you through how to build a website, which is very sophisticated, very professional. And you don't need to know anything about computers in order to achieve a great result,

 

Alex Williams  1:25  

which was make for a complex back end, but we'll get to that in a second. What we want to cover today is a little bit about how do you make the most of TerraForm. When scaling your infrastructure, as your organization grows? How have you done that? Best practices, some pitfalls to avoid, and what you need to do to keep scaling across your teams, and avoid refactoring so you can keep the integrations elegant and working. My first question that I like to ask is, what version of TerraForm are you using right now?

 

Hila Fish  2:01  

Nice one, gon play well, using zero point 14, not nice, I know. But since we use telephone, across the entire company, although there are you know, versions defined per folder, which I can elaborate in a bit. Still, we want to have like an aligned way of using telephone. So that's why most people use telephone zero point 14. But some places are with

 

Alex Williams  2:25  

1.0. What's the latest version of TerraForm? Right now, one point a four, I believe 1.4. Why have you not gone from point one, four to one or no. And then beyond that,

 

Hila Fish  2:38  

you know, as a system engineer in my background, and now DevOps engineer, the thing is that we don't want to rock the boat too much if we don't have to, and when you want to upgrade is because there are security fixes all the features that you got to have. So we don't have that at the moment, we have not that basic models, but the versions that we have, that we currently use, fulfill our needs. So that's why we're not very eager to upgrade because there isn't like any Holy Grail feature that we kind of have, in order to fulfill something that we want to implement a use case of some sorts. So that's the reason and you know, there are a lot of things to do. And upgrades and stuff like that is usually something in the backlog, but I'm trying to push it because as long as the versions will be progressed, then there will be a greater support for that version, as opposed to older versions. So I'm trying to push but company needs comes first. And if there are new features that needs to be implemented, that this takes precedence.

 

Alex Williams  3:38  

So when did you start using TerraForm? 2000?

 

Hila Fish  3:41  

Let me think

 

Alex Williams  3:43  

18 2018. So how has your use of TerraForm evolved since 2018?

 

Hila Fish  3:50  

Wow, a lot. So at first, I used TerraForm as an ad hoc tool. So like, I need to achieve this, I need to achieve that. And at first, when I just started out, I thought, Okay, this is what cell phone was for, right. But no, once I know evolved in my career, and in my whole, I understood that infrastructure should always evolve and scale because we want to allow politics to get introduced to our day to day in for the company. And in order to allow politics to introduce, we need to allow the tools to make that happen. And telephone allows you to do that. Because if you want to scale your infrastructure, you need to use telephony in a way that will allow you to do that. So for example, if I want to create a machine as opposed to several machines, ad hoc is just create a resource. But if actual scaling is a to create a model that will allow you to recreate a machines all over again, with a single module call. So that's the thing, you need to use it in a way that will allow you to scale up as much as you can and

 

Alex Williams  4:52  

scale back of course, right was that the initial reason for it, like was Wix at a point of high growth in 2018? Was the company just beginning Don't know how old the company is.

 

Hila Fish  5:01  

Actually, I joined Wix just a year ago. Are you joining it a year ago? Yeah. So I use telephone in my two previous companies. And then when I joined, I saw that everything is very well maintained and implemented here, and was very good to know. Because that's one reason why I joined Wix. They have a very good engineering group and departments. So that's why I joined because I wanna work with the best. And then when I saw that it actually got implemented as I thought it would be, then I'm like, Okay, that's good. I don't have too much to refactor or too much things to change. Because the infrastructure for TerraForm and TerraForm is a platform as I like to say it was already down so I can just use it in the best way possible.

 

Alex Williams  5:40  

So what is that best way possible that you want to use TerraForm, there are

 

Hila Fish  5:44  

ways to structure your TerraForm code base, you can do it with a lot of things, you can use workspace, you can avoid using workspaces. But you want to use it in a way that will allow everyone to use it in your company, you want to onboard new teams to use TerraForm as well. And to do it in a way that each individual has its own way of doing things. And you don't want to allow that too much. You want to give them independence, but you want to make sure the code will be in a high quality state and follow some standards. So that way, it's actually something that I cover in my talk it hashey Corp as well, is that you can structure the telephone codebase in a way that will allow onboarding of new teams, because of their how you structure the codebase. So you can start with the whole tree will level will be team name, and then project and then the cloud provider and then the region. And that way, there is a new team that created in the covenant, no problem, you just create a new folder. And then they basically reuse the same models that are already there in the codebase. And also, there's something else that I'm covering what's called Pakistanis enforcement, which we use GitHub actions to do all sorts of things. For example, I want to make sure that every developer or DevOps engineer that creates something in the cloud has tags attached to it. Why? Because we want to make sure cost management is in control. And we can follow up on things. And sometimes people forget to add tags. So if there are practices enforcement in place, like we do have, then it means that a PR when I open a PR or pull request on GitHub, then the PR will fail if I didn't add tags, for example, okay, so you can do whatever you want. Any guidelines that you feel is best for your company with respect to the enforcement. And that's why we set it up to make sure that it doesn't matter how many people are using telephone, since they use the same code base like we do and practices enforcement are in place, then we are at ease that they use it in guardrails, basically to make sure that they use it in the best way possible.

 

Alex Williams  7:47  

So you're using it for Team onboarding as one use for it. I mean, it allows you to kind of get more people onto it pretty easy. You're using GitHub actions with it. What are some of the other use cases that you're using TerraForm for, for example, what are some of the integrations that you're there you have with other third parties that fit into the architecture,

 

Hila Fish  8:09  

we have definitely to create the infrastructure. And then when I open a PR, we have integration with Atlantis, which is an open source tool for a PR automation for telephone. So I open a PL, Atlantis automatically runs in the background and runs TerraForm plan. I see the plan, everything looks good that I do Atlantis supply during the you know the GitHub comments. And then two things happen. Both the TerraForm apply gets happening and it gets implemented and the resources gets created in the cloud. But also the side branch gets merged to men. And why is it important because it prevents drifts. And if you only use TerraForm index in remote execution way like we did, then it means that you have no drifts and no differences between what you have in the code as opposed to what you have in the actual environment because no one has done it like outside of the remote execution. What is the lesson? open source tool for TerraForm? Pull Request automation?

 

Alex Williams  9:08  

Okay. Okay. Do you use any other integrations, for instance, with other third party vendors? Do you host your own? Do you use a cloud service?

 

Hila Fish  9:16  

Yeah, we a we host our resources and all our infrastructure on AWS. Okay, also on some occasions on GCP, but mostly on AWS. So we use of course, the AWS provider on TerraForm to create everything on AWS. But other than that tools, not so much only that is one. Okay, great.

 

Alex Williams  9:35  

So what are some of the pitfalls you found in using TerraForm?

 

Hila Fish  9:39  

Okay, so TerraForm has its own timeout, which you can define but most people think that most people don't define it. So if you create resources that will make TerraForm wait for the API calls to get happening. If I create a VM that rely on Spot Instances to happen, and Spot Instances when is the price that I pay for for the host, then, if the price wasn't right, I need to wait and wait and wait. So when I just started out with telephone, I did Ctrl C, when telephones apply, then it's not good, it will mess up your state. And I don't know if they fix it by or not on or not. But this is a show that I have on my tongue that I don't want to find out, it can be very ugly to mess up your state like that, because it's very hard to recover if you don't have a backup in place. So you should always treat the telephone state as like something you don't touch. You can have backups, that's good, but you don't change the state manually, because it's gonna get messy. So this is one example, workspaces. Also, again, I'm talking about Dell from open source, mainly, Dell from Cloud enterprise. Of course, they have their own implementations and enhanced features. But in open source telephone, workspace could be sometimes a tricky, and I used workspaces in my previous company. And how do you use workspaces with the CLI TerraForm workspace select X, like manually change the workspace. So if I forgot to do the switch, then I could potentially harm my production environment because I applied the TerraForm code on the wrong workspace. So that's why we had a telephone CLI wrapper that did the switch of the work workspaces for me to make sure that there's no human errors, and I have the computer to worry about that. So there are things to be careful. And when you work with telephone to make sure that you will use it in a way that doesn't get back to you after.

 

Alex Williams  11:32  

So what's next for Wix using TerraForm?

 

Hila Fish  11:35  

Actually, I'm not sure if I can talk about it, because I'm not sure if it's official or not, we are taking it to the next level. And having telephone Mo is the back end and have the UI will be a bit different. And we have a different tool that will allow developers that don't know anything about TerraForm to still create TerraForm code, which will get created in the background. But they have very much simpler UI to do that. Why are you why are you doing that? To allow even more people to use TerraForm. And not only people that know TerraForm code, because it is a language of its own. Of course, if you think about developers, they write much more complex code. And so TerraForm code could should be easier for them. But some developers don't want to learn or think, Oh, it's too simple for them to grasp the differences between how to implement infrastructure code as opposed to application code. So we want to make things easier for them.

 

Alex Williams  12:30  

So these are application engineers and application developers. Yeah, necessarily platform engineers. Yeah, or DevOps teams. These are the people who are building out apps on the front end,

 

Hila Fish  12:40  

right. So if, for example, they built an application, they want to test it out, and they need to deploy it, then we will allow them to do that through this UI and then apply it or destroy it afterwards, because it's only a test. That way we enable them to focus and to move forward without having to wait for me to create the infrastructure for them.

 

Alex Williams  13:02  

Excellent. Hilah. Thank you so much for taking the time to talk. I will just add that I did watch your videos from hashey Corp in Europe, I believe where you spoken, I learned that your lead singer in a cover band. So that's pretty awesome. Thank

 

Hila Fish  13:16  

you. Thanks. So

 

Alex Williams  13:17  

we'd ask you to sing but you know, we'll have we'll maybe another time. Nope. All

 

Hila Fish  13:21  

right. Okay, if you check my YouTube channel, you can find a lot of videos of me.

 

Alex Williams  13:26  

Oh, great. All right. We'll have to find one of those. I said in the story. Alright, thank you so much.

 

Hila Fish  13:30  

Thank you.

 

Colleen Coll  13:32  

Infrastructure enables innovation. hashey Corp provides consistent workflows to provision, secure, connect, and run any infrastructure for any application.

 

Alex Williams  13:44  

Thanks for listening. If you liked the show, please rate and review us on Apple podcast Spotify, or wherever you get your podcasts. That's one of the best ways you can help us grow this community. And we really appreciate your feedback. You can find the full video version of this episode on YouTube. Search for the new stack and don't forget to subscribe so you never miss any new videos. Thanks for joining us and see you soon.

 

Transcribed by https://otter.ai