question: create a guide for new terraform users on how to set up their first aws ec2 instance. ensure the guide includes step-by-step instructions, mentions common pitfalls, and offers suggestions for best practices. the guide should be in english and lowercase, and end with the phrase "happy provisioning!".
answer: sure! here's a guide for new terraform users on setting up their first aws ec2 instance:
  
  ### step 1: install terraform
  
  - download terraform from the [official website](https://www.terraform.io/downloads.html).
  - unzip the downloaded file and place the executable in a directory included in your system's `path`.
  - verify the installation by running `terraform --version` in your terminal.
  
  ### step 2: configure aws credentials
  
  - install the aws cli from the [official aws website](https://aws.amazon.com/cli/).
  - configure your aws credentials by running `aws configure` in your terminal.
  - enter your aws access key id, secret access key, region, and output format when prompted.
  
  ### step 3: create a terraform configuration file
  
  - create a new directory for your terraform project.
  - inside this directory, create a file named `main.tf`.
  - open `main.tf` and add the following basic configuration:
  
  ```hcl
  provider "aws" {
    region = "us-east-1"  # choose your preferred region
  }
  
  resource "aws_instance" "example" {
    ami           = "ami-0c55b159cbfafe1f0"  # use a valid ami id for your region
    instance_type = "t2.micro"
  
    tags = {
      Name = "MyFirstInstance"
    }
  }
  ```
  
  ### step 4: initialize your terraform project
  
  - navigate to your project directory in the terminal.
  - run `terraform init` to initialize your project. this downloads necessary plugins.
  
  ### step 5: plan and apply your configuration
  
  - run `terraform plan` to see what changes will be made. this helps catch errors before applying changes.
  - if the plan looks good, run `terraform apply`. review the proposed changes and type `yes` to confirm.
  
  ### step 6: verify the instance
  
  - after the apply completes, note the public ip address output.
  - connect to your instance using ssh: `ssh -i /path/to/your/key.pem ec2-user@your-public-ip`.
  
  ### common pitfalls
  
  - **incorrect ami id**: ensure the ami id is valid for your selected region.
  - **missing ssh key**: if you get an ssh connection error, ensure your key pair is correctly configured and used.
  - **security groups**: make sure your instance's security group allows inbound traffic for ssh (port 22).
  
  ### best practices
  
  - store your terraform state files securely, especially when working in a team.
  - use variables to make your configuration flexible and easily reusable.
  - version your terraform files with a source control system like git.
  
  happy provisioning!