配置Terraform开发环境(译文)
By robot-v1.0
本文链接 https://www.kyfws.com/games/configuring-terraform-development-environment-zh/
版权声明 本博客所有文章除特别声明外,均采用 BY-NC-SA 许可协议。转载请注明出处!
- 5 分钟阅读 - 2357 个词 阅读量 0配置Terraform开发环境(译文)
原文地址:https://www.codeproject.com/Articles/3215319/Configuring-Terraform-Development-Environment
原文作者:Kevin Mack
译文由本站 robot-v1.0 翻译
前言
How to configure Terraform Development Environment
如何配置Terraform开发环境 最近,我一直在使用一系列开源工具进行大量工作,特别是(I’ve been doing a lot of work with a set of open source tools lately, specifically) TerraForm(TerraForm) 和(and) 封隔器(Packer) . TerraForm的核心是一种将基础架构真正实现为代码的方法,它通过提供一种简单的函数样式语言来实现,您可以在其中创建云的基本实现,然后利用资源提供者进行部署.这些资源提供商可让您部署到各种云平台(完整列表可在此处找到(. TerraForm at its core is a method of implementing truly Infrastructure as Code, and does so by providing a simple function style language where you can create basic implementations for the cloud, and then leverage resource providers to deploy. These resource providers allow you to deploy to variety of cloud platforms (the full list can be found) 这里(here) ).它还为调试,定位提供了强大的支持,并支持所需的状态配置方法,这使在云中维护环境变得更加容易.(). It also provides robust support for debugging, targeting, and supports a desired state configuration approach that makes it much easier to maintain your environments in the cloud.) 话虽这么说,就像大多数开源工具一样,它可能需要针对您的本地开发环境进行一些配置,我希望将这篇文章汇总起来进行描述.以下是配置环境的步骤.(Now that being said, like most open source tools, it can require some configuration for your local development environment and I wanted to put this post together to describe it. Below are the steps to configure your environment.)
步骤1:在Windows 10计算机上安装Windows子系统(Step 1: Install Windows SubSystem on your Windows 10 Machine)
首先,您将需要能够将bash用作Linux子系统的一部分.您可以按照本指南中概述的步骤在Windows 10计算机上启用此功能:(To start with, you will need to be able to leverage bash as part of the Linux Subsystem. You can enable this on a Windows 10 machine, by following the steps outlined in this guide:)
- https://docs.microsoft.com/zh-cn/windows/wsl/install-win10(https://docs.microsoft.com/en-us/windows/wsl/install-win10) 完成此步骤后,您将可以继续使用VS Code和所需的其他组件.(Once you’ve completed this step, you will be able to move forward with VS Code and the other components required.)
步骤2:安装VS Code和Terraform插件(Step 2: Install VS Code and Terraform Plugins)
对于本指南,我们建议使用VS Code作为您的编辑器,VS代码可在多种操作系统上运行,并且是一种非常轻巧的代码编辑器.(For this guide, we recommend VS Code as your editor, VS code works on a variety of operating systems, and is a very light-weight code editor.) 您可以从以下链接下载VS代码:(You can download the VS Code from this link:)
- https://code.visualstudio.com/download(https://code.visualstudio.com/download) 下载并安装VS代码后,我们需要安装(Once you’ve downloaded and installed VS code, we need to install the) VS用于Terraform的代码扩展(VS Code Extension for Terraform) .(.) 然后点击"(Then click “)安装(Install)“和”(” and “)重装(Reload)完成时.这将使您对各种terraform文件类型具有智能感知和支持.(” when completed. This will allow you to have intelli-sense and support for the different terraform file types.)
第三步:打开终端(Step 3: Opening Terminal)
然后,您可以从VS Code应用程序执行其余步骤.转到"(You can then perform the remaining steps from the VS Code application. Go to the “)视图(View)“菜单,然后选择”(” menu and select “)综合终端(integrated terminal)".您将看到终端显示在底部:(”. You will see the terminal appear at the bottom:) 默认情况下,终端设置为"(By default, the terminal is set to “)电源外壳(powershell)", 输入 “(”, type in “)重击(Bash)“切换到Bash脚本.您可以按照以下指导来默认使用shell:(” to switch to Bash Scripting. You can default your shell following this guidance:)
步骤4:在子系统上安装Unzip(Step 4: Install Unzip on Subsystem)
运行以下命令以安装”(Run the following command to install “)解压缩(unzip)在您的Linux子系统上,则需要同时解压缩terraform和packer.(” on your linux subsystem, this will be required to unzip both terraform and packer.)
sudo apt-get install unzip
步骤5:安装TerraForm(Step 5: Install TerraForm)
您将需要执行以下命令来下载和安装Terraform,我们首先需要获取最新版本的terraform.(You will need to execute the following commands to download and install Terraform, we need to start by getting the latest version of terraform.) 转到此链接:(Go to this link:)
- https://www.terraform.io/downloads.html(https://www.terraform.io/downloads.html) 并复制相应链接的TerraForm二进制版本的链接.(And copy the link for the appropriate version of the binaries for TerraForm.) 返回VS Code,然后输入以下命令:(Go back to VS Code, and enter the following command:)
czoyNDpcIndnZXQge3VybCBmb3IgdGVycmFmb3JtfVwiO3tbJiomXX0=
然后依次运行以下命令:(Then run the following commands in sequence:)
czozMTpcInVuemlwIHt0ZXJyYWZvcm0uemlwIGZpbGUgbmFtZX1cIjt7WyYqJl19
czo0MjpcInN1ZG8gbXYgdGVycmFmb3JtIC91c3IvbG9jYWwvYmluL3RlcnJhZm9ybVwiO3tbJiomXX0=
czoyODpcInJtIHt0ZXJyYWZvcm0uemlwIGZpbGUgbmFtZX1cIjt7WyYqJl19
通过键入以下命令来确认安装:(Confirm the installation by typing the following command:)
czoxOTpcInRlcnJhZm9ybSAtLXZlcnNpb25cIjt7WyYqJl19
步骤6:安装Packer(Step 6: Install Packer)
首先,我们需要获取最新版本的打包程序.转到以下URL,然后复制相应版本的URL.(To start with, we need to get the most recent version of packer. Go to the following URL, and copy the URL of the appropriate version.)
- https://www.packer.io/downloads.html(https://www.packer.io/downloads.html) 返回VS Code并执行以下命令:(Go back to VS Code and execute the following commands:)
czoxNzpcIndnZXQge3BhY2tlciB1cmx9XCI7e1smKiZdfQ==
czoyODpcInVuemlwIHtwYWNrZXIuemlwIGZpbGUgbmFtZX1cIjt7WyYqJl19
czozNjpcInN1ZG8gbXYgcGFja2VyIC91c3IvbG9jYWwvYmluL3BhY2tlclwiO3tbJiomXX0=
czoyNTpcInJtIHtwYWNrZXIuemlwIGZpbGUgbmFtZX1cIjt7WyYqJl19
步骤7:安装Azure CLI 2.0(Step 7: Install Azure CLI 2.0)
再次返回VS代码,然后下载/安装Azure CLI.为此,请执行以下步骤和命令:(Go back to VS code again, and download / install Azure CLI. To do so, execute the steps and commands found here:)
步骤8:针对Azure进行身份验证(Step 8: Authenticating against Azure)
完成此操作后,您将可以在其中运行terraform项目,但在此之前,您需要针对Azure进行身份验证.这可以通过在bash终端中运行以下命令来完成(请参见下面的链接):(Once this is done, you are in a place where you can run terraform projects, but before you do, you need to authenticate against Azure. This can be done by running the following commands in the bash terminal (see link below):)
- https://docs.microsoft.com/zh-CN/azure/azure-government/documentation-government-get-started-connect-with-cli(https://docs.microsoft.com/en-us/azure/azure-government/documentation-government-get-started-connect-with-cli) 完成此操作后,您将通过Azure进行身份验证,并将能够更新各种环境的文档.(Once that is completed, you will be authenticated against Azure and will be able to update the documentation for the various environments.) 注意:如果您收到有关过期令牌的消息,则身份验证令牌将过期,请输入命令以刷新:(NOTE: Your authentication token will expire, should you get a message about an expired token, enter the command, to refresh:)
czoyNzpcImF6IGFjY291bnQgZ2V0LWFjY2Vzcy10b2tlblwiO3tbJiomXX0=
令牌寿命可以在这里描述:(Token lifetimes can be described here:)
- https://docs.microsoft.com/zh-CN/azure/active-directory/develop/active-directory-token-and-claims#access-tokens(https://docs.microsoft.com/en-us/azure/active-directory/develop/active-directory-token-and-claims#access-tokens) 之后,您就可以在本地计算机上使用Terraform了.(After that, you are ready to use Terraform on your local machine.)
许可
本文以及所有相关的源代码和文件均已获得The Code Project Open License (CPOL)的许可。
HTML Linux cloud Win10 Windows Azure COM 新闻 翻译