What is User Data in AWS, Azure, or Terraform?

Problem scenario
You have heard about user data in AWS, Azure, or Terraform. What is it? What does user data include?

AWS User Data versus Terraform User Data

Answer for AWS
Generally it is a customization that the account owner configured to apply to an EC-2 instance when it first launches. It is either a shell script or a cloud-init directive that is used when an EC-2 instance is launched (according to Amazon’s website).

How Do You Write a Terraform Module in AWS?

Problem scenario
You want to write a Terraform module in AWS. What do you do?

Solution
You will use the keyword “module” in a .tf file, and you will use either “terraform init” or “terraform get” to install the module. The directions below were adapted from https://www.howtoforge.com/how-to-create-a-terraform-module/.

Prerequisite
You need to have Terraform installed;

How Do You Use Terraform and Kubernetes in a Simple Way (as a Proof of Concept)?

Problem scenario
You want to use Terraform and Kubernetes (in EKS). How do you do this in a simple way to test it out?

Solution
Prerequisite

This assumes you have deployed EKS. If you need assistance, see this posting.
This assumes you have installed Terraform. If you need assistance, see this posting.

Procedures

  1. This first step is optional.

How Do You Troubleshoot the Terraform Error “Unable to evaluate directory symlink: lstat”?

Updated on 6/4/22 to include possible solutions 2 through 4.

Problem scenario
You are running a terraform command, but you receive this error:

Initializing modules…
– website_contint_bucket in
Error: Unreadable module directory
Unable to evaluate directory symlink: lstat foobar: no such file or directory
Error: Failed to read module directory
Module directory does not exist or cannot be read.

How Do You Troubleshoot The Terraform Error “Authentication using either SSH …must be enabled in Linux profile”?

Problem scenario
You try to run terraform apply to create an Azure VM but you receive a message like this:

Error: Error applying plan:

1 error(s) occurred:

* azurerm_virtual_machine.myterraformvm: 1 error(s) occurred:

* azurerm_virtual_machine.myterraformvm: compute.VirtualMachinesClient#CreateOrUpdate: Failure sending request: StatusCo” Message=”Authentication using either SSH or by user name and password must be enabled in Linux profile.” Target=”linux”

What should you do?

Solution
1.

How Do You Use Terraform to Create AWS Servers?

Problem scenario
You want to use Terraform to deploy EC-2 instances (VMs in AWS).  How do you do this?

Solution
These directions can work on a Linux server in your enterprise, a Linux server in Azure or a Linux server in AWS.

1.  Install Terraform.  See this link if you do not know how.

2.  Create a file like this called contint.tf with this as the content:

provider “aws” {