terraform - aws instance 파일 정리

This commit is contained in:
dsk-minchulahn
2023-11-21 11:45:48 +09:00
parent 7796d39318
commit bb490c3de0
21 changed files with 0 additions and 0 deletions

View File

@@ -0,0 +1,44 @@
# This file is maintained automatically by "terraform init".
# Manual edits may be lost in future updates.
provider "registry.terraform.io/hashicorp/archive" {
version = "1.3.0"
constraints = "~> 1.3"
hashes = [
"h1:T3DszgOa/75SiiONgEDRujpN5rSqIw9TvFZXHjpqMB4=",
"zh:115aa6bc7825402a8d4e2e954378a9f48e4fdbeabe081ffd04e0a2f6786159bb",
"zh:21f731ffac20a67615c64a7a8a96949c971ee28ffd5807d8c299faba73b5e273",
"zh:2e81b58e141b175cbf801ade5e87c5db4cb28933216b0547ef32c95500385904",
"zh:3acbb96fd142b4d193dc18861340281249301368029169e346d15410d0572492",
"zh:4346edee0dfe97154b6f28d9ef0fa762131db92b78bbd1b3207945201cb59818",
"zh:93916a84cc6ff6778456dd170a657326c4dd3a86b4434e424a66a87c2535b888",
"zh:ade675c3ac8b9ec91131bac5881fbd4efad46a3683f2fea2efb9493a2c1b9ffb",
"zh:b0a0cb13fc850903aa7a057ae7e06366939b8f347926dce1137cd47b9123ad93",
"zh:d6d838cceffb7f3ff27fb9b51d78fccdef15bd32408f33a726556bfe66315bd3",
"zh:ddc4ac6aea6537f8096ffeb8ff3bca355f0972793184e0f6df120aa6460b4446",
"zh:e0d1213625d40d124bd9570f0d92907416f8d61bc8c389c776e72c0a97020cce",
"zh:eb707b69f9093b97d98e2dece9822852a27849dd1627d35302e8d6b9801407ef",
]
}
provider "registry.terraform.io/hashicorp/aws" {
version = "5.5.0"
hashes = [
"h1:WOweXv4ZjePZwdxuzE2UmRWOPhhcQDNxGu2wOcpHFWY=",
"zh:10fe0ef4191323c920c1844f27dbc88114547d5f78fad915c1769c908f40d916",
"zh:565fc7c3a1f42474fa75f143cb8115e11b894ed7fd9973569b00bd429fb92b4e",
"zh:5ba6132b1d442ed679ad8ea89fb5602aa0893e8dcd002a52ab3d76591aa18c8b",
"zh:5c2580630cd5034bae800445074c17950aea17f089bcdae7af637173122f8b03",
"zh:656d77220c6053fd5adb86d3bfb57dd42f98220d81590ffd643156ffeca36608",
"zh:65c7b3e333b734ce641735a23539d4fb392a675a5a9b892e8369781b1f3386a2",
"zh:682d55b2e6e9c40e20d679aa53d561797b1f3450e5187c9f4e8c359b69f06df3",
"zh:79ebc0993d6128819d70dd896cd743e3bab3e3cdc4c02f2a2dbd138471c23179",
"zh:8d44214c738f0410f829e1c761b021c92b3364daf9fcd08097216cc84eaff997",
"zh:9b12af85486a96aedd8d7984b0ff811a4b42e3d88dad1a3fb4c0b580d04fa425",
"zh:a0b1bc008e95c5a7285f5e7dd116ce60ba7a6c1c3bd8ac3e3b63d4e1438d8e49",
"zh:cf40fb60efc5df42fc5716c7e458868251c82fc78b623f12d1bc994b6fcc7ef2",
"zh:cfd8f3f391cddecfc5e44fe57f0633067470e9038517115ba69d8ee533d5d74e",
"zh:d6552490599e02a756e72b7091b591493cee25548ce7120ad05210b4ff2492bd",
"zh:f77dfe665fd4b3d9e36fdc989d7feff4cf6bf17161c0b1a0f25a0fcf402c779d",
]
}

View File

@@ -0,0 +1,32 @@
resource "aws_instance" "dskdemo" {
ami = "ami-0c27244ec9d87b4e8"
instance_type = "t3.small"
key_name = "kp-jay-bastion-datasaker"
vpc_security_group_ids = [aws_security_group.dskdemo-allow-security.id]
availability_zone = "ap-northeast-2c"
subnet_id = var.Public_Subnet_ID_3
root_block_device {
delete_on_termination = true
volume_size = 30
}
tags = {
Name = "dskdemo"
}
}
resource "aws_ebs_volume" "dskdemo_ebs" {
availability_zone = aws_instance.dskdemo.availability_zone
size = 100
tags = {
Name = "dskdemo-ebs"
}
}
resource "aws_volume_attachment" "dskdemo_ebs_attach" {
device_name = "/dev/xvdf"
volume_id = aws_ebs_volume.dskdemo_ebs.id
instance_id = aws_instance.dskdemo.id
}

View File

@@ -0,0 +1,32 @@
resource "aws_instance" "dskdemo2" {
ami = "ami-0c27244ec9d87b4e8"
instance_type = "t3.small"
key_name = "kp-jay-bastion-datasaker"
vpc_security_group_ids = [aws_security_group.dskdemo-allow-security.id]
availability_zone = "ap-northeast-2c"
subnet_id = var.Public_Subnet_ID_3
root_block_device {
delete_on_termination = true
volume_size = 30
}
tags = {
Name = "dskdemo2"
}
}
resource "aws_ebs_volume" "dskdemo2_ebs" {
availability_zone = aws_instance.dskdemo2.availability_zone
size = 100
tags = {
Name = "dskdemo2-ebs"
}
}
resource "aws_volume_attachment" "dskdemo2_ebs_attach" {
device_name = "/dev/xvdf"
volume_id = aws_ebs_volume.dskdemo2_ebs.id
instance_id = aws_instance.dskdemo2.id
}

View File

@@ -0,0 +1,10 @@
provider "aws" {
region = "ap-northeast-2"
}
terraform {
required_providers {
archive = "~> 1.3"
}
}

View File

@@ -0,0 +1,73 @@
resource "aws_security_group" "dskdemo-allow-security" {
name = "dskdemo-allow-security-new"
description = "Allow inbound traffic"
vpc_id = var.VPC_ID
ingress {
description = "SSH"
from_port = 22
to_port = 22
protocol = "tcp"
cidr_blocks = ["118.223.123.161/32"]
}
ingress {
description = "etcd"
from_port = 2379
to_port = 2380
protocol = "tcp"
cidr_blocks = ["172.24.2.0/24"]
}
ingress {
description = "kubelet api"
from_port = 10250
to_port = 10250
protocol = "tcp"
cidr_blocks = ["172.24.2.0/24"]
}
ingress {
description = "Cilium Geneve or VXLAN"
from_port = 8472
to_port = 8472
protocol = "tcp"
cidr_blocks = ["172.24.2.0/24"]
}
ingress {
description = "Cilium Health Check"
from_port = 4240
to_port = 4240
protocol = "tcp"
cidr_blocks = ["172.24.2.0/24"]
}
ingress {
description = "api-server"
from_port = 6443
to_port = 6443
protocol = "tcp"
cidr_blocks = ["172.24.2.0/24"]
}
ingress {
description = "node port range"
from_port = 30000
to_port = 32767
protocol = "tcp"
cidr_blocks = ["172.24.2.0/24"]
}
ingress {
description = "Cilium Operator"
from_port = 2379
to_port = 2379
protocol = "tcp"
cidr_blocks = ["172.24.2.0/24"]
}
egress {
from_port = 0
to_port = 0
protocol = "-1"
cidr_blocks = ["0.0.0.0/0"]
ipv6_cidr_blocks = ["::/0"]
}
tags = {
Name = "dskdemo-allow-security"
}
}

View File

@@ -0,0 +1,470 @@
{
"version": 4,
"terraform_version": "1.4.6",
"serial": 8,
"lineage": "52e87bf7-135d-91e1-6212-adda0c0c1c37",
"outputs": {},
"resources": [
{
"mode": "managed",
"type": "aws_ebs_volume",
"name": "dskdemo2_ebs",
"provider": "provider[\"registry.terraform.io/hashicorp/aws\"]",
"instances": [
{
"schema_version": 0,
"attributes": {
"arn": "arn:aws:ec2:ap-northeast-2:508259851457:volume/vol-0d940e174d486470d",
"availability_zone": "ap-northeast-2c",
"encrypted": true,
"final_snapshot": false,
"id": "vol-0d940e174d486470d",
"iops": 300,
"kms_key_id": "arn:aws:kms:ap-northeast-2:508259851457:key/fac33ef5-dbc0-4dcb-9be1-1862c6678bfb",
"multi_attach_enabled": false,
"outpost_arn": "",
"size": 100,
"snapshot_id": "",
"tags": {
"Name": "dskdemo2-ebs"
},
"tags_all": {
"Name": "dskdemo2-ebs"
},
"throughput": 0,
"timeouts": null,
"type": "gp2"
},
"sensitive_attributes": [],
"private": "eyJlMmJmYjczMC1lY2FhLTExZTYtOGY4OC0zNDM2M2JjN2M0YzAiOnsiY3JlYXRlIjozMDAwMDAwMDAwMDAsImRlbGV0ZSI6MzAwMDAwMDAwMDAwLCJ1cGRhdGUiOjMwMDAwMDAwMDAwMH19",
"dependencies": [
"aws_instance.dskdemo2",
"aws_security_group.dskdemo-allow-security"
]
}
]
},
{
"mode": "managed",
"type": "aws_ebs_volume",
"name": "dskdemo_ebs",
"provider": "provider[\"registry.terraform.io/hashicorp/aws\"]",
"instances": [
{
"schema_version": 0,
"attributes": {
"arn": "arn:aws:ec2:ap-northeast-2:508259851457:volume/vol-0ac9975e51ec72682",
"availability_zone": "ap-northeast-2c",
"encrypted": true,
"final_snapshot": false,
"id": "vol-0ac9975e51ec72682",
"iops": 300,
"kms_key_id": "arn:aws:kms:ap-northeast-2:508259851457:key/fac33ef5-dbc0-4dcb-9be1-1862c6678bfb",
"multi_attach_enabled": false,
"outpost_arn": "",
"size": 100,
"snapshot_id": "",
"tags": {
"Name": "dskdemo-ebs"
},
"tags_all": {
"Name": "dskdemo-ebs"
},
"throughput": 0,
"timeouts": null,
"type": "gp2"
},
"sensitive_attributes": [],
"private": "eyJlMmJmYjczMC1lY2FhLTExZTYtOGY4OC0zNDM2M2JjN2M0YzAiOnsiY3JlYXRlIjozMDAwMDAwMDAwMDAsImRlbGV0ZSI6MzAwMDAwMDAwMDAwLCJ1cGRhdGUiOjMwMDAwMDAwMDAwMH19",
"dependencies": [
"aws_instance.dskdemo",
"aws_security_group.dskdemo-allow-security"
]
}
]
},
{
"mode": "managed",
"type": "aws_instance",
"name": "dskdemo",
"provider": "provider[\"registry.terraform.io/hashicorp/aws\"]",
"instances": [
{
"schema_version": 1,
"attributes": {
"ami": "ami-0c27244ec9d87b4e8",
"arn": "arn:aws:ec2:ap-northeast-2:508259851457:instance/i-052ddfaa3948d4ee3",
"associate_public_ip_address": false,
"availability_zone": "ap-northeast-2c",
"capacity_reservation_specification": [
{
"capacity_reservation_preference": "open",
"capacity_reservation_target": []
}
],
"cpu_core_count": 1,
"cpu_options": [
{
"amd_sev_snp": "",
"core_count": 1,
"threads_per_core": 2
}
],
"cpu_threads_per_core": 2,
"credit_specification": [
{
"cpu_credits": "unlimited"
}
],
"disable_api_stop": false,
"disable_api_termination": false,
"ebs_block_device": [],
"ebs_optimized": false,
"enclave_options": [
{
"enabled": false
}
],
"ephemeral_block_device": [],
"get_password_data": false,
"hibernation": false,
"host_id": "",
"host_resource_group_arn": null,
"iam_instance_profile": "",
"id": "i-052ddfaa3948d4ee3",
"instance_initiated_shutdown_behavior": "stop",
"instance_lifecycle": "",
"instance_market_options": [],
"instance_state": "running",
"instance_type": "t3.small",
"ipv6_address_count": 0,
"ipv6_addresses": [],
"key_name": "kp-jay-bastion-datasaker",
"launch_template": [],
"maintenance_options": [
{
"auto_recovery": "default"
}
],
"metadata_options": [
{
"http_endpoint": "enabled",
"http_put_response_hop_limit": 1,
"http_tokens": "optional",
"instance_metadata_tags": "disabled"
}
],
"monitoring": false,
"network_interface": [],
"outpost_arn": "",
"password_data": "",
"placement_group": "",
"placement_partition_number": 0,
"primary_network_interface_id": "eni-0945c4acbc3bff8c1",
"private_dns": "i-052ddfaa3948d4ee3.ap-northeast-2.compute.internal",
"private_dns_name_options": [
{
"enable_resource_name_dns_a_record": true,
"enable_resource_name_dns_aaaa_record": false,
"hostname_type": "resource-name"
}
],
"private_ip": "172.24.2.121",
"public_dns": "",
"public_ip": "",
"root_block_device": [
{
"delete_on_termination": true,
"device_name": "/dev/xvda",
"encrypted": true,
"iops": 100,
"kms_key_id": "arn:aws:kms:ap-northeast-2:508259851457:key/fac33ef5-dbc0-4dcb-9be1-1862c6678bfb",
"tags": null,
"throughput": 0,
"volume_id": "vol-013872983cfbbfa2a",
"volume_size": 30,
"volume_type": "gp2"
}
],
"secondary_private_ips": [],
"security_groups": [],
"source_dest_check": true,
"spot_instance_request_id": "",
"subnet_id": "subnet-0073a61bc56a68a3e",
"tags": {
"Name": "dskdemo"
},
"tags_all": {
"Name": "dskdemo"
},
"tenancy": "default",
"timeouts": null,
"user_data": null,
"user_data_base64": null,
"user_data_replace_on_change": false,
"volume_tags": null,
"vpc_security_group_ids": [
"sg-073c247730836f7fd"
]
},
"sensitive_attributes": [],
"private": "eyJlMmJmYjczMC1lY2FhLTExZTYtOGY4OC0zNDM2M2JjN2M0YzAiOnsiY3JlYXRlIjo2MDAwMDAwMDAwMDAsImRlbGV0ZSI6MTIwMDAwMDAwMDAwMCwidXBkYXRlIjo2MDAwMDAwMDAwMDB9LCJzY2hlbWFfdmVyc2lvbiI6IjEifQ==",
"dependencies": [
"aws_security_group.dskdemo-allow-security"
]
}
]
},
{
"mode": "managed",
"type": "aws_instance",
"name": "dskdemo2",
"provider": "provider[\"registry.terraform.io/hashicorp/aws\"]",
"instances": [
{
"schema_version": 1,
"attributes": {
"ami": "ami-0c27244ec9d87b4e8",
"arn": "arn:aws:ec2:ap-northeast-2:508259851457:instance/i-0dad753d4392f5144",
"associate_public_ip_address": false,
"availability_zone": "ap-northeast-2c",
"capacity_reservation_specification": [
{
"capacity_reservation_preference": "open",
"capacity_reservation_target": []
}
],
"cpu_core_count": 1,
"cpu_options": [
{
"amd_sev_snp": "",
"core_count": 1,
"threads_per_core": 2
}
],
"cpu_threads_per_core": 2,
"credit_specification": [
{
"cpu_credits": "unlimited"
}
],
"disable_api_stop": false,
"disable_api_termination": false,
"ebs_block_device": [],
"ebs_optimized": false,
"enclave_options": [
{
"enabled": false
}
],
"ephemeral_block_device": [],
"get_password_data": false,
"hibernation": false,
"host_id": "",
"host_resource_group_arn": null,
"iam_instance_profile": "",
"id": "i-0dad753d4392f5144",
"instance_initiated_shutdown_behavior": "stop",
"instance_lifecycle": "",
"instance_market_options": [],
"instance_state": "running",
"instance_type": "t3.small",
"ipv6_address_count": 0,
"ipv6_addresses": [],
"key_name": "kp-jay-bastion-datasaker",
"launch_template": [],
"maintenance_options": [
{
"auto_recovery": "default"
}
],
"metadata_options": [
{
"http_endpoint": "enabled",
"http_put_response_hop_limit": 1,
"http_tokens": "optional",
"instance_metadata_tags": "disabled"
}
],
"monitoring": false,
"network_interface": [],
"outpost_arn": "",
"password_data": "",
"placement_group": "",
"placement_partition_number": 0,
"primary_network_interface_id": "eni-0289f9f895e56ec92",
"private_dns": "i-0dad753d4392f5144.ap-northeast-2.compute.internal",
"private_dns_name_options": [
{
"enable_resource_name_dns_a_record": true,
"enable_resource_name_dns_aaaa_record": false,
"hostname_type": "resource-name"
}
],
"private_ip": "172.24.2.164",
"public_dns": "",
"public_ip": "",
"root_block_device": [
{
"delete_on_termination": true,
"device_name": "/dev/xvda",
"encrypted": true,
"iops": 100,
"kms_key_id": "arn:aws:kms:ap-northeast-2:508259851457:key/fac33ef5-dbc0-4dcb-9be1-1862c6678bfb",
"tags": null,
"throughput": 0,
"volume_id": "vol-093b7f4eb73d57435",
"volume_size": 30,
"volume_type": "gp2"
}
],
"secondary_private_ips": [],
"security_groups": [],
"source_dest_check": true,
"spot_instance_request_id": "",
"subnet_id": "subnet-0073a61bc56a68a3e",
"tags": {
"Name": "dskdemo2"
},
"tags_all": {
"Name": "dskdemo2"
},
"tenancy": "default",
"timeouts": null,
"user_data": null,
"user_data_base64": null,
"user_data_replace_on_change": false,
"volume_tags": null,
"vpc_security_group_ids": [
"sg-073c247730836f7fd"
]
},
"sensitive_attributes": [],
"private": "eyJlMmJmYjczMC1lY2FhLTExZTYtOGY4OC0zNDM2M2JjN2M0YzAiOnsiY3JlYXRlIjo2MDAwMDAwMDAwMDAsImRlbGV0ZSI6MTIwMDAwMDAwMDAwMCwidXBkYXRlIjo2MDAwMDAwMDAwMDB9LCJzY2hlbWFfdmVyc2lvbiI6IjEifQ==",
"dependencies": [
"aws_security_group.dskdemo-allow-security"
]
}
]
},
{
"mode": "managed",
"type": "aws_security_group",
"name": "dskdemo-allow-security",
"provider": "provider[\"registry.terraform.io/hashicorp/aws\"]",
"instances": [
{
"schema_version": 1,
"attributes": {
"arn": "arn:aws:ec2:ap-northeast-2:508259851457:security-group/sg-073c247730836f7fd",
"description": "Allow inbound traffic",
"egress": [
{
"cidr_blocks": [
"0.0.0.0/0"
],
"description": "",
"from_port": 0,
"ipv6_cidr_blocks": [
"::/0"
],
"prefix_list_ids": [],
"protocol": "-1",
"security_groups": [],
"self": false,
"to_port": 0
}
],
"id": "sg-073c247730836f7fd",
"ingress": [
{
"cidr_blocks": [
"118.223.123.161/32"
],
"description": "SSH",
"from_port": 22,
"ipv6_cidr_blocks": [],
"prefix_list_ids": [],
"protocol": "tcp",
"security_groups": [],
"self": false,
"to_port": 22
}
],
"name": "dskdemo-allow-security-new",
"name_prefix": "",
"owner_id": "508259851457",
"revoke_rules_on_delete": false,
"tags": {
"Name": "dskdemo-allow-security"
},
"tags_all": {
"Name": "dskdemo-allow-security"
},
"timeouts": null,
"vpc_id": "vpc-00ba2b0e9ad59f0ed"
},
"sensitive_attributes": [],
"private": "eyJlMmJmYjczMC1lY2FhLTExZTYtOGY4OC0zNDM2M2JjN2M0YzAiOnsiY3JlYXRlIjo2MDAwMDAwMDAwMDAsImRlbGV0ZSI6OTAwMDAwMDAwMDAwfSwic2NoZW1hX3ZlcnNpb24iOiIxIn0="
}
]
},
{
"mode": "managed",
"type": "aws_volume_attachment",
"name": "dskdemo2_ebs_attach",
"provider": "provider[\"registry.terraform.io/hashicorp/aws\"]",
"instances": [
{
"schema_version": 0,
"attributes": {
"device_name": "/dev/xvdf",
"force_detach": null,
"id": "vai-3450723728",
"instance_id": "i-0dad753d4392f5144",
"skip_destroy": null,
"stop_instance_before_detaching": null,
"timeouts": null,
"volume_id": "vol-0d940e174d486470d"
},
"sensitive_attributes": [],
"private": "eyJlMmJmYjczMC1lY2FhLTExZTYtOGY4OC0zNDM2M2JjN2M0YzAiOnsiY3JlYXRlIjozMDAwMDAwMDAwMDAsImRlbGV0ZSI6MzAwMDAwMDAwMDAwfX0=",
"dependencies": [
"aws_ebs_volume.dskdemo2_ebs",
"aws_instance.dskdemo2",
"aws_security_group.dskdemo-allow-security"
]
}
]
},
{
"mode": "managed",
"type": "aws_volume_attachment",
"name": "dskdemo_ebs_attach",
"provider": "provider[\"registry.terraform.io/hashicorp/aws\"]",
"instances": [
{
"schema_version": 0,
"attributes": {
"device_name": "/dev/xvdf",
"force_detach": null,
"id": "vai-210491461",
"instance_id": "i-052ddfaa3948d4ee3",
"skip_destroy": null,
"stop_instance_before_detaching": null,
"timeouts": null,
"volume_id": "vol-0ac9975e51ec72682"
},
"sensitive_attributes": [],
"private": "eyJlMmJmYjczMC1lY2FhLTExZTYtOGY4OC0zNDM2M2JjN2M0YzAiOnsiY3JlYXRlIjozMDAwMDAwMDAwMDAsImRlbGV0ZSI6MzAwMDAwMDAwMDAwfX0=",
"dependencies": [
"aws_ebs_volume.dskdemo_ebs",
"aws_instance.dskdemo",
"aws_security_group.dskdemo-allow-security"
]
}
]
}
],
"check_results": null
}

View File

@@ -0,0 +1,39 @@
#---------------------------------------------------------------#
# Network ID
variable "VPC_ID" {
default = "vpc-00ba2b0e9ad59f0ed"
}
variable "Network_CIDR" {
default = "172.24.0.0/19"
}
variable "Private_Subnet_ID_1" {
default = "subnet-024f0deda82039fa4"
}
variable "Private_Subnet_ID_2" {
default = "subnet-050d942fa1c46540a"
}
variable "Private_Subnet_ID_3" {
default = "subnet-0946eb806af7377be"
}
variable "Public_Subnet_ID_1" {
default = "subnet-00c363356f133411d"
}
variable "Public_Subnet_ID_2" {
default = "subnet-07aa5e879a262014d"
}
variable "Public_Subnet_ID_3" {
default = "subnet-0073a61bc56a68a3e"
}
variable "datasaker-io" {
default = "Z072735718G25WNVKU834"
}