https://github.com/amaurybsouza/terraform-aws-instance
A way to provisioning a EC2 instance on AWS using the best practices of Terraform (constantly updating).
https://github.com/amaurybsouza/terraform-aws-instance
ansible aws aws-cli aws-ec2 cloud cloud-computing devops devops-tools linux terraform terraform-module terraform-provider
Last synced: 6 months ago
JSON representation
A way to provisioning a EC2 instance on AWS using the best practices of Terraform (constantly updating).
- Host: GitHub
- URL: https://github.com/amaurybsouza/terraform-aws-instance
- Owner: amaurybsouza
- Created: 2021-09-01T18:03:11.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2022-09-22T01:26:36.000Z (over 3 years ago)
- Last Synced: 2025-02-07T09:14:51.938Z (about 1 year ago)
- Topics: ansible, aws, aws-cli, aws-ec2, cloud, cloud-computing, devops, devops-tools, linux, terraform, terraform-module, terraform-provider
- Language: HCL
- Homepage: https://medium.com/@amaurybsouza
- Size: 13.7 KB
- Stars: 2
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Terraform AWS EC2
This project is a way to provision a basic EC2 with variables on AWS using Terraform CLI. According to Terraform documentation, it's a good practice create several ".tf" files to organize your project, when invoking any command that loads the Terraform configuration, Terraform loads all configuration files within the directory specified in alphabetical order..
## Credentials on AWS
Use this [article](https://amaurybsouza.medium.com/terraform-e364f5d31570) to create your credentials at AWS.
## Usage
- First of all, check if your code is correct:
```hcl
$ terraform fmt
```
- Prepare your working directory for other commands:
```hcl
$ terraform init
```
- Show changes required by the current configuration:
```hcl
$ terraform plan
```
- Create or update infrastructure:
```hcl
$ terraform apply
```
- Destroy previously-created infrastructure:
```hcl
$ terraform destroy
```
## Basic Examples
- A basic example for provider ```.tf```:
```hcl
terraform {
required_providers {
aws = {
source = "hashicorp/aws"
version = "~> 3.0"
}
}
}
provider "aws" {
region = var.region
}
resource "aws_instance" "tutorials" {
ami = var.ami
instance_type = var.instance_type
}
```
- A basix example for variables ```.tf```:
```hcl
variable "region" {
description = "define what region"
default = "us-east-1"
}
variable "ami" {
description = "define what AMI"
default = "ami-09e67e426f25ce0d7"
}
variable "instance_type" {
description = "value"
default = "t2.micro"
}
```
## Contributing
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
Please make sure to update tests as appropriate.
## License
[MIT](https://choosealicense.com/licenses/mit/)