# 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


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://blog.securescape.cc/offensive-security/red-team/offensive-development/infrastructure-development-wip/infrastructure-as-code/terraform/going-to-the-cloud.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
