-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* move vpc to module * Feature: Terraform CI (#4) * add tf workflow * update ci * update exit command * update return code * update exit code * fmt * update readme * add module * update vpc module * add vm module * add main * fmt * refactor * fmt * simplify vpc route table * fmt * Revert "simplify vpc route table" This reverts commit a8f22db. * update vars * update output
- Loading branch information
Showing
10 changed files
with
129 additions
and
83 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,7 @@ | |
# .tfstate files | ||
*.tfstate | ||
*.tfstate.* | ||
kubeconfig* | ||
|
||
# Crash log files | ||
crash.log | ||
|
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
module "bastion" { | ||
source = "./modules/vm" | ||
ssh_key_pair = var.ssh_key_pair | ||
|
||
vm_name = "bastion_vm" | ||
subnet_id = aws_subnet.main-vpc-subnet-public[0].id | ||
|
||
init_script = "./helper/init.sh" | ||
|
||
security_group_ids = [ | ||
aws_security_group.allow_ssh.id, | ||
aws_security_group.allow_egress.id | ||
] | ||
} | ||
|
||
module "private_bastion" { | ||
source = "./modules/vm" | ||
ssh_key_pair = var.ssh_key_pair | ||
|
||
vm_name = "private_vm" | ||
subnet_id = aws_subnet.main-vpc-subnet-private[0].id | ||
|
||
security_group_ids = [ | ||
aws_security_group.allow_ssh.id, | ||
aws_security_group.allow_egress.id | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
resource "aws_key_pair" "ssh_key_pair" { | ||
key_name = "${var.vm_name}-key" | ||
public_key = var.ssh_key_pair | ||
} | ||
|
||
resource "aws_instance" "vm" { | ||
ami = var.vm_ami | ||
instance_type = var.instance_type | ||
key_name = aws_key_pair.ssh_key_pair.key_name | ||
monitoring = true | ||
|
||
subnet_id = var.subnet_id | ||
|
||
user_data = var.init_script != null ? file(var.init_script) : null | ||
|
||
vpc_security_group_ids = var.security_group_ids | ||
tags = { | ||
Name = var.vm_name | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
output "id" { | ||
value = aws_instance.vm.id | ||
} | ||
|
||
output "public_ip" { | ||
value = aws_instance.vm.public_ip | ||
} | ||
|
||
output "private_ip" { | ||
value = aws_instance.vm.private_ip | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
variable "ssh_key_pair" { | ||
type = string | ||
sensitive = true | ||
} | ||
|
||
variable "vm_ami" { | ||
default = "ami-02453f5468b897e31" #amazon linux | ||
} | ||
|
||
variable "instance_type" { | ||
default = "t2.micro" | ||
} | ||
|
||
variable "vm_name" { | ||
type = string | ||
} | ||
|
||
variable "subnet_id" { | ||
type = string | ||
} | ||
|
||
variable "security_group_ids" { | ||
type = list(string) | ||
} | ||
|
||
variable "init_script" { | ||
type = string | ||
default = null | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
output "bastion-vm" { | ||
value = { | ||
id = module.bastion.id | ||
private_ip = module.bastion.private_ip | ||
public_ip = module.bastion.public_ip | ||
} | ||
} | ||
|
||
output "private-bastion-vm" { | ||
value = { | ||
id = module.private_bastion.id | ||
private_ip = module.private_bastion.private_ip | ||
} | ||
} | ||
|
||
|
||
output "nat-gateway" { | ||
value = { | ||
public_ip = aws_nat_gateway.nat-gw.public_ip | ||
private_ip = aws_nat_gateway.nat-gw.private_ip | ||
} | ||
} | ||
|
||
output "eks" { | ||
value = { | ||
cluster_name = module.eks.cluster_name | ||
cluster_endpoint = module.eks.cluster_endpoint | ||
get_kubeconfig_command = "aws eks update-kubeconfig --name ${module.eks.cluster_name}" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters