diff --git a/spot_221207/script/lambda_restart.sh b/spot_221207/script/lambda_restart.sh new file mode 100755 index 0000000..2e4b800 --- /dev/null +++ b/spot_221207/script/lambda_restart.sh @@ -0,0 +1,102 @@ +if [ -z "$BASH_VERSION" ]; then exec bash "$0" "$@"; exit; fi + +#---------------------------------------------------------------------------------------------------------------- +# 변수 선언 +echo_line="==========================================================================" +search_tag="spot" +stop_function="spot_stop" +start_function="spot_start" + +#---------------------------------------------------------------------------------------------------------------- +# aws 인스턴스 조회 +_get_aws_status (){ + aws_query="Reservations[].Instances[].[ InstanceId, Tags[?Key=='Name'].Value|[0] ]" + aws_filter="Name=instance-state-name,Values=running" + current_ec2_num=`aws ec2 describe-instances --query "${aws_query}" --filter ${aws_filter} --output text | grep ${search_tag} | wc -l` +} + +#---------------------------------------------------------------------------------------------------------------- +# log 출력 +_get_time_log (){ + datetime=`date +'%Y-%m-%d %H:%M:%S'` + string=$1 + echo "[${datetime}] ${string}" +} + +#---------------------------------------------------------------------------------------------------------------- +# aws lambda 실행 후 인스턴스 조회하여 성공/실패 여부 체크 + +_main (){ + lambda_function=$1 + echo ${echo_line} + if [[ ${lambda_fuction} == *"stop"* ]]; then + what_func='stop' + else + what_func='start' + fi + + _get_time_log "[INFO] aws lambda ${lambda_function} start" + + aws lambda invoke --function-name ${lambda_function} --cli-binary-format raw-in-base64-out --payload '{ "key": "value" }' response.json > /tmp/aws_func_result + #echo "aws lambda invoke --function-name ${lambda_function} --cli-binary-format raw-in-base64-out --payload '{ "key": "value" }' response.json" + + succ_flag=0 + while read line + do + if [[ $line == *"200"* ]]; then + succ_flag=1 + _get_time_log "[INFO] aws lambda ${lambda_function} success!" + break + else + succ_flag=0 + fi + done < /tmp/aws_func_result + + if [[ ${succ_flag} == 1 ]]; then + aws lambda invoke --function-name ${lambda_function} out --log-type Tail --query 'LogResult' --output text | base64 -d > /tmp/aws_func_output + if [[ ${what_func} == 'stop' ]]; then + final_ec2_num=0 + else + final_ec2_num=`grep "Starting" /tmp/aws_func_output | wc -l` + fi + + num=0 + while true + do + _get_aws_status + num=`echo $(( $num + 1 ))` + if [[ ${current_ec2_num} == ${final_ec2_num} ]]; then + _get_time_log "[INFO] aws ${search_tag} instance number: ${final_ec2_num} check success!" + break + elif [[ ${num} == 30 ]]; then + _get_time_log "[Error] time out!" + break + else + _get_time_log "[Retry: ${num}] aws ${search_tag} instance number: ${final_ec2_num} checking..." + fi + sleep 5 + done + else + echo ${echo_line} + _get_time_log "[Error] aws lambda ${lambda_function} failed!" + exit + fi + echo ${echo_line} + #--------------- + +} +#---------------------------------------------------------------------------------------------------------------- +# 실행 + +_main ${stop_function} + +_main ${start_function} + +#---------------------------------------------------------------------------------------------------------------- +# 임시 파일 삭제 + +unlink out +unlink response.json +unlink /tmp/aws_func_output +unlink /tmp/aws_func_result +#---------------------------------------------------------------------------------------------------------------- diff --git a/spot_221207/script/lambda_stop.sh b/spot_221207/script/lambda_stop.sh new file mode 100755 index 0000000..b8be4fd --- /dev/null +++ b/spot_221207/script/lambda_stop.sh @@ -0,0 +1,100 @@ +if [ -z "$BASH_VERSION" ]; then exec bash "$0" "$@"; exit; fi + +#---------------------------------------------------------------------------------------------------------------- +# 변수 선언 +echo_line="==========================================================================" +search_tag="spot" +stop_function="spot_stop" +start_function="spot_start" + +#---------------------------------------------------------------------------------------------------------------- +# aws 인스턴스 조회 +_get_aws_status (){ + aws_query="Reservations[].Instances[].[ InstanceId, Tags[?Key=='Name'].Value|[0] ]" + aws_filter="Name=instance-state-name,Values=running" + current_ec2_num=`aws ec2 describe-instances --query "${aws_query}" --filter ${aws_filter} --output text | grep ${search_tag} | wc -l` +} + +#---------------------------------------------------------------------------------------------------------------- +# log 출력 +_get_time_log (){ + datetime=`date +'%Y-%m-%d %H:%M:%S'` + string=$1 + echo "[${datetime}] ${string}" +} + +#---------------------------------------------------------------------------------------------------------------- +# aws lambda 실행 후 인스턴스 조회하여 성공/실패 여부 체크 + +_main (){ + lambda_function=$1 + echo ${echo_line} + if [[ ${lambda_fuction} == *"stop"* ]]; then + what_func='stop' + else + what_func='start' + fi + + _get_time_log "[INFO] aws lambda ${lambda_function} start" + + aws lambda invoke --function-name ${lambda_function} --cli-binary-format raw-in-base64-out --payload '{ "key": "value" }' response.json > /tmp/aws_func_result + #echo "aws lambda invoke --function-name ${lambda_function} --cli-binary-format raw-in-base64-out --payload '{ "key": "value" }' response.json" + + succ_flag=0 + while read line + do + if [[ $line == *"200"* ]]; then + succ_flag=1 + _get_time_log "[INFO] aws lambda ${lambda_function} success!" + break + else + succ_flag=0 + fi + done < /tmp/aws_func_result + + if [[ ${succ_flag} == 1 ]]; then + aws lambda invoke --function-name ${lambda_function} out --log-type Tail --query 'LogResult' --output text | base64 -d > /tmp/aws_func_output + if [[ ${what_func} == 'stop' ]]; then + final_ec2_num=0 + else + final_ec2_num=`grep "Starting" /tmp/aws_func_output | wc -l` + fi + + num=0 + while true + do + _get_aws_status + num=`echo $(( $num + 1 ))` + if [[ ${current_ec2_num} == ${final_ec2_num} ]]; then + _get_time_log "[INFO] aws ${search_tag} instance number: ${final_ec2_num} check success!" + break + elif [[ ${num} == 30 ]]; then + _get_time_log "[Error] time out!" + break + else + _get_time_log "[Retry: ${num}] aws ${search_tag} instance number: ${final_ec2_num} checking..." + fi + sleep 5 + done + else + echo ${echo_line} + _get_time_log "[Error] aws lambda ${lambda_function} failed!" + exit + fi + echo ${echo_line} + #--------------- + +} +#---------------------------------------------------------------------------------------------------------------- +# 실행 + +_main ${stop_function} + +#---------------------------------------------------------------------------------------------------------------- +# 임시 파일 삭제 + +unlink out +unlink response.json +unlink /tmp/aws_func_output +unlink /tmp/aws_func_result +#---------------------------------------------------------------------------------------------------------------- diff --git a/spot_221207/spot_kops_env.sh b/spot_221207/spot_kops_env.sh new file mode 100755 index 0000000..d2cb2f1 --- /dev/null +++ b/spot_221207/spot_kops_env.sh @@ -0,0 +1,41 @@ +#!/bin/bash + +export KOPS_STATE_STORE=s3://test.datasaker.io +export KOPS_CLUSTER_NAME=k8s-spot.datasaker.io + +export VPC_ID="vpc-00ba2b0e9ad59f0ed" +export Network_CIDR="172.24.0.0/19" +export AMI_Image="ami-0409b7ddbc59e3222" +export Private_Subnet_ID_1="subnet-024f0deda82039fa4" +export Private_Subnet_ID_2="subnet-050d942fa1c46540a" +export Private_Subnet_ID_3="subnet-0946eb806af7377be" +export Public_Subnet_ID_1="subnet-00c363356f133411d" +export Public_Subnet_ID_2="subnet-07aa5e879a262014d" +export Public_Subnet_ID_3="subnet-0073a61bc56a68a3e" + +kops_cmd=""" +kops create cluster \ + --vpc "$VPC_ID" \ + --cloud aws \ + --ssh-public-key "$HOME/.ssh/id_rsa.pub" \ + --topology private --kubernetes-version "1.25.2" \ + --network-cidr "$Network_CIDR" \ + --networking calico \ + --container-runtime containerd \ + --image $AMI_Image \ + --zones ap-northeast-2a,ap-northeast-2b,ap-northeast-2c \ + --master-count 3 \ + --master-size t3.small \ + --node-count 3 \ + --node-size t3.small \ + --node-volume-size 100 \ + --subnets "$Private_Subnet_ID_1,$Private_Subnet_ID_2,$Private_Subnet_ID_3" \ + --utility-subnets "$Public_Subnet_ID_1,$Public_Subnet_ID_2,$Public_Subnet_ID_3" \ + -v 10 +""" + +kubeconfig="kops export kubecfg --admin8760h0m0s --kubeconfig /root/.kube/config --name=${KOPS_CLUSTER_NAME} --state=${KOPS_STATE_STORE}" +echo ${kubeconfig} +echo +echo +echo ${kops_cmd} diff --git a/spot_221207/terraform/.terraform.lock.hcl b/spot_221207/terraform/.terraform.lock.hcl new file mode 100644 index 0000000..edcfb3a --- /dev/null +++ b/spot_221207/terraform/.terraform.lock.hcl @@ -0,0 +1,62 @@ +# This file is maintained automatically by "terraform init". +# Manual edits may be lost in future updates. + +provider "registry.terraform.io/hashicorp/archive" { + version = "2.2.0" + hashes = [ + "h1:CIWi5G6ob7p2wWoThRQbOB8AbmFlCzp7Ka81hR3cVp0=", + "zh:06bd875932288f235c16e2237142b493c2c2b6aba0e82e8c85068332a8d2a29e", + "zh:0c681b481372afcaefddacc7ccdf1d3bb3a0c0d4678a526bc8b02d0c331479bc", + "zh:100fc5b3fc01ea463533d7bbfb01cb7113947a969a4ec12e27f5b2be49884d6c", + "zh:55c0d7ddddbd0a46d57c51fcfa9b91f14eed081a45101dbfc7fd9d2278aa1403", + "zh:73a5dd68379119167934c48afa1101b09abad2deb436cd5c446733e705869d6b", + "zh:841fc4ac6dc3479981330974d44ad2341deada8a5ff9e3b1b4510702dfbdbed9", + "zh:91be62c9b41edb137f7f835491183628d484e9d6efa82fcb75cfa538c92791c5", + "zh:acd5f442bd88d67eb948b18dc2ed421c6c3faee62d3a12200e442bfff0aa7d8b", + "zh:ad5720da5524641ad718a565694821be5f61f68f1c3c5d2cfa24426b8e774bef", + "zh:e63f12ea938520b3f83634fc29da28d92eed5cfbc5cc8ca08281a6a9c36cca65", + "zh:f6542918faa115df46474a36aabb4c3899650bea036b5f8a5e296be6f8f25767", + ] +} + +provider "registry.terraform.io/hashicorp/aws" { + version = "4.45.0" + constraints = ">= 4.0.0" + hashes = [ + "h1:J/XjRsEJIpxi+mczXQfnH3nvfACv3LRDtrthQJCIibY=", + "zh:22da03786f25658a000d1bcc28c780816a97e7e8a1f59fff6eee7d452830e95e", + "zh:2543be56eee0491eb0c79ca1c901dcbf71da26625961fe719f088263fef062f4", + "zh:31a1da1e3beedfd88c3c152ab505bdcf330427f26b75835885526f7bb75c4857", + "zh:4409afe50f225659d5f378fe9303a45052953a1219f7f1acc82b69d07528b7ba", + "zh:4dadec3b783f10d2f8eef3dab5e817baae9c932a7967d45fe3d77fcbcbdaa438", + "zh:55be80d6e24828dcb0db7a0226fb275415c1c0ad63dd2f33b76f3ac0cd64e6a6", + "zh:560bba29efb7dbe0bfcc937369d88817aa31a8d18aa25395b1afe2576cb04495", + "zh:6caacc202e83438ff63d5d96733e283f44e349668d96c6b1c5c7df463ebf85cc", + "zh:6cabab83a61d5b4ac801c5a5d57556a0e76ec8dc879d28cf777509db5f6a657e", + "zh:96c4528bf9c16edb8841b68479ec51c499ed7fa680462fa28caeab3fc168bb43", + "zh:9b12af85486a96aedd8d7984b0ff811a4b42e3d88dad1a3fb4c0b580d04fa425", + "zh:cdc0b47ff840d708fbf75abfe86d23dc7f1dffdd233a771822a17b5c637f4769", + "zh:d9a9583e82776d1ebb6cf6c3d47acc2b302f8778f470ceffe7579dc794eb1feb", + "zh:e9367ca9f6f6418a23cdf8d01f29dd0c4f614e78499f52a767a422e4c334b915", + "zh:f6d355a2fb3bcebb597f68bbca4fa2aaa364efd29240236c582375e219d77656", + ] +} + +provider "registry.terraform.io/hashicorp/null" { + version = "3.2.1" + hashes = [ + "h1:FbGfc+muBsC17Ohy5g806iuI1hQc4SIexpYCrQHQd8w=", + "zh:58ed64389620cc7b82f01332e27723856422820cfd302e304b5f6c3436fb9840", + "zh:62a5cc82c3b2ddef7ef3a6f2fedb7b9b3deff4ab7b414938b08e51d6e8be87cb", + "zh:63cff4de03af983175a7e37e52d4bd89d990be256b16b5c7f919aff5ad485aa5", + "zh:74cb22c6700e48486b7cabefa10b33b801dfcab56f1a6ac9b6624531f3d36ea3", + "zh:78d5eefdd9e494defcb3c68d282b8f96630502cac21d1ea161f53cfe9bb483b3", + "zh:79e553aff77f1cfa9012a2218b8238dd672ea5e1b2924775ac9ac24d2a75c238", + "zh:a1e06ddda0b5ac48f7e7c7d59e1ab5a4073bbcf876c73c0299e4610ed53859dc", + "zh:c37a97090f1a82222925d45d84483b2aa702ef7ab66532af6cbcfb567818b970", + "zh:e4453fbebf90c53ca3323a92e7ca0f9961427d2f0ce0d2b65523cc04d5d999c2", + "zh:e80a746921946d8b6761e77305b752ad188da60688cfd2059322875d363be5f5", + "zh:fbdb892d9822ed0e4cb60f2fedbdbb556e4da0d88d3b942ae963ed6ff091e48f", + "zh:fca01a623d90d0cad0843102f9b8b9fe0d3ff8244593bd817f126582b52dd694", + ] +} diff --git a/spot_221207/terraform/00_terraform_var_change.sh b/spot_221207/terraform/00_terraform_var_change.sh new file mode 100755 index 0000000..3ffae89 --- /dev/null +++ b/spot_221207/terraform/00_terraform_var_change.sh @@ -0,0 +1,133 @@ +#!/bin/bash +#---------------------------------------------------------------------------------------------------------------- +# BASH SHELL로 실행 +if [ -z "$BASH_VERSION" ]; then exec bash "$0" "$@"; exit; fi + +#---------------------------------------------------------------------------------------------------------------- +# 변수 선언 +echo_line="======================================================" +kops_env_file="spot_kops_env.sh" +var_file="99_variables.tf" +search_tag="masters.k8s-spot" + +#---------------------------------------------------------------------------------------------------------------- +# 파일에서 기존에 선언되어 있는 ID값 가져오는 함수 +_get_var_id (){ + tf_variable=$1 + ret_id=`grep ${tf_variable} ${var_file_path} -A 1 | tail -1 | awk -F= '{print $2}' | tr -d ' ' | tr -d "\""` + if [ -z ${ret_id} ]; then echo "[Error] ${tf_variable} : Not found variable default (${var_file_path})"; exit; fi + #if [ -z ${ret_id} ]; then echo "[Error] ${tf_variable} : Not found variable default"; fi +} + +#---------------------------------------------------------------------------------------------------------------- +# 파일의 내용을 변경하는 함수 (before_id -> after_id) + +_change_default (){ + before_id=$1 + after_id=$2 + #echo "[${before_id}]" + #echo "[${after_id}]" + echo ${echo_line} + echo "[INFO] ${tf_variable}" + if [ "${before_id}" != "${after_id}" ] + then + echo "[Change] # ${before_id} --> ${after_id}" + sed -i "s/${before_id}/${after_id}/g" ${var_file_path} + #echo "sed -i 's/${before_id}/${after_id}/g' ${var_file_path}" + else + echo "[PASS] # ${ret_id}" + fi +} + +#---------------------------------------------------------------------------------------------------------------- +# master 별 ID 확인 후 변수에 저장하는 함수 +_get_aws_ec2_id (){ + ec2_id=$1 + tag_name=$2 + + if [ `echo ${tag_name} | grep 2a | wc -l` == 1 ] + then + master_2a=${ec2_id} + elif [ `echo ${tag_name} | grep 2b | wc -l` == 1 ] + then + master_2b=${ec2_id} + elif [ `echo ${tag_name} | grep 2c | wc -l` == 1 ] + then + master_2c=${ec2_id} + fi +} + +#---------------------------------------------------------------------------------------------------------------- +# path 확인 +current_path=`pwd` +kops_env_path=`find ${current_path} -name ${kops_env_file}` +var_file_path=`find ${current_path} -name ${var_file}` + +#---------------------------------------------------------------------------------------------------------------- +# kops 환경변수 적용 +source ${kops_env_path} > /dev/null 2>/dev/null +if [ -z "${VPC_ID}" ]; then + source ../${kops_env_file} +fi + +#---------------------------------------------------------------------------------------------------------------- +# aws에 인스턴스 ID 조회 +aws_query="Reservations[].Instances[].[ InstanceId, Tags[?Key=='Name'].Value|[0] ]" +aws_filter="Name=instance-state-name,Values=running" +aws ec2 describe-instances --query "${aws_query}" --filter ${aws_filter} --output text | grep ${search_tag} > tmp_cluster +echo "aws ec2 describe-instances --query \"${aws_query}\" --filter \"${aws_filter}\" --output text | grep ${search_tag}" + +while read line +do + _get_aws_ec2_id ${line} +done < tmp_cluster + +unlink tmp_cluster +#---------------------------------------------------------------------------------------------------------------- +# 기존에 파일에 선언되어 있는 ID 값을 조회해서 변경된 ID값이 있으면 변경 진행 + +_get_var_id master-2a +before_master_2a=${ret_id} +_change_default ${before_master_2a} ${master_2a} + +_get_var_id master-2b +before_master_2b=${ret_id} +_change_default ${before_master_2b} ${master_2b} + +_get_var_id master-2c +before_master_2c=${ret_id} +_change_default ${before_master_2c} ${master_2c} + +_get_var_id VPC_ID +before_VPC_ID=${ret_id} +_change_default ${before_VPC_ID} ${VPC_ID} + +_get_var_id Network_CIDR +before_Network_CIDR=${ret_id} +_change_default ${before_Network_CIDR} ${Network_CIDR} + +_get_var_id Private_Subnet_ID_1 +before_Private_Subnet_ID_1=${ret_id} +_change_default ${before_Private_Subnet_ID_1} ${Private_Subnet_ID_1} + +_get_var_id Private_Subnet_ID_2 +before_Private_Subnet_ID_2=${ret_id} +_change_default ${before_Private_Subnet_ID_2} ${Private_Subnet_ID_2} + +_get_var_id Private_Subnet_ID_3 +before_Private_Subnet_ID_3=${ret_id} +_change_default ${before_Private_Subnet_ID_3} ${Private_Subnet_ID_3} + +_get_var_id Public_Subnet_ID_1 +before_Public_Subnet_ID_1=${ret_id} +_change_default ${before_Public_Subnet_ID_1} ${Public_Subnet_ID_1} + +_get_var_id Public_Subnet_ID_2 +before_Public_Subnet_ID_2=${ret_id} +_change_default ${before_Public_Subnet_ID_2} ${Public_Subnet_ID_2} + +_get_var_id Public_Subnet_ID_3 +before_Public_Subnet_ID_3=${ret_id} +_change_default ${before_Public_Subnet_ID_3} ${Public_Subnet_ID_3} + +echo ${echo_line} diff --git a/spot_221207/terraform/01_main.tf b/spot_221207/terraform/01_main.tf new file mode 100644 index 0000000..c595cc0 --- /dev/null +++ b/spot_221207/terraform/01_main.tf @@ -0,0 +1,17 @@ +terraform { + required_version = ">= 0.15.0" + required_providers { + aws = { + "configuration_aliases" = [aws.files] + "source" = "hashicorp/aws" + "version" = ">= 4.0.0" + } + } +} + +provider "aws" { + alias = "files" + region = "ap-northeast-2" +} + + diff --git a/spot_221207/terraform/02_nlb.tf b/spot_221207/terraform/02_nlb.tf new file mode 100644 index 0000000..6f13559 --- /dev/null +++ b/spot_221207/terraform/02_nlb.tf @@ -0,0 +1,19 @@ +resource "aws_alb" "nlb-spot-kr-ingress" { + name = "nlb-spot-kr-ingress" + internal = false + load_balancer_type = "network" + subnet_mapping { + subnet_id = "${var.Public_Subnet_ID_1}" + } + subnet_mapping { + subnet_id = "${var.Public_Subnet_ID_2}" + } + subnet_mapping { + subnet_id = "${var.Public_Subnet_ID_3}" + } + enable_deletion_protection = false + + tags = { + Environment = "nlb-spot-kr-ingress" + } +} diff --git a/spot_221207/terraform/03_nlb_listener.tf b/spot_221207/terraform/03_nlb_listener.tf new file mode 100644 index 0000000..f0dd1af --- /dev/null +++ b/spot_221207/terraform/03_nlb_listener.tf @@ -0,0 +1,21 @@ +resource "aws_alb_listener" "nlb-listener-http-spot" { + load_balancer_arn = aws_alb.nlb-spot-kr-ingress.arn + port = "443" + protocol = "TCP" + + default_action { + type = "forward" + target_group_arn = aws_alb_target_group.tg-spot-kr-tcp-30001.arn + } +} + +resource "aws_alb_listener" "nlb-listener-tls-spot" { + load_balancer_arn = aws_alb.nlb-spot-kr-ingress.arn + port = "80" + protocol = "TCP" + + default_action { + type = "forward" + target_group_arn = aws_alb_target_group.tg-spot-kr-tcp-30000.arn + } +} diff --git a/spot_221207/terraform/04_nlb_target_group.tf b/spot_221207/terraform/04_nlb_target_group.tf new file mode 100644 index 0000000..dc1b710 --- /dev/null +++ b/spot_221207/terraform/04_nlb_target_group.tf @@ -0,0 +1,69 @@ +resource "aws_alb_target_group" "tg-spot-kr-tcp-30000" { + name = "tg-spot-kr-tcp-30000" + port = 30000 + protocol = "TCP" + vpc_id = "${var.VPC_ID}" + + health_check { + interval = 30 + protocol = "TCP" + healthy_threshold = 3 + unhealthy_threshold = 3 + } + +} + +resource "aws_alb_target_group_attachment" "spot-master-http-2a" { + target_group_arn = "${aws_alb_target_group.tg-spot-kr-tcp-30000.arn}" + target_id = "${var.master-2a}" + port = 30000 +} + +resource "aws_alb_target_group_attachment" "spot-master-http-2b" { + target_group_arn = "${aws_alb_target_group.tg-spot-kr-tcp-30000.arn}" + target_id = "${var.master-2b}" + port = 30000 +} + +resource "aws_alb_target_group_attachment" "spot-master-http-2c" { + target_group_arn = "${aws_alb_target_group.tg-spot-kr-tcp-30000.arn}" + target_id = "${var.master-2c}" + port = 30000 +} + +############################################################################### + +resource "aws_alb_target_group" "tg-spot-kr-tcp-30001" { + name = "tg-spot-kr-tcp-30001" + port = 30001 + protocol = "TCP" + vpc_id = "${var.VPC_ID}" + + health_check { + interval = 30 + protocol = "TCP" + healthy_threshold = 3 + unhealthy_threshold = 3 + } + +} + +resource "aws_alb_target_group_attachment" "spot-master-tls-2a" { + target_group_arn = "${aws_alb_target_group.tg-spot-kr-tcp-30001.arn}" + target_id = "${var.master-2a}" + port = 30001 +} + +resource "aws_alb_target_group_attachment" "spot-master-tls-2b" { + target_group_arn = "${aws_alb_target_group.tg-spot-kr-tcp-30001.arn}" + target_id = "${var.master-2b}" + port = 30001 +} + +resource "aws_alb_target_group_attachment" "spot-master-tls-2c" { + target_group_arn = "${aws_alb_target_group.tg-spot-kr-tcp-30001.arn}" + target_id = "${var.master-2c}" + port = 30001 +} + +############################################################################### diff --git a/spot_221207/terraform/05_route53.tf b/spot_221207/terraform/05_route53.tf new file mode 100644 index 0000000..fa3dd41 --- /dev/null +++ b/spot_221207/terraform/05_route53.tf @@ -0,0 +1,22 @@ +resource "aws_route53_record" "spot-dns-krakend" { + zone_id = "${var.datasaker-io}" + name = "api.spot.datasaker.io" + type = "A" + alias { + name = aws_alb.nlb-spot-kr-ingress.dns_name + zone_id = aws_alb.nlb-spot-kr-ingress.zone_id + evaluate_target_health = true + } +} + +resource "aws_route53_record" "spot-dns-keycloak" { + zone_id = "${var.datasaker-io}" + name = "test.spot.datasaker.io" + type = "A" + alias { + name = aws_alb.nlb-spot-kr-ingress.dns_name + zone_id = aws_alb.nlb-spot-kr-ingress.zone_id + evaluate_target_health = true + } +} + diff --git a/spot_221207/terraform/99_variables.tf b/spot_221207/terraform/99_variables.tf new file mode 100644 index 0000000..553755c --- /dev/null +++ b/spot_221207/terraform/99_variables.tf @@ -0,0 +1,78 @@ +#---------------------------------------------------------------# +# LB 구성 후 target group 매칭 시 필요한 인스턴스 ID +variable "lambda-user" { + default = "arn:aws:iam::508259851457:user/user_lambda" +} + +#---------------------------------------------------------------# +# LB 구성 후 target group 매칭 시 필요한 인스턴스 ID +variable "master-2a" { + default = "i-0d60fb3dce0af86dd" +} + +variable "master-2b" { + default = "i-0a55a0970db57e3f0" +} + +variable "master-2c" { + default = "i-0e83929146290be1c" +} + +#---------------------------------------------------------------# +# 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" +} + +#---------------------------------------------------------------# + # Route53 ID + + variable "datasaker-ai" { + default = "Z06479772L265DHVJW30F" + } + + variable "datasaker-com" { + default = "Z0218361HIZ723RV9EX4" + } + + variable "datasaker-io" { + default = "Z072735718G25WNVKU834" + } + + variable "datasaker-co-kr" { + default = "Z06528191YJHOMRBYTXXT" + } + + variable "datasaker-net" { + default = "Z072720912UR7SY03M9F8" + } + diff --git a/spot_221207/terraform/terraform.tfstate b/spot_221207/terraform/terraform.tfstate new file mode 100644 index 0000000..3646982 --- /dev/null +++ b/spot_221207/terraform/terraform.tfstate @@ -0,0 +1,753 @@ +{ + "version": 4, + "terraform_version": "1.3.1", + "serial": 155, + "lineage": "032f4e32-eac2-150d-d701-e7669deda40a", + "outputs": {}, + "resources": [ + { + "mode": "data", + "type": "archive_file", + "name": "python-start", + "provider": "provider[\"registry.terraform.io/hashicorp/archive\"]", + "instances": [ + { + "schema_version": 0, + "attributes": { + "excludes": null, + "id": "daae77ced1e4b958c09e9c889ada79be8926a3a7", + "output_base64sha256": "X2llCFxq3rWrZH+v+rfYD/2xxxAg69Xkhuc6ElW9DSM=", + "output_file_mode": null, + "output_md5": "b4bf9b7ae2ff9bfe896af6ebb8c9dc5c", + "output_path": "./code/spot_start.zip", + "output_sha": "daae77ced1e4b958c09e9c889ada79be8926a3a7", + "output_size": 570, + "source": [], + "source_content": null, + "source_content_filename": null, + "source_dir": null, + "source_file": "./code/spot_start.py", + "type": "zip" + }, + "sensitive_attributes": [] + } + ] + }, + { + "mode": "data", + "type": "archive_file", + "name": "python-stop", + "provider": "provider[\"registry.terraform.io/hashicorp/archive\"]", + "instances": [ + { + "schema_version": 0, + "attributes": { + "excludes": null, + "id": "b71d1d33f0a7ce242baaa2ccb71eab56fb2661a0", + "output_base64sha256": "T6nY95UEy5cqlpacLlnkJybiBvmJ4+oP9wWTut+vKDg=", + "output_file_mode": null, + "output_md5": "36f88fa43ffb3f5547d4ec89b867c805", + "output_path": "./code/spot_stop.zip", + "output_sha": "b71d1d33f0a7ce242baaa2ccb71eab56fb2661a0", + "output_size": 568, + "source": [], + "source_content": null, + "source_content_filename": null, + "source_dir": null, + "source_file": "./code/spot_stop.py", + "type": "zip" + }, + "sensitive_attributes": [] + } + ] + }, + { + "mode": "managed", + "type": "aws_alb", + "name": "nlb-spot-kr-ingress", + "provider": "provider[\"registry.terraform.io/hashicorp/aws\"]", + "instances": [ + { + "schema_version": 0, + "attributes": { + "access_logs": [ + { + "bucket": "", + "enabled": false, + "prefix": "" + } + ], + "arn": "arn:aws:elasticloadbalancing:ap-northeast-2:508259851457:loadbalancer/net/nlb-spot-kr-ingress/78764994534ff2f2", + "arn_suffix": "net/nlb-spot-kr-ingress/78764994534ff2f2", + "customer_owned_ipv4_pool": "", + "desync_mitigation_mode": null, + "dns_name": "nlb-spot-kr-ingress-78764994534ff2f2.elb.ap-northeast-2.amazonaws.com", + "drop_invalid_header_fields": null, + "enable_cross_zone_load_balancing": false, + "enable_deletion_protection": false, + "enable_http2": null, + "enable_waf_fail_open": null, + "id": "arn:aws:elasticloadbalancing:ap-northeast-2:508259851457:loadbalancer/net/nlb-spot-kr-ingress/78764994534ff2f2", + "idle_timeout": null, + "internal": false, + "ip_address_type": "ipv4", + "load_balancer_type": "network", + "name": "nlb-spot-kr-ingress", + "name_prefix": null, + "preserve_host_header": null, + "security_groups": [], + "subnet_mapping": [ + { + "allocation_id": "", + "ipv6_address": "", + "outpost_id": "", + "private_ipv4_address": "", + "subnet_id": "subnet-0073a61bc56a68a3e" + }, + { + "allocation_id": "", + "ipv6_address": "", + "outpost_id": "", + "private_ipv4_address": "", + "subnet_id": "subnet-00c363356f133411d" + }, + { + "allocation_id": "", + "ipv6_address": "", + "outpost_id": "", + "private_ipv4_address": "", + "subnet_id": "subnet-07aa5e879a262014d" + } + ], + "subnets": [ + "subnet-0073a61bc56a68a3e", + "subnet-00c363356f133411d", + "subnet-07aa5e879a262014d" + ], + "tags": { + "Environment": "nlb-spot-kr-ingress" + }, + "tags_all": { + "Environment": "nlb-spot-kr-ingress" + }, + "timeouts": null, + "vpc_id": "vpc-00ba2b0e9ad59f0ed", + "zone_id": "ZIBE1TIR4HY56" + }, + "sensitive_attributes": [], + "private": "eyJlMmJmYjczMC1lY2FhLTExZTYtOGY4OC0zNDM2M2JjN2M0YzAiOnsiY3JlYXRlIjo2MDAwMDAwMDAwMDAsImRlbGV0ZSI6NjAwMDAwMDAwMDAwLCJ1cGRhdGUiOjYwMDAwMDAwMDAwMH19" + } + ] + }, + { + "mode": "managed", + "type": "aws_alb_listener", + "name": "nlb-listener-http-spot", + "provider": "provider[\"registry.terraform.io/hashicorp/aws\"]", + "instances": [ + { + "schema_version": 0, + "attributes": { + "alpn_policy": null, + "arn": "arn:aws:elasticloadbalancing:ap-northeast-2:508259851457:listener/net/nlb-spot-kr-ingress/78764994534ff2f2/877ddd740e570ec4", + "certificate_arn": null, + "default_action": [ + { + "authenticate_cognito": [], + "authenticate_oidc": [], + "fixed_response": [], + "forward": [], + "order": 1, + "redirect": [], + "target_group_arn": "arn:aws:elasticloadbalancing:ap-northeast-2:508259851457:targetgroup/tg-spot-kr-tcp-30001/fa75e29a3ffe1fa4", + "type": "forward" + } + ], + "id": "arn:aws:elasticloadbalancing:ap-northeast-2:508259851457:listener/net/nlb-spot-kr-ingress/78764994534ff2f2/877ddd740e570ec4", + "load_balancer_arn": "arn:aws:elasticloadbalancing:ap-northeast-2:508259851457:loadbalancer/net/nlb-spot-kr-ingress/78764994534ff2f2", + "port": 443, + "protocol": "TCP", + "ssl_policy": "", + "tags": {}, + "tags_all": {}, + "timeouts": null + }, + "sensitive_attributes": [], + "private": "eyJlMmJmYjczMC1lY2FhLTExZTYtOGY4OC0zNDM2M2JjN2M0YzAiOnsicmVhZCI6NjAwMDAwMDAwMDAwfX0=", + "dependencies": [ + "aws_alb.nlb-spot-kr-ingress", + "aws_alb_target_group.tg-spot-kr-tcp-30001" + ] + } + ] + }, + { + "mode": "managed", + "type": "aws_alb_listener", + "name": "nlb-listener-tls-spot", + "provider": "provider[\"registry.terraform.io/hashicorp/aws\"]", + "instances": [ + { + "schema_version": 0, + "attributes": { + "alpn_policy": null, + "arn": "arn:aws:elasticloadbalancing:ap-northeast-2:508259851457:listener/net/nlb-spot-kr-ingress/78764994534ff2f2/fbb26c612065fd23", + "certificate_arn": null, + "default_action": [ + { + "authenticate_cognito": [], + "authenticate_oidc": [], + "fixed_response": [], + "forward": [], + "order": 1, + "redirect": [], + "target_group_arn": "arn:aws:elasticloadbalancing:ap-northeast-2:508259851457:targetgroup/tg-spot-kr-tcp-30000/bb1ec3447d8f55f1", + "type": "forward" + } + ], + "id": "arn:aws:elasticloadbalancing:ap-northeast-2:508259851457:listener/net/nlb-spot-kr-ingress/78764994534ff2f2/fbb26c612065fd23", + "load_balancer_arn": "arn:aws:elasticloadbalancing:ap-northeast-2:508259851457:loadbalancer/net/nlb-spot-kr-ingress/78764994534ff2f2", + "port": 80, + "protocol": "TCP", + "ssl_policy": "", + "tags": {}, + "tags_all": {}, + "timeouts": null + }, + "sensitive_attributes": [], + "private": "eyJlMmJmYjczMC1lY2FhLTExZTYtOGY4OC0zNDM2M2JjN2M0YzAiOnsicmVhZCI6NjAwMDAwMDAwMDAwfX0=", + "dependencies": [ + "aws_alb.nlb-spot-kr-ingress", + "aws_alb_target_group.tg-spot-kr-tcp-30000" + ] + } + ] + }, + { + "mode": "managed", + "type": "aws_alb_target_group", + "name": "tg-spot-kr-tcp-30000", + "provider": "provider[\"registry.terraform.io/hashicorp/aws\"]", + "instances": [ + { + "schema_version": 0, + "attributes": { + "arn": "arn:aws:elasticloadbalancing:ap-northeast-2:508259851457:targetgroup/tg-spot-kr-tcp-30000/bb1ec3447d8f55f1", + "arn_suffix": "targetgroup/tg-spot-kr-tcp-30000/bb1ec3447d8f55f1", + "connection_termination": false, + "deregistration_delay": "300", + "health_check": [ + { + "enabled": true, + "healthy_threshold": 3, + "interval": 30, + "matcher": "", + "path": "", + "port": "traffic-port", + "protocol": "TCP", + "timeout": 10, + "unhealthy_threshold": 3 + } + ], + "id": "arn:aws:elasticloadbalancing:ap-northeast-2:508259851457:targetgroup/tg-spot-kr-tcp-30000/bb1ec3447d8f55f1", + "ip_address_type": "ipv4", + "lambda_multi_value_headers_enabled": false, + "load_balancing_algorithm_type": null, + "name": "tg-spot-kr-tcp-30000", + "name_prefix": null, + "port": 30000, + "preserve_client_ip": "true", + "protocol": "TCP", + "protocol_version": null, + "proxy_protocol_v2": false, + "slow_start": 0, + "stickiness": [ + { + "cookie_duration": 0, + "cookie_name": "", + "enabled": false, + "type": "source_ip" + } + ], + "tags": {}, + "tags_all": {}, + "target_failover": [ + { + "on_deregistration": null, + "on_unhealthy": null + } + ], + "target_type": "instance", + "vpc_id": "vpc-00ba2b0e9ad59f0ed" + }, + "sensitive_attributes": [], + "private": "bnVsbA==" + } + ] + }, + { + "mode": "managed", + "type": "aws_alb_target_group", + "name": "tg-spot-kr-tcp-30001", + "provider": "provider[\"registry.terraform.io/hashicorp/aws\"]", + "instances": [ + { + "schema_version": 0, + "attributes": { + "arn": "arn:aws:elasticloadbalancing:ap-northeast-2:508259851457:targetgroup/tg-spot-kr-tcp-30001/fa75e29a3ffe1fa4", + "arn_suffix": "targetgroup/tg-spot-kr-tcp-30001/fa75e29a3ffe1fa4", + "connection_termination": false, + "deregistration_delay": "300", + "health_check": [ + { + "enabled": true, + "healthy_threshold": 3, + "interval": 30, + "matcher": "", + "path": "", + "port": "traffic-port", + "protocol": "TCP", + "timeout": 10, + "unhealthy_threshold": 3 + } + ], + "id": "arn:aws:elasticloadbalancing:ap-northeast-2:508259851457:targetgroup/tg-spot-kr-tcp-30001/fa75e29a3ffe1fa4", + "ip_address_type": "ipv4", + "lambda_multi_value_headers_enabled": false, + "load_balancing_algorithm_type": null, + "name": "tg-spot-kr-tcp-30001", + "name_prefix": null, + "port": 30001, + "preserve_client_ip": "true", + "protocol": "TCP", + "protocol_version": null, + "proxy_protocol_v2": false, + "slow_start": 0, + "stickiness": [ + { + "cookie_duration": 0, + "cookie_name": "", + "enabled": false, + "type": "source_ip" + } + ], + "tags": {}, + "tags_all": {}, + "target_failover": [ + { + "on_deregistration": null, + "on_unhealthy": null + } + ], + "target_type": "instance", + "vpc_id": "vpc-00ba2b0e9ad59f0ed" + }, + "sensitive_attributes": [], + "private": "bnVsbA==" + } + ] + }, + { + "mode": "managed", + "type": "aws_alb_target_group_attachment", + "name": "spot-master-http-2a", + "provider": "provider[\"registry.terraform.io/hashicorp/aws\"]", + "instances": [ + { + "schema_version": 0, + "attributes": { + "availability_zone": null, + "id": "arn:aws:elasticloadbalancing:ap-northeast-2:508259851457:targetgroup/tg-spot-kr-tcp-30000/bb1ec3447d8f55f1-20221208074319228900000004", + "port": 30000, + "target_group_arn": "arn:aws:elasticloadbalancing:ap-northeast-2:508259851457:targetgroup/tg-spot-kr-tcp-30000/bb1ec3447d8f55f1", + "target_id": "i-0d60fb3dce0af86dd" + }, + "sensitive_attributes": [], + "private": "bnVsbA==", + "dependencies": [ + "aws_alb_target_group.tg-spot-kr-tcp-30000" + ] + } + ] + }, + { + "mode": "managed", + "type": "aws_alb_target_group_attachment", + "name": "spot-master-http-2b", + "provider": "provider[\"registry.terraform.io/hashicorp/aws\"]", + "instances": [ + { + "schema_version": 0, + "attributes": { + "availability_zone": null, + "id": "arn:aws:elasticloadbalancing:ap-northeast-2:508259851457:targetgroup/tg-spot-kr-tcp-30000/bb1ec3447d8f55f1-20221208074319108100000001", + "port": 30000, + "target_group_arn": "arn:aws:elasticloadbalancing:ap-northeast-2:508259851457:targetgroup/tg-spot-kr-tcp-30000/bb1ec3447d8f55f1", + "target_id": "i-0a55a0970db57e3f0" + }, + "sensitive_attributes": [], + "private": "bnVsbA==", + "dependencies": [ + "aws_alb_target_group.tg-spot-kr-tcp-30000" + ] + } + ] + }, + { + "mode": "managed", + "type": "aws_alb_target_group_attachment", + "name": "spot-master-http-2c", + "provider": "provider[\"registry.terraform.io/hashicorp/aws\"]", + "instances": [ + { + "schema_version": 0, + "attributes": { + "availability_zone": null, + "id": "arn:aws:elasticloadbalancing:ap-northeast-2:508259851457:targetgroup/tg-spot-kr-tcp-30000/bb1ec3447d8f55f1-20221208074319455600000005", + "port": 30000, + "target_group_arn": "arn:aws:elasticloadbalancing:ap-northeast-2:508259851457:targetgroup/tg-spot-kr-tcp-30000/bb1ec3447d8f55f1", + "target_id": "i-0e83929146290be1c" + }, + "sensitive_attributes": [], + "private": "bnVsbA==", + "dependencies": [ + "aws_alb_target_group.tg-spot-kr-tcp-30000" + ] + } + ] + }, + { + "mode": "managed", + "type": "aws_alb_target_group_attachment", + "name": "spot-master-tls-2a", + "provider": "provider[\"registry.terraform.io/hashicorp/aws\"]", + "instances": [ + { + "schema_version": 0, + "attributes": { + "availability_zone": null, + "id": "arn:aws:elasticloadbalancing:ap-northeast-2:508259851457:targetgroup/tg-spot-kr-tcp-30001/fa75e29a3ffe1fa4-20221208074319183800000003", + "port": 30001, + "target_group_arn": "arn:aws:elasticloadbalancing:ap-northeast-2:508259851457:targetgroup/tg-spot-kr-tcp-30001/fa75e29a3ffe1fa4", + "target_id": "i-0d60fb3dce0af86dd" + }, + "sensitive_attributes": [], + "private": "bnVsbA==", + "dependencies": [ + "aws_alb_target_group.tg-spot-kr-tcp-30001" + ] + } + ] + }, + { + "mode": "managed", + "type": "aws_alb_target_group_attachment", + "name": "spot-master-tls-2b", + "provider": "provider[\"registry.terraform.io/hashicorp/aws\"]", + "instances": [ + { + "schema_version": 0, + "attributes": { + "availability_zone": null, + "id": "arn:aws:elasticloadbalancing:ap-northeast-2:508259851457:targetgroup/tg-spot-kr-tcp-30001/fa75e29a3ffe1fa4-20221208074319533500000006", + "port": 30001, + "target_group_arn": "arn:aws:elasticloadbalancing:ap-northeast-2:508259851457:targetgroup/tg-spot-kr-tcp-30001/fa75e29a3ffe1fa4", + "target_id": "i-0a55a0970db57e3f0" + }, + "sensitive_attributes": [], + "private": "bnVsbA==", + "dependencies": [ + "aws_alb_target_group.tg-spot-kr-tcp-30001" + ] + } + ] + }, + { + "mode": "managed", + "type": "aws_alb_target_group_attachment", + "name": "spot-master-tls-2c", + "provider": "provider[\"registry.terraform.io/hashicorp/aws\"]", + "instances": [ + { + "schema_version": 0, + "attributes": { + "availability_zone": null, + "id": "arn:aws:elasticloadbalancing:ap-northeast-2:508259851457:targetgroup/tg-spot-kr-tcp-30001/fa75e29a3ffe1fa4-20221208074319153500000002", + "port": 30001, + "target_group_arn": "arn:aws:elasticloadbalancing:ap-northeast-2:508259851457:targetgroup/tg-spot-kr-tcp-30001/fa75e29a3ffe1fa4", + "target_id": "i-0e83929146290be1c" + }, + "sensitive_attributes": [], + "private": "bnVsbA==", + "dependencies": [ + "aws_alb_target_group.tg-spot-kr-tcp-30001" + ] + } + ] + }, + { + "mode": "managed", + "type": "aws_iam_role", + "name": "spot-lambda-role", + "provider": "provider[\"registry.terraform.io/hashicorp/aws\"]", + "instances": [ + { + "schema_version": 0, + "attributes": { + "arn": "arn:aws:iam::508259851457:role/spot-lambda-role", + "assume_role_policy": "{\"Statement\":[{\"Action\":\"sts:AssumeRole\",\"Effect\":\"Allow\",\"Principal\":{\"Service\":\"lambda.amazonaws.com\"},\"Sid\":\"\"}],\"Version\":\"2012-10-17\"}", + "create_date": "2022-12-08T07:43:24Z", + "description": "", + "force_detach_policies": false, + "id": "spot-lambda-role", + "inline_policy": [], + "managed_policy_arns": [], + "max_session_duration": 3600, + "name": "spot-lambda-role", + "name_prefix": "", + "path": "/", + "permissions_boundary": null, + "tags": {}, + "tags_all": {}, + "unique_id": "AROAXMVVF3TAUBQDVKMXS" + }, + "sensitive_attributes": [], + "private": "bnVsbA==" + } + ] + }, + { + "mode": "managed", + "type": "aws_lambda_function", + "name": "spot-auto-start", + "provider": "provider[\"registry.terraform.io/hashicorp/aws\"]", + "instances": [ + { + "schema_version": 0, + "attributes": { + "architectures": [ + "x86_64" + ], + "arn": "arn:aws:lambda:ap-northeast-2:508259851457:function:spot-auto-start", + "code_signing_config_arn": "", + "dead_letter_config": [], + "description": "", + "environment": [ + { + "variables": { + "LOG_LEVEL": "INFO" + } + } + ], + "ephemeral_storage": [ + { + "size": 512 + } + ], + "file_system_config": [], + "filename": "./code/spot_start.zip", + "function_name": "spot-auto-start", + "handler": "main.lambda_handler", + "id": "spot-auto-start", + "image_config": [], + "image_uri": "", + "invoke_arn": "arn:aws:apigateway:ap-northeast-2:lambda:path/2015-03-31/functions/arn:aws:lambda:ap-northeast-2:508259851457:function:spot-auto-start/invocations", + "kms_key_arn": "", + "last_modified": "2022-12-08T08:16:36.000+0000", + "layers": [], + "memory_size": 128, + "package_type": "Zip", + "publish": false, + "qualified_arn": "arn:aws:lambda:ap-northeast-2:508259851457:function:spot-auto-start:$LATEST", + "qualified_invoke_arn": "arn:aws:apigateway:ap-northeast-2:lambda:path/2015-03-31/functions/arn:aws:lambda:ap-northeast-2:508259851457:function:spot-auto-start:$LATEST/invocations", + "reserved_concurrent_executions": -1, + "role": "arn:aws:iam::508259851457:role/spot-lambda-role", + "runtime": "python3.9", + "s3_bucket": null, + "s3_key": null, + "s3_object_version": null, + "signing_job_arn": "", + "signing_profile_version_arn": "", + "snap_start": [], + "source_code_hash": "X2llCFxq3rWrZH+v+rfYD/2xxxAg69Xkhuc6ElW9DSM=", + "source_code_size": 570, + "tags": {}, + "tags_all": {}, + "timeout": 3, + "timeouts": null, + "tracing_config": [ + { + "mode": "PassThrough" + } + ], + "version": "$LATEST", + "vpc_config": [] + }, + "sensitive_attributes": [], + "private": "eyJlMmJmYjczMC1lY2FhLTExZTYtOGY4OC0zNDM2M2JjN2M0YzAiOnsiY3JlYXRlIjo2MDAwMDAwMDAwMDB9fQ==", + "dependencies": [ + "aws_iam_role.spot-lambda-role", + "data.archive_file.python-start" + ] + } + ] + }, + { + "mode": "managed", + "type": "aws_lambda_function", + "name": "spot-auto-stop", + "provider": "provider[\"registry.terraform.io/hashicorp/aws\"]", + "instances": [ + { + "schema_version": 0, + "attributes": { + "architectures": [ + "x86_64" + ], + "arn": "arn:aws:lambda:ap-northeast-2:508259851457:function:spot-auto-stop", + "code_signing_config_arn": "", + "dead_letter_config": [], + "description": "", + "environment": [ + { + "variables": { + "LOG_LEVEL": "INFO" + } + } + ], + "ephemeral_storage": [ + { + "size": 512 + } + ], + "file_system_config": [], + "filename": "./code/spot_stop.zip", + "function_name": "spot-auto-stop", + "handler": "main.lambda_handler", + "id": "spot-auto-stop", + "image_config": [], + "image_uri": "", + "invoke_arn": "arn:aws:apigateway:ap-northeast-2:lambda:path/2015-03-31/functions/arn:aws:lambda:ap-northeast-2:508259851457:function:spot-auto-stop/invocations", + "kms_key_arn": "", + "last_modified": "2022-12-08T08:03:18.000+0000", + "layers": [], + "memory_size": 128, + "package_type": "Zip", + "publish": false, + "qualified_arn": "arn:aws:lambda:ap-northeast-2:508259851457:function:spot-auto-stop:$LATEST", + "qualified_invoke_arn": "arn:aws:apigateway:ap-northeast-2:lambda:path/2015-03-31/functions/arn:aws:lambda:ap-northeast-2:508259851457:function:spot-auto-stop:$LATEST/invocations", + "reserved_concurrent_executions": -1, + "role": "arn:aws:iam::508259851457:role/spot-lambda-role", + "runtime": "python3.9", + "s3_bucket": null, + "s3_key": null, + "s3_object_version": null, + "signing_job_arn": "", + "signing_profile_version_arn": "", + "snap_start": [], + "source_code_hash": "T6nY95UEy5cqlpacLlnkJybiBvmJ4+oP9wWTut+vKDg=", + "source_code_size": 568, + "tags": {}, + "tags_all": {}, + "timeout": 3, + "timeouts": null, + "tracing_config": [ + { + "mode": "PassThrough" + } + ], + "version": "$LATEST", + "vpc_config": [] + }, + "sensitive_attributes": [], + "private": "eyJlMmJmYjczMC1lY2FhLTExZTYtOGY4OC0zNDM2M2JjN2M0YzAiOnsiY3JlYXRlIjo2MDAwMDAwMDAwMDB9fQ==", + "dependencies": [ + "aws_iam_role.spot-lambda-role", + "data.archive_file.python-stop" + ] + } + ] + }, + { + "mode": "managed", + "type": "aws_route53_record", + "name": "spot-dns-keycloak", + "provider": "provider[\"registry.terraform.io/hashicorp/aws\"]", + "instances": [ + { + "schema_version": 2, + "attributes": { + "alias": [ + { + "evaluate_target_health": true, + "name": "nlb-spot-kr-ingress-78764994534ff2f2.elb.ap-northeast-2.amazonaws.com", + "zone_id": "ZIBE1TIR4HY56" + } + ], + "allow_overwrite": null, + "failover_routing_policy": [], + "fqdn": "test.spot.datasaker.io", + "geolocation_routing_policy": [], + "health_check_id": "", + "id": "Z072735718G25WNVKU834_test.spot.datasaker.io_A", + "latency_routing_policy": [], + "multivalue_answer_routing_policy": null, + "name": "test.spot.datasaker.io", + "records": [], + "set_identifier": "", + "ttl": 0, + "type": "A", + "weighted_routing_policy": [], + "zone_id": "Z072735718G25WNVKU834" + }, + "sensitive_attributes": [], + "private": "eyJzY2hlbWFfdmVyc2lvbiI6IjIifQ==", + "dependencies": [ + "aws_alb.nlb-spot-kr-ingress" + ] + } + ] + }, + { + "mode": "managed", + "type": "aws_route53_record", + "name": "spot-dns-krakend", + "provider": "provider[\"registry.terraform.io/hashicorp/aws\"]", + "instances": [ + { + "schema_version": 2, + "attributes": { + "alias": [ + { + "evaluate_target_health": true, + "name": "nlb-spot-kr-ingress-78764994534ff2f2.elb.ap-northeast-2.amazonaws.com", + "zone_id": "ZIBE1TIR4HY56" + } + ], + "allow_overwrite": null, + "failover_routing_policy": [], + "fqdn": "api.spot.datasaker.io", + "geolocation_routing_policy": [], + "health_check_id": "", + "id": "Z072735718G25WNVKU834_api.spot.datasaker.io_A", + "latency_routing_policy": [], + "multivalue_answer_routing_policy": null, + "name": "api.spot.datasaker.io", + "records": [], + "set_identifier": "", + "ttl": 0, + "type": "A", + "weighted_routing_policy": [], + "zone_id": "Z072735718G25WNVKU834" + }, + "sensitive_attributes": [], + "private": "eyJzY2hlbWFfdmVyc2lvbiI6IjIifQ==", + "dependencies": [ + "aws_alb.nlb-spot-kr-ingress" + ] + } + ] + } + ], + "check_results": [] +} diff --git a/spot_221207/terraform/terraform.tfstate.backup b/spot_221207/terraform/terraform.tfstate.backup new file mode 100644 index 0000000..8482580 --- /dev/null +++ b/spot_221207/terraform/terraform.tfstate.backup @@ -0,0 +1,753 @@ +{ + "version": 4, + "terraform_version": "1.3.1", + "serial": 138, + "lineage": "032f4e32-eac2-150d-d701-e7669deda40a", + "outputs": {}, + "resources": [ + { + "mode": "data", + "type": "archive_file", + "name": "python-start", + "provider": "provider[\"registry.terraform.io/hashicorp/archive\"]", + "instances": [ + { + "schema_version": 0, + "attributes": { + "excludes": null, + "id": "c0f3da3940dbcb2fe389567b22d55d23e5c286af", + "output_base64sha256": "8KD6NlEwOh5O/0ro/iLvBot0KR/g4sitEgEsTuRpG5o=", + "output_file_mode": null, + "output_md5": "982608b39d8037315a5fbe868e6eb7c7", + "output_path": "./code/spot_start.zip", + "output_sha": "c0f3da3940dbcb2fe389567b22d55d23e5c286af", + "output_size": 570, + "source": [], + "source_content": null, + "source_content_filename": null, + "source_dir": null, + "source_file": "./code/spot_start.py", + "type": "zip" + }, + "sensitive_attributes": [] + } + ] + }, + { + "mode": "data", + "type": "archive_file", + "name": "python-stop", + "provider": "provider[\"registry.terraform.io/hashicorp/archive\"]", + "instances": [ + { + "schema_version": 0, + "attributes": { + "excludes": null, + "id": "b71d1d33f0a7ce242baaa2ccb71eab56fb2661a0", + "output_base64sha256": "T6nY95UEy5cqlpacLlnkJybiBvmJ4+oP9wWTut+vKDg=", + "output_file_mode": null, + "output_md5": "36f88fa43ffb3f5547d4ec89b867c805", + "output_path": "./code/spot_stop.zip", + "output_sha": "b71d1d33f0a7ce242baaa2ccb71eab56fb2661a0", + "output_size": 568, + "source": [], + "source_content": null, + "source_content_filename": null, + "source_dir": null, + "source_file": "./code/spot_stop.py", + "type": "zip" + }, + "sensitive_attributes": [] + } + ] + }, + { + "mode": "managed", + "type": "aws_alb", + "name": "nlb-spot-kr-ingress", + "provider": "provider[\"registry.terraform.io/hashicorp/aws\"]", + "instances": [ + { + "schema_version": 0, + "attributes": { + "access_logs": [ + { + "bucket": "", + "enabled": false, + "prefix": "" + } + ], + "arn": "arn:aws:elasticloadbalancing:ap-northeast-2:508259851457:loadbalancer/net/nlb-spot-kr-ingress/78764994534ff2f2", + "arn_suffix": "net/nlb-spot-kr-ingress/78764994534ff2f2", + "customer_owned_ipv4_pool": "", + "desync_mitigation_mode": null, + "dns_name": "nlb-spot-kr-ingress-78764994534ff2f2.elb.ap-northeast-2.amazonaws.com", + "drop_invalid_header_fields": null, + "enable_cross_zone_load_balancing": false, + "enable_deletion_protection": false, + "enable_http2": null, + "enable_waf_fail_open": null, + "id": "arn:aws:elasticloadbalancing:ap-northeast-2:508259851457:loadbalancer/net/nlb-spot-kr-ingress/78764994534ff2f2", + "idle_timeout": null, + "internal": false, + "ip_address_type": "ipv4", + "load_balancer_type": "network", + "name": "nlb-spot-kr-ingress", + "name_prefix": null, + "preserve_host_header": null, + "security_groups": [], + "subnet_mapping": [ + { + "allocation_id": "", + "ipv6_address": "", + "outpost_id": "", + "private_ipv4_address": "", + "subnet_id": "subnet-0073a61bc56a68a3e" + }, + { + "allocation_id": "", + "ipv6_address": "", + "outpost_id": "", + "private_ipv4_address": "", + "subnet_id": "subnet-00c363356f133411d" + }, + { + "allocation_id": "", + "ipv6_address": "", + "outpost_id": "", + "private_ipv4_address": "", + "subnet_id": "subnet-07aa5e879a262014d" + } + ], + "subnets": [ + "subnet-0073a61bc56a68a3e", + "subnet-00c363356f133411d", + "subnet-07aa5e879a262014d" + ], + "tags": { + "Environment": "nlb-spot-kr-ingress" + }, + "tags_all": { + "Environment": "nlb-spot-kr-ingress" + }, + "timeouts": null, + "vpc_id": "vpc-00ba2b0e9ad59f0ed", + "zone_id": "ZIBE1TIR4HY56" + }, + "sensitive_attributes": [], + "private": "eyJlMmJmYjczMC1lY2FhLTExZTYtOGY4OC0zNDM2M2JjN2M0YzAiOnsiY3JlYXRlIjo2MDAwMDAwMDAwMDAsImRlbGV0ZSI6NjAwMDAwMDAwMDAwLCJ1cGRhdGUiOjYwMDAwMDAwMDAwMH19" + } + ] + }, + { + "mode": "managed", + "type": "aws_alb_listener", + "name": "nlb-listener-http-spot", + "provider": "provider[\"registry.terraform.io/hashicorp/aws\"]", + "instances": [ + { + "schema_version": 0, + "attributes": { + "alpn_policy": null, + "arn": "arn:aws:elasticloadbalancing:ap-northeast-2:508259851457:listener/net/nlb-spot-kr-ingress/78764994534ff2f2/877ddd740e570ec4", + "certificate_arn": null, + "default_action": [ + { + "authenticate_cognito": [], + "authenticate_oidc": [], + "fixed_response": [], + "forward": [], + "order": 1, + "redirect": [], + "target_group_arn": "arn:aws:elasticloadbalancing:ap-northeast-2:508259851457:targetgroup/tg-spot-kr-tcp-30001/fa75e29a3ffe1fa4", + "type": "forward" + } + ], + "id": "arn:aws:elasticloadbalancing:ap-northeast-2:508259851457:listener/net/nlb-spot-kr-ingress/78764994534ff2f2/877ddd740e570ec4", + "load_balancer_arn": "arn:aws:elasticloadbalancing:ap-northeast-2:508259851457:loadbalancer/net/nlb-spot-kr-ingress/78764994534ff2f2", + "port": 443, + "protocol": "TCP", + "ssl_policy": "", + "tags": {}, + "tags_all": {}, + "timeouts": null + }, + "sensitive_attributes": [], + "private": "eyJlMmJmYjczMC1lY2FhLTExZTYtOGY4OC0zNDM2M2JjN2M0YzAiOnsicmVhZCI6NjAwMDAwMDAwMDAwfX0=", + "dependencies": [ + "aws_alb.nlb-spot-kr-ingress", + "aws_alb_target_group.tg-spot-kr-tcp-30001" + ] + } + ] + }, + { + "mode": "managed", + "type": "aws_alb_listener", + "name": "nlb-listener-tls-spot", + "provider": "provider[\"registry.terraform.io/hashicorp/aws\"]", + "instances": [ + { + "schema_version": 0, + "attributes": { + "alpn_policy": null, + "arn": "arn:aws:elasticloadbalancing:ap-northeast-2:508259851457:listener/net/nlb-spot-kr-ingress/78764994534ff2f2/fbb26c612065fd23", + "certificate_arn": null, + "default_action": [ + { + "authenticate_cognito": [], + "authenticate_oidc": [], + "fixed_response": [], + "forward": [], + "order": 1, + "redirect": [], + "target_group_arn": "arn:aws:elasticloadbalancing:ap-northeast-2:508259851457:targetgroup/tg-spot-kr-tcp-30000/bb1ec3447d8f55f1", + "type": "forward" + } + ], + "id": "arn:aws:elasticloadbalancing:ap-northeast-2:508259851457:listener/net/nlb-spot-kr-ingress/78764994534ff2f2/fbb26c612065fd23", + "load_balancer_arn": "arn:aws:elasticloadbalancing:ap-northeast-2:508259851457:loadbalancer/net/nlb-spot-kr-ingress/78764994534ff2f2", + "port": 80, + "protocol": "TCP", + "ssl_policy": "", + "tags": {}, + "tags_all": {}, + "timeouts": null + }, + "sensitive_attributes": [], + "private": "eyJlMmJmYjczMC1lY2FhLTExZTYtOGY4OC0zNDM2M2JjN2M0YzAiOnsicmVhZCI6NjAwMDAwMDAwMDAwfX0=", + "dependencies": [ + "aws_alb.nlb-spot-kr-ingress", + "aws_alb_target_group.tg-spot-kr-tcp-30000" + ] + } + ] + }, + { + "mode": "managed", + "type": "aws_alb_target_group", + "name": "tg-spot-kr-tcp-30000", + "provider": "provider[\"registry.terraform.io/hashicorp/aws\"]", + "instances": [ + { + "schema_version": 0, + "attributes": { + "arn": "arn:aws:elasticloadbalancing:ap-northeast-2:508259851457:targetgroup/tg-spot-kr-tcp-30000/bb1ec3447d8f55f1", + "arn_suffix": "targetgroup/tg-spot-kr-tcp-30000/bb1ec3447d8f55f1", + "connection_termination": false, + "deregistration_delay": "300", + "health_check": [ + { + "enabled": true, + "healthy_threshold": 3, + "interval": 30, + "matcher": "", + "path": "", + "port": "traffic-port", + "protocol": "TCP", + "timeout": 10, + "unhealthy_threshold": 3 + } + ], + "id": "arn:aws:elasticloadbalancing:ap-northeast-2:508259851457:targetgroup/tg-spot-kr-tcp-30000/bb1ec3447d8f55f1", + "ip_address_type": "ipv4", + "lambda_multi_value_headers_enabled": false, + "load_balancing_algorithm_type": null, + "name": "tg-spot-kr-tcp-30000", + "name_prefix": null, + "port": 30000, + "preserve_client_ip": "true", + "protocol": "TCP", + "protocol_version": null, + "proxy_protocol_v2": false, + "slow_start": 0, + "stickiness": [ + { + "cookie_duration": 0, + "cookie_name": "", + "enabled": false, + "type": "source_ip" + } + ], + "tags": {}, + "tags_all": {}, + "target_failover": [ + { + "on_deregistration": null, + "on_unhealthy": null + } + ], + "target_type": "instance", + "vpc_id": "vpc-00ba2b0e9ad59f0ed" + }, + "sensitive_attributes": [], + "private": "bnVsbA==" + } + ] + }, + { + "mode": "managed", + "type": "aws_alb_target_group", + "name": "tg-spot-kr-tcp-30001", + "provider": "provider[\"registry.terraform.io/hashicorp/aws\"]", + "instances": [ + { + "schema_version": 0, + "attributes": { + "arn": "arn:aws:elasticloadbalancing:ap-northeast-2:508259851457:targetgroup/tg-spot-kr-tcp-30001/fa75e29a3ffe1fa4", + "arn_suffix": "targetgroup/tg-spot-kr-tcp-30001/fa75e29a3ffe1fa4", + "connection_termination": false, + "deregistration_delay": "300", + "health_check": [ + { + "enabled": true, + "healthy_threshold": 3, + "interval": 30, + "matcher": "", + "path": "", + "port": "traffic-port", + "protocol": "TCP", + "timeout": 10, + "unhealthy_threshold": 3 + } + ], + "id": "arn:aws:elasticloadbalancing:ap-northeast-2:508259851457:targetgroup/tg-spot-kr-tcp-30001/fa75e29a3ffe1fa4", + "ip_address_type": "ipv4", + "lambda_multi_value_headers_enabled": false, + "load_balancing_algorithm_type": null, + "name": "tg-spot-kr-tcp-30001", + "name_prefix": null, + "port": 30001, + "preserve_client_ip": "true", + "protocol": "TCP", + "protocol_version": null, + "proxy_protocol_v2": false, + "slow_start": 0, + "stickiness": [ + { + "cookie_duration": 0, + "cookie_name": "", + "enabled": false, + "type": "source_ip" + } + ], + "tags": {}, + "tags_all": {}, + "target_failover": [ + { + "on_deregistration": null, + "on_unhealthy": null + } + ], + "target_type": "instance", + "vpc_id": "vpc-00ba2b0e9ad59f0ed" + }, + "sensitive_attributes": [], + "private": "bnVsbA==" + } + ] + }, + { + "mode": "managed", + "type": "aws_alb_target_group_attachment", + "name": "spot-master-http-2a", + "provider": "provider[\"registry.terraform.io/hashicorp/aws\"]", + "instances": [ + { + "schema_version": 0, + "attributes": { + "availability_zone": null, + "id": "arn:aws:elasticloadbalancing:ap-northeast-2:508259851457:targetgroup/tg-spot-kr-tcp-30000/bb1ec3447d8f55f1-20221208074319228900000004", + "port": 30000, + "target_group_arn": "arn:aws:elasticloadbalancing:ap-northeast-2:508259851457:targetgroup/tg-spot-kr-tcp-30000/bb1ec3447d8f55f1", + "target_id": "i-0d60fb3dce0af86dd" + }, + "sensitive_attributes": [], + "private": "bnVsbA==", + "dependencies": [ + "aws_alb_target_group.tg-spot-kr-tcp-30000" + ] + } + ] + }, + { + "mode": "managed", + "type": "aws_alb_target_group_attachment", + "name": "spot-master-http-2b", + "provider": "provider[\"registry.terraform.io/hashicorp/aws\"]", + "instances": [ + { + "schema_version": 0, + "attributes": { + "availability_zone": null, + "id": "arn:aws:elasticloadbalancing:ap-northeast-2:508259851457:targetgroup/tg-spot-kr-tcp-30000/bb1ec3447d8f55f1-20221208074319108100000001", + "port": 30000, + "target_group_arn": "arn:aws:elasticloadbalancing:ap-northeast-2:508259851457:targetgroup/tg-spot-kr-tcp-30000/bb1ec3447d8f55f1", + "target_id": "i-0a55a0970db57e3f0" + }, + "sensitive_attributes": [], + "private": "bnVsbA==", + "dependencies": [ + "aws_alb_target_group.tg-spot-kr-tcp-30000" + ] + } + ] + }, + { + "mode": "managed", + "type": "aws_alb_target_group_attachment", + "name": "spot-master-http-2c", + "provider": "provider[\"registry.terraform.io/hashicorp/aws\"]", + "instances": [ + { + "schema_version": 0, + "attributes": { + "availability_zone": null, + "id": "arn:aws:elasticloadbalancing:ap-northeast-2:508259851457:targetgroup/tg-spot-kr-tcp-30000/bb1ec3447d8f55f1-20221208074319455600000005", + "port": 30000, + "target_group_arn": "arn:aws:elasticloadbalancing:ap-northeast-2:508259851457:targetgroup/tg-spot-kr-tcp-30000/bb1ec3447d8f55f1", + "target_id": "i-0e83929146290be1c" + }, + "sensitive_attributes": [], + "private": "bnVsbA==", + "dependencies": [ + "aws_alb_target_group.tg-spot-kr-tcp-30000" + ] + } + ] + }, + { + "mode": "managed", + "type": "aws_alb_target_group_attachment", + "name": "spot-master-tls-2a", + "provider": "provider[\"registry.terraform.io/hashicorp/aws\"]", + "instances": [ + { + "schema_version": 0, + "attributes": { + "availability_zone": null, + "id": "arn:aws:elasticloadbalancing:ap-northeast-2:508259851457:targetgroup/tg-spot-kr-tcp-30001/fa75e29a3ffe1fa4-20221208074319183800000003", + "port": 30001, + "target_group_arn": "arn:aws:elasticloadbalancing:ap-northeast-2:508259851457:targetgroup/tg-spot-kr-tcp-30001/fa75e29a3ffe1fa4", + "target_id": "i-0d60fb3dce0af86dd" + }, + "sensitive_attributes": [], + "private": "bnVsbA==", + "dependencies": [ + "aws_alb_target_group.tg-spot-kr-tcp-30001" + ] + } + ] + }, + { + "mode": "managed", + "type": "aws_alb_target_group_attachment", + "name": "spot-master-tls-2b", + "provider": "provider[\"registry.terraform.io/hashicorp/aws\"]", + "instances": [ + { + "schema_version": 0, + "attributes": { + "availability_zone": null, + "id": "arn:aws:elasticloadbalancing:ap-northeast-2:508259851457:targetgroup/tg-spot-kr-tcp-30001/fa75e29a3ffe1fa4-20221208074319533500000006", + "port": 30001, + "target_group_arn": "arn:aws:elasticloadbalancing:ap-northeast-2:508259851457:targetgroup/tg-spot-kr-tcp-30001/fa75e29a3ffe1fa4", + "target_id": "i-0a55a0970db57e3f0" + }, + "sensitive_attributes": [], + "private": "bnVsbA==", + "dependencies": [ + "aws_alb_target_group.tg-spot-kr-tcp-30001" + ] + } + ] + }, + { + "mode": "managed", + "type": "aws_alb_target_group_attachment", + "name": "spot-master-tls-2c", + "provider": "provider[\"registry.terraform.io/hashicorp/aws\"]", + "instances": [ + { + "schema_version": 0, + "attributes": { + "availability_zone": null, + "id": "arn:aws:elasticloadbalancing:ap-northeast-2:508259851457:targetgroup/tg-spot-kr-tcp-30001/fa75e29a3ffe1fa4-20221208074319153500000002", + "port": 30001, + "target_group_arn": "arn:aws:elasticloadbalancing:ap-northeast-2:508259851457:targetgroup/tg-spot-kr-tcp-30001/fa75e29a3ffe1fa4", + "target_id": "i-0e83929146290be1c" + }, + "sensitive_attributes": [], + "private": "bnVsbA==", + "dependencies": [ + "aws_alb_target_group.tg-spot-kr-tcp-30001" + ] + } + ] + }, + { + "mode": "managed", + "type": "aws_iam_role", + "name": "spot-lambda-role", + "provider": "provider[\"registry.terraform.io/hashicorp/aws\"]", + "instances": [ + { + "schema_version": 0, + "attributes": { + "arn": "arn:aws:iam::508259851457:role/spot-lambda-role", + "assume_role_policy": "{\"Statement\":[{\"Action\":\"sts:AssumeRole\",\"Effect\":\"Allow\",\"Principal\":{\"Service\":\"lambda.amazonaws.com\"},\"Sid\":\"\"}],\"Version\":\"2012-10-17\"}", + "create_date": "2022-12-08T07:43:24Z", + "description": "", + "force_detach_policies": false, + "id": "spot-lambda-role", + "inline_policy": [], + "managed_policy_arns": [], + "max_session_duration": 3600, + "name": "spot-lambda-role", + "name_prefix": "", + "path": "/", + "permissions_boundary": null, + "tags": {}, + "tags_all": {}, + "unique_id": "AROAXMVVF3TAUBQDVKMXS" + }, + "sensitive_attributes": [], + "private": "bnVsbA==" + } + ] + }, + { + "mode": "managed", + "type": "aws_lambda_function", + "name": "spot-auto-start", + "provider": "provider[\"registry.terraform.io/hashicorp/aws\"]", + "instances": [ + { + "schema_version": 0, + "attributes": { + "architectures": [ + "x86_64" + ], + "arn": "arn:aws:lambda:ap-northeast-2:508259851457:function:spot-auto-start", + "code_signing_config_arn": "", + "dead_letter_config": [], + "description": "", + "environment": [ + { + "variables": { + "LOG_LEVEL": "INFO" + } + } + ], + "ephemeral_storage": [ + { + "size": 512 + } + ], + "file_system_config": [], + "filename": "./code/spot_start.zip", + "function_name": "spot-auto-start", + "handler": "main.lambda_handler", + "id": "spot-auto-start", + "image_config": [], + "image_uri": "", + "invoke_arn": "arn:aws:apigateway:ap-northeast-2:lambda:path/2015-03-31/functions/arn:aws:lambda:ap-northeast-2:508259851457:function:spot-auto-start/invocations", + "kms_key_arn": "", + "last_modified": "2022-12-08T08:03:18.000+0000", + "layers": [], + "memory_size": 128, + "package_type": "Zip", + "publish": false, + "qualified_arn": "arn:aws:lambda:ap-northeast-2:508259851457:function:spot-auto-start:$LATEST", + "qualified_invoke_arn": "arn:aws:apigateway:ap-northeast-2:lambda:path/2015-03-31/functions/arn:aws:lambda:ap-northeast-2:508259851457:function:spot-auto-start:$LATEST/invocations", + "reserved_concurrent_executions": -1, + "role": "arn:aws:iam::508259851457:role/spot-lambda-role", + "runtime": "python3.9", + "s3_bucket": null, + "s3_key": null, + "s3_object_version": null, + "signing_job_arn": "", + "signing_profile_version_arn": "", + "snap_start": [], + "source_code_hash": "8KD6NlEwOh5O/0ro/iLvBot0KR/g4sitEgEsTuRpG5o=", + "source_code_size": 570, + "tags": {}, + "tags_all": {}, + "timeout": 3, + "timeouts": null, + "tracing_config": [ + { + "mode": "PassThrough" + } + ], + "version": "$LATEST", + "vpc_config": [] + }, + "sensitive_attributes": [], + "private": "eyJlMmJmYjczMC1lY2FhLTExZTYtOGY4OC0zNDM2M2JjN2M0YzAiOnsiY3JlYXRlIjo2MDAwMDAwMDAwMDB9fQ==", + "dependencies": [ + "aws_iam_role.spot-lambda-role", + "data.archive_file.python-start" + ] + } + ] + }, + { + "mode": "managed", + "type": "aws_lambda_function", + "name": "spot-auto-stop", + "provider": "provider[\"registry.terraform.io/hashicorp/aws\"]", + "instances": [ + { + "schema_version": 0, + "attributes": { + "architectures": [ + "x86_64" + ], + "arn": "arn:aws:lambda:ap-northeast-2:508259851457:function:spot-auto-stop", + "code_signing_config_arn": "", + "dead_letter_config": [], + "description": "", + "environment": [ + { + "variables": { + "LOG_LEVEL": "INFO" + } + } + ], + "ephemeral_storage": [ + { + "size": 512 + } + ], + "file_system_config": [], + "filename": "./code/spot_stop.zip", + "function_name": "spot-auto-stop", + "handler": "main.lambda_handler", + "id": "spot-auto-stop", + "image_config": [], + "image_uri": "", + "invoke_arn": "arn:aws:apigateway:ap-northeast-2:lambda:path/2015-03-31/functions/arn:aws:lambda:ap-northeast-2:508259851457:function:spot-auto-stop/invocations", + "kms_key_arn": "", + "last_modified": "2022-12-08T08:03:18.000+0000", + "layers": [], + "memory_size": 128, + "package_type": "Zip", + "publish": false, + "qualified_arn": "arn:aws:lambda:ap-northeast-2:508259851457:function:spot-auto-stop:$LATEST", + "qualified_invoke_arn": "arn:aws:apigateway:ap-northeast-2:lambda:path/2015-03-31/functions/arn:aws:lambda:ap-northeast-2:508259851457:function:spot-auto-stop:$LATEST/invocations", + "reserved_concurrent_executions": -1, + "role": "arn:aws:iam::508259851457:role/spot-lambda-role", + "runtime": "python3.9", + "s3_bucket": null, + "s3_key": null, + "s3_object_version": null, + "signing_job_arn": "", + "signing_profile_version_arn": "", + "snap_start": [], + "source_code_hash": "T6nY95UEy5cqlpacLlnkJybiBvmJ4+oP9wWTut+vKDg=", + "source_code_size": 568, + "tags": {}, + "tags_all": {}, + "timeout": 3, + "timeouts": null, + "tracing_config": [ + { + "mode": "PassThrough" + } + ], + "version": "$LATEST", + "vpc_config": [] + }, + "sensitive_attributes": [], + "private": "eyJlMmJmYjczMC1lY2FhLTExZTYtOGY4OC0zNDM2M2JjN2M0YzAiOnsiY3JlYXRlIjo2MDAwMDAwMDAwMDB9fQ==", + "dependencies": [ + "aws_iam_role.spot-lambda-role", + "data.archive_file.python-stop" + ] + } + ] + }, + { + "mode": "managed", + "type": "aws_route53_record", + "name": "spot-dns-keycloak", + "provider": "provider[\"registry.terraform.io/hashicorp/aws\"]", + "instances": [ + { + "schema_version": 2, + "attributes": { + "alias": [ + { + "evaluate_target_health": true, + "name": "nlb-spot-kr-ingress-78764994534ff2f2.elb.ap-northeast-2.amazonaws.com", + "zone_id": "ZIBE1TIR4HY56" + } + ], + "allow_overwrite": null, + "failover_routing_policy": [], + "fqdn": "test.spot.datasaker.io", + "geolocation_routing_policy": [], + "health_check_id": "", + "id": "Z072735718G25WNVKU834_test.spot.datasaker.io_A", + "latency_routing_policy": [], + "multivalue_answer_routing_policy": null, + "name": "test.spot.datasaker.io", + "records": [], + "set_identifier": "", + "ttl": 0, + "type": "A", + "weighted_routing_policy": [], + "zone_id": "Z072735718G25WNVKU834" + }, + "sensitive_attributes": [], + "private": "eyJzY2hlbWFfdmVyc2lvbiI6IjIifQ==", + "dependencies": [ + "aws_alb.nlb-spot-kr-ingress" + ] + } + ] + }, + { + "mode": "managed", + "type": "aws_route53_record", + "name": "spot-dns-krakend", + "provider": "provider[\"registry.terraform.io/hashicorp/aws\"]", + "instances": [ + { + "schema_version": 2, + "attributes": { + "alias": [ + { + "evaluate_target_health": true, + "name": "nlb-spot-kr-ingress-78764994534ff2f2.elb.ap-northeast-2.amazonaws.com", + "zone_id": "ZIBE1TIR4HY56" + } + ], + "allow_overwrite": null, + "failover_routing_policy": [], + "fqdn": "api.spot.datasaker.io", + "geolocation_routing_policy": [], + "health_check_id": "", + "id": "Z072735718G25WNVKU834_api.spot.datasaker.io_A", + "latency_routing_policy": [], + "multivalue_answer_routing_policy": null, + "name": "api.spot.datasaker.io", + "records": [], + "set_identifier": "", + "ttl": 0, + "type": "A", + "weighted_routing_policy": [], + "zone_id": "Z072735718G25WNVKU834" + }, + "sensitive_attributes": [], + "private": "eyJzY2hlbWFfdmVyc2lvbiI6IjIifQ==", + "dependencies": [ + "aws_alb.nlb-spot-kr-ingress" + ] + } + ] + } + ], + "check_results": [] +}