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:
Error waiting for instance (i-...) to become ready: unexpected state 'terminated', wanted target 'running'
To find the root cause of the error in AWS
- Log into the AWS console and navigate to the EC2 section,
- Search for the instance by the instance Id,
- You can find the error message at the bottom of the Description tab
In our specific case, it was Client.VolumeLimitExceeded: Volume limit exceeded
We had to increase the volume limit to be able to launch more large EC2 instances.
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,
Variable '...': duplicate found. Variable names must be unique.
Make sure a variable is only defined once in the module or directory.
Move the Git repositories to a new workstation
If you want to move Git repositories to your new workstation
- Commit and push all repositories to GitHub on the old workstation,
- Copy the folders from your old workstation to the new,
- Execute the following command in all Git repositories on the new workstation.
git reset --hard
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
- Start Windows explorer in the folder above the Terraform script folders,
- Search for .terraform,
- In the search result list delete the .terraform folders.
If you migrate between Windows and Macintosh you need to update a few paths, because the two operating systems store user specific files at different places.
The ssh_key location in the .kitchen.yml file should start with
- On Macintosh: ~/.aws/
- On Windows: C:\Users\YOUR_USER_NAME\.aws\