To assign your API token as an environment variable, run the following command, entering your API token and the path to your private SSH when prompted:Įcho Enter your DigitalOcean API token? read token export TF_VAR_do_token=$token This can be useful for storing variable values that are consistent across your DigitalOcean Terraform deployments, such as your API token or datacenter regions. This allows Terraform to access your DigitalOcean account via the API.Įnvironment variables are stored on your operating system outside of your working directory. Step 2: Configure Terraform Environment Variablesīefore running Terraform commands, you need to assign your API token as an environment variable. This directory is where you execute Terraform commands from. ![]() Once you download the repository, move to the 01-minimal-web-db-stack directory:Ĭd terraform-sample-digitalocean-architectures/01-minimal-web-db-stack This does not require a GitHub account.įirst, download the repository to your system: ![]() You need to download this repository to your machine to deploy the resources. We created a GitHub repository with several Terraform configuration files that compose the web architecture. Step 1: Download the DigitalOcean Sample Terraform Repo To avoid unwanted charges, the last step of this tutorial destroys all of this tutorial’s resources. These resources incur charges for as long as you keep them running. This tutorial deploys real resources into your account. If you are using the in-browser terminal for this tutorial, Terraform has already been installed. Terraform is available for MacOS, Windows, Linux, and FreeBSD. You need to install Terraform on the machine you are deploying from. This is the SSH key that Terraform applies to the Droplets being deployed. You need to have an SSH key and upload your public key to your DigitalOcean account. The domain name allows you to access the newly deployed Droplets via a hostname. You need to own a domain name and have its DNS records hosted by DigitalOcean. ![]() This allows Terraform to access the DigitalOcean API and programmatically deploy resources into your account. You need to create an API token in your DigitalOcean account. Configurationīefore starting this tutorial, you need four things: It may take a minute to load and initialize the interactive environment. To launch the in-browser terminal, hover over any code block and click Launch Terminal. If you use the in-browser terminal, you can click any command in this tutorial to paste them into the command line and run them from within your browser. You can follow this tutorial using a terminal on your local computer or with the in-browser terminal available on this page. The architecture includes three Droplets attached to a database and a load balancer in a VPC network:Īt the end of this tutorial, you can visit a small website being hosted by your Droplets in your web browser. This tutorial teaches you how to use Terraform to deploy a sample web application to your DigitalOcean account.
0 Comments
Leave a Reply. |