# Going to the Cloud

Now that we have a basic understanding on how to use Terraform, we can look into more intermediate usages by utilising cloud providers. Since servers require a lot more info such as the network CIDRs, inbound and outbound connections, image IDs and more, we will need to start organising our files from the get-go to reduce the amount of clutter we might get later on when we scale.

### AWS Provider

Start by setting up your providers.tf file in accordance to the [AWS Provider documentation](https://registry.terraform.io/providers/hashicorp/aws/latest/docs).

{% code title="providers.tf" %}

```hcl
terraform {
  required_providers {
    aws = {
      source = "hashicorp/aws"
      version = "~> 5.70.0"
    }
  }
}

provider "aws" {
  region = "us-east-1" # Default for now, we will turn this into a variable later on
}
```

{% endcode %}

Now, initialise this environment with `terraform init` so you have the files necessary to create resources, then log into your AWS User/IAM through the [AWS CLI](https://aws.amazon.com/cli/) tool if you have not already.

<details>

<summary>Note on storing secrets</summary>

You can store authentication inside of the provider's config though this is not recommended unless if you're using a secrets vault. We'll look into this more when we integrate it into a DevOps server

```hcl
provider "aws" {
  region     = "us-west-2"
  access_key = "my-access-key"
  secret_key = "my-secret-key" # Bad Practice
}
```

</details>

### Creating an EC2 Instance
