Skip to content

Commit

Permalink
terraform lab
Browse files Browse the repository at this point in the history
terraform lab
  • Loading branch information
HieuChayA4 committed Aug 23, 2023
1 parent 3d4a647 commit 85c7911
Show file tree
Hide file tree
Showing 6 changed files with 56 additions and 0 deletions.
9 changes: 9 additions & 0 deletions Terraform/backend.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
terraform {
cloud {
organization = "hieuchaya"

workspaces {
name = "vti-demo-terraform"
}
}
}
Empty file added Terraform/data.tf
Empty file.
Empty file added Terraform/keypair.tf
Empty file.
9 changes: 9 additions & 0 deletions Terraform/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
resource "aws_instance" "this" {
ami = "ami-091a58610910a87a9"
instance_type = var.instance_type
availability_zone = var.az
associate_public_ip_address = var.associate_public_ip_address
subnet_id = "subnet-0987e4da014f80b75"
security_groups = ["sg-0b85f388c1731fb0e"]
tags = var.default_tags
}
16 changes: 16 additions & 0 deletions Terraform/provider.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
provider "aws" {
version = "~> 5.0"
region = "ap-southeast-1"
shared_credentials_files = ["C:/Users/Hieu/.aws/credentials"]
skip_region_validation = true
}

terraform {
required_version = ">= 1.4.0"
required_providers {
aws = {
source = "hashicorp/aws"
version = "~> 5.0"
}
}
}
22 changes: 22 additions & 0 deletions Terraform/variables.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
variable "az" {
default = "ap-southeast-1b"
type = string
}

variable "associate_public_ip_address" {
default = false
type = bool
}

variable "instance_type" {
default = "t2.micro"
type = string

}

variable "default_tags" {
default = {
"Owner" = "Hieu"
}
type = map(string)
}

0 comments on commit 85c7911

Please sign in to comment.