This commit is contained in:
2025-11-18 03:20:27 +00:00
parent c50d803865
commit fadee048d7
49 changed files with 3243 additions and 0 deletions

11
modules/ec2/eks-host.sh Normal file
View File

@ -0,0 +1,11 @@
curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"
unzip awscliv2.zip
sudo ./aws/install
export PATH=/usr/local/bin:$PATH
source ~/.bash_profile
curl -o /usr/local/bin/kubectl https://s3.us-west-2.amazonaws.com/amazon-eks/1.23.13/2022-10-31/bin/linux/amd64/kubectl
chmod +x /usr/local/bin/kubectl
yum install -y jq
yum install -y bash-completion
curl --silent --location "https://github.com/weaveworks/eksctl/releases/latest/download/eksctl_$(uname -s)_amd64.tar.gz" | tar xz -C /tmp
mv -v /tmp/eksctl /usr/local/bin

33
modules/ec2/main.tf Normal file
View File

@ -0,0 +1,33 @@
resource "aws_network_interface" "eni" {
# public subnet 여부에 따라 동작방식이 달라짐.
subnet_id = var.public_ip_associate ? var.public_subnet : var.private_subnet
# private_ips = ["172.16.10.100"]
security_groups = var.sg_list
tags = {
Name = "primary_network_interface"
}
}
resource "aws_instance" "ec2" {
ami = var.ami_name
# "ami-0ab04b3ccbadfae1f"
instance_type = var.instance_type
# "t2.micro"
user_data = var.user_data_file != null ? file(var.user_data_file) : null
tags = {
Name = "${var.tag_name}"
}
primary_network_interface {
network_interface_id = aws_network_interface.eni.id
# device_index = 0
# delete_on_termination = true
# security_groups = var.sg_list
}
key_name = var.key_name
}

9
modules/ec2/mariadb.sh Normal file
View File

@ -0,0 +1,9 @@
cat <<EOF>> /etc/yum.repos.d/MariaDB.repo
[mariadb]
name = MariaDB
baseurl = http://yum.mariadb.org/10.3/centos7-amd64
gpgkey = https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck = 1
EOF
yum install mariadb-server -y
systemctl enable --now mariadb

3
modules/ec2/nginx.sh Normal file
View File

@ -0,0 +1,3 @@
yum update -y
amazon-linux-extras install -y nginx1
systemctl enable --now nginx

16
modules/ec2/outputs.tf Normal file
View File

@ -0,0 +1,16 @@
output "ec2_id" {
value = aws_instance.ec2.id
}
output "public_ip_associate" {
value = aws_instance.ec2.associate_public_ip_address
}
output "sg_id" {
value = aws_network_interface.eni.security_groups
}
output "private_ip" {
value = aws_instance.ec2.private_ip
}

46
modules/ec2/vailables.tf Normal file
View File

@ -0,0 +1,46 @@
variable "ami_name" {
description = "ami name"
type = string
}
variable "instance_type" {
type = string
}
variable "tag_name" {
type = string
}
variable "public_ip_associate" {
type = bool
}
variable "key_name" {
type = string
}
# variable "subnet_id" {
# type = string
# }
variable "public_subnet" {
type = string
}
variable "private_subnet" {
type = string
}
variable "sg_list" {
description = "sg list"
type = list(string)
}
variable "user_data_file" {
type = string
default = null
}
# variable "user_data" {
# type = string
# default = null
# }