diff --git a/README.md b/README.md index 8d7cd31..4467abb 100644 --- a/README.md +++ b/README.md @@ -39,6 +39,11 @@ Here is a list of all the examples | ----------------------------------------- | ----------------------------------------------- | | Deploy CloudFront + S3 with Terraform | [here](/examples/aws/cdn/cloudfront-s3) | +#### Compute +| Description | Folder | +| ----------------------------------------- | ----------------------------------------------- | +| Deploy AWS EC2 | [here](/examples/aws/compute/ec2) | + ### GCP Examples #### Database diff --git a/examples/aws/compute/ec2/terraform/main.tf b/examples/aws/compute/ec2/terraform/main.tf new file mode 100644 index 0000000..095d3ee --- /dev/null +++ b/examples/aws/compute/ec2/terraform/main.tf @@ -0,0 +1,22 @@ +terraform { + required_providers { + aws = { + source = "hashicorp/aws" + version = "~> 5.0" + } + } +} + +provider "aws" { + region = var.region +} + +resource "aws_instance" "ec2" { + ami = var.ami_id + instance_type = var.instance_type + + tags = { + Name = var.instance_name + } +} + diff --git a/examples/aws/compute/ec2/terraform/outputs.tf b/examples/aws/compute/ec2/terraform/outputs.tf new file mode 100644 index 0000000..1b3b380 --- /dev/null +++ b/examples/aws/compute/ec2/terraform/outputs.tf @@ -0,0 +1,19 @@ +output "ec2_instance_name" { + description = "Name of EC2 Instance" + value = aws_instance.ec2.tags.Name +} + +output "public_ip" { + description = "The public IP address of the EC2 instance." + value = aws_instance.ec2.public_ip +} + +output "private_ip" { + description = "The private IP address of the EC2 instance." + value = aws_instance.ec2.private_ip +} + +output "public_dns" { + description = "The public DNS name of the EC2 instance." + value = aws_instance.ec2.public_dns +} \ No newline at end of file diff --git a/examples/aws/compute/ec2/terraform/variables.tf b/examples/aws/compute/ec2/terraform/variables.tf new file mode 100644 index 0000000..2867a3d --- /dev/null +++ b/examples/aws/compute/ec2/terraform/variables.tf @@ -0,0 +1,24 @@ +variable "region" { + description = "AWS Region for the EC2 instance." + type = string + default = "eu-central-1" # Replace with your region +} + +variable "ami_id" { + description = "AMI ID for the EC2 instance." + type = string + default = "ami-00d2efe5bc0683614" # Replace with a valid AMI ID for your region +} + +variable "instance_type" { + description = "Instance type for EC2" + type = string + default = "t2.micro" +} + +variable "instance_name" { + description = "Instance Name for EC2" + type = string + default = "qovery_server" +} +