Terraform - EC2 - Agent에서 arm test를 위한 ec2 생성

This commit is contained in:
dsk-minchulahn
2024-01-25 14:26:26 +09:00
parent 75fcc67a4c
commit c8f14a323d
6 changed files with 130 additions and 0 deletions

View File

@@ -0,0 +1,25 @@
# This file is maintained automatically by "terraform init".
# Manual edits may be lost in future updates.
provider "registry.terraform.io/hashicorp/aws" {
version = "5.33.0"
constraints = "~> 5.0"
hashes = [
"h1:rAmKVvvzUqVocFppyheelWGnyfCcIGxLV31iFBY2sz4=",
"zh:10bb683f2a9306e881f51a971ad3b2bb654ac94b54945dd63769876a343b5b04",
"zh:3916406db958d5487ea0c2d2320012d1907c29e6d01bf693560fe05e38ee0601",
"zh:3cb54b76b2f9e30620f3281ab7fb20633b1e4584fc84cc4ecd5752546252e86f",
"zh:513bcfd6971482215c5d64725189f875cbcbd260c6d11f0da4d66321efd93a92",
"zh:545a34427ebe7a950056627e7c980c9ba16318bf086d300eb808ffc41c52b7a8",
"zh:5a44b90faf1c8e8269f389c04bfac25ad4766d26360e7f7ac371be12a442981c",
"zh:64e1ef83162f78538dccad8b035577738851395ba774d6919cb21eb465a21e3a",
"zh:7315c70cb6b7f975471ea6129474639a08c58c071afc95a36cfaa41a13ae7fb9",
"zh:9806faae58938d638b757f54414400be998dddb45edfd4a29c85e827111dc93d",
"zh:997fa2e2db242354d9f772fba7eb17bd6d18d28480291dd93f85a18ca0a67ac2",
"zh:9b12af85486a96aedd8d7984b0ff811a4b42e3d88dad1a3fb4c0b580d04fa425",
"zh:9f9e076b7e9752971f39eead6eda69df1c5e890c82ba2ca95f56974af7adfe79",
"zh:b1d6af047f96de7f97d38b685654f1aed4356d5060b0e696d87d0270f5d49f75",
"zh:bfb0654b6f34398aeffdf907b744af06733d168db610a2c5747263380f817ac7",
"zh:e25203ee8cedccf60bf450950d533d3c172509bda8af97dbc3bc817d2a503c57",
]
}

View File

@@ -0,0 +1,18 @@
resource "aws_instance" "dsk-agent-arm-host" {
ami = var.AMI_ID
instance_type = var.Instance_Type
key_name = var.Key_Pair
vpc_security_group_ids = [aws_security_group.dsk-agent-allow-security.id]
availability_zone = var.Aavailability_Zone
subnet_id = var.Public_Subnet_2C
root_block_device {
delete_on_termination = true
volume_size = 30
}
tags = {
Name = "dsk-agent-arm-host"
}
}

View File

@@ -0,0 +1,4 @@
# Configure the AWS Provider
provider "aws" {
region = var.REGION
}

View File

@@ -0,0 +1,41 @@
resource "aws_security_group" "dsk-agent-allow-security" {
name = "dsk-agent-allow-security"
description = "Allow inbound traffic"
vpc_id = var.VPC_ID
ingress {
description = "Allow SSH traffic"
from_port = 22
to_port = 22
protocol = "tcp"
cidr_blocks = ["39.115.183.236/32"]
}
ingress {
description = "Allow HTTPS traffic"
from_port = 443
to_port = 443
protocol = "tcp"
cidr_blocks = ["39.115.183.236/32"]
}
ingress {
description = "Allow HTTP traffic"
from_port = 80
to_port = 80
protocol = "tcp"
cidr_blocks = ["39.115.183.236/32"]
}
egress {
from_port = 0
to_port = 0
protocol = "-1"
cidr_blocks = ["0.0.0.0/0"]
ipv6_cidr_blocks = ["::/0"]
}
tags = {
Name = "dsk-agent-allow-security"
}
}

View File

@@ -0,0 +1,34 @@
variable "REGION" {
default = "ap-northeast-2"
}
variable "VPC_ID" {
# default VPC
# 172.31.0.0/16
default = "vpc-0507701f168dc33c7"
}
variable "Public_Subnet_2C" {
# 172.31.32.0/20
default = "subnet-076d5e6f5b07d33a5"
}
variable "Aavailability_Zone" {
default = "ap-northeast-2c"
}
variable "Instance_Type" {
# Architecture: arm64
# vCPUs: 2
# Memory: 4
default = "t4g.medium"
}
variable "AMI_ID" {
# Amazon Linux 2023 AMI 2023.3.20240122.0 arm64 HVM kernel-6.1
default = "ami-01f739e4a07abd6a9"
}
variable "Key_Pair" {
default = "devops"
}

View File

@@ -0,0 +1,8 @@
terraform {
required_providers {
aws = {
source = "hashicorp/aws"
version = "~> 5.0"
}
}
}