The SQL database servers use the available memory for caching to speed up the database operation. If we do not restrict the SQL database server memory usage, the operating system will not have enough memory to run. This setting is also necessary for an AWS RDS instance, otherwise, you will get the alert

ALARM FreeableMemory <=… MB

In AWS we can specify the maximum SQL server memory dynamically, so every RDS instance type will leave enough memory for the operating system regardless of the size of the available memory size. in this example, we will leave 1.5 GB (1536 MB) memory for the operating system so the default 1024 MB free memory alarm will not sound.

DBInstanceClassMemory returns the total memory size in bytes, so we need to convert the value to MB, to be able to set the value of “max server memory (mb)” to the correct number.

If you use Terraform to create your RDS instance, create a script with the aws_db_parameter_group resource to create a Parameter Group in your AWS account. You need to execute it once, as all RDS instances will use the same group.

In the RDS instance creation script assign the Parameter Group to the RDS instance and increase the timeout of the create and delete operations to make sure Terraform waits during the creation and deletion process.

If you just start to work with Terraform Enterprise, you need to create a Terraform environment.

Preparation

GitHub account

To access GitHub from Terraform Enterprise, create a GitHub team and account with admin access to the GitHub repository that will store the Terraform scripts.

Create a GitHub team who will have admin access to the Terraform script repository,

Create a GitHub user what Terraform Enterprise will use to access the Terraform script repository,

Add the new GitHub user to your GitHub organization,

Log into GitHub with the new user account credentials and wait for the email verification email from GitHub,

Open the verification email from GitHub and click the button in the email to verify your email address,

Stay logged into GitHub with the new user account and wait for the invitation email from GitHub to join the organization,

Open the invitation email from GitHub and click the button to accept the invitation,

In GitHub add the new GitHub user to the new team,

Create a GitHub repository to store the Terraform scripts,

Add the new team to the Terraform script repository with admin rights.

If the Terraform modules are in a separate GitHub repository, add the new team to that repository with Read rights.

AWS account

Create a new user account that Terraform Enterprise will use to access AWS

Create a new AWS user,

Add user rights

AmazonEC2FullAccess

AmazonS3FullAccess

Connect your Atlas account to GitHub

We will authorize Terraform Enterprise to access the Terraform script GitHub repository. We set this connection up in our personal profile in Terraform enterprise, but when we create new Terraform environments Terraform Enterprise will use this connection to access the GitHub repository the environment will be connected to. Do not use your personal GitHub account to make the connection, because if your personal account loses access to the GitHub repository, the Terraform environment will not be able to connect to it. For this connection, we have already created a new user in GitHub above.

In a web browser log into GitHub with the user account you want Terraform Enterprise use to access the GitHub repository,

On the GitHub authorization page click the Authorize hashicorp button,

Later if you want to unlink Atlas from your GitHub account, in the Personal section select Connections, and click the Unlink button.

Create the GitHub repository

Create a repository in GitHub to store the Terraform config files. You can specify subdirectories for each Terraform environment to watch, so one repository can serve the security group creation, and EC2 instance creation for the same developer group.

Create the GitHub repository,

Create a folder that the Terraform Enterprise environment will monitor for changes.

Create a new environment

In the dropdown list of the New Environment page (click the text of the dropdown, not the arrow) select Link to GitHub.Name the environment to include the type of the server you want to launch and the server environment, for example, test_linux_sandbox.
To save the environment click the Create & Continue button,

On the left side select Variables,

In the Environment section click the Edit button,

If the environment is linked to the Terraform Enterprise Server

The environment has been created. Click the your account settings page to create a personal token. It will allow you to access your account without using your username and password.

Enter a description for the token and click the Generate Token button,

Save the token value at a safe place

To return back to the Runs page select Terraform Enterprise in the upper left corner

Click the name of the environment you want to work with

Configure the environment. On the left side click Settings

Uncheck Plan on artifact uploads

Store your personal access token on your workstation to be able to access Terraform Enterprise. Open a Bash window and execute the export command:

export ATLAS_TOKEN=[YOUR AUTHENTICATION TOKEN]

Add the terraform backend configuration to the .tf file on your workstation

When you launch a server instance with Terraform, sometimes the error message does not contain the underlying cause. When the cloud provider cannot complete the request, many times Terraform displays a generic error message:

Starting with Terraform version 0.7.3 you can only define a variable once within a directory or a module. Before that release you could copy variable definition files from other modules and did not throw an error if you had the same variable defined in multiple files within the module.

In the new version of Terraform if you define the same variable name multiple times within the module you will get the following error message,

Move the Git repositories to a new workstation

Execute the following command in all Git repositories on the new workstation.

git reset --hard

Terraform

Copying Terraform scripts from a Windows workstation

If the Terraform scripts reference modules, terraform creates symbolic links to those modules in the .terraform/modules directories. When you try to copy those symbolic links on a Windows machine the copy process stops. To copy the Terraform scripts