728x90
728x90
# Linux
# linux.sh
#!/bin/bash
PROXY_URL="http://proxy.domain:3128"
NO_PROXY="169.254.169.254,localhost,127.0.0.1,.svc.cluster.local,.amazonaws.com,172.16.0.0/12,10.0.0.0/8,192.168.0.0/16,.internal"
echo "export http_proxy=$PROXY_URL" | tee -a /etc/profile.d/proxy.sh
echo "export https_proxy=$PROXY_URL" | tee -a /etc/profile.d/proxy.sh
echo "export no_proxy=$NO_PROXY" | tee -a /etc/profile.d/proxy.sh
source /etc/profile.d/proxy.sh
# Windows
# windows.ps1
<powershell>
$proxyUrl = "proxy.domain:3128"
$proxyOverride = "<local>;*.amazonaws.com;127.0.0.1;10.*;172.16.*;172.17.*;172.18.*;172.19.*;172.20.*;172.21.*;172.22.*;172.23.*;172.24.*;172.25.*;172.26.*;172.27.*;172.28.*;172.29.*;172.30.*;172.31.*;192.168.*"
Set-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Internet Settings" -Name ProxyEnable -Value 1
Set-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Internet Settings" -Name ProxyServer -Value $proxyUrl
Set-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Internet Settings" -Name ProxyOverride -Value $proxyOverride
</powershell>
# in Terraform
locals {
ami_os = # 알아서 linux인지 windows인지 구분하기
user_data_file = local.ami_os == "linux" ? "linux.sh" : "windows.ps1"
user_data_script = file("${path.module}/${local.user_data_file}")
}
resource "aws_instance" "this" {
# 매개변수 입력
user_data = local.user_data_script
}
# 참조 (Powershell)
끝~
728x90
728x90
'공부 > AWS' 카테고리의 다른 글
[aws-load-balancer-controller] failed calling webhook "mtargetgroupbinding.elbv2.k8s.aws" (0) | 2024.07.17 |
---|---|
[AWS EKS] 보안그룹 최소 필요사항 정리 (0) | 2024.07.01 |
[Terraform/AWS ECR] 외부 이미지 ECR에 캐싱하기 (Pull Through Cache Rule) (0) | 2024.06.30 |
[AWS EKS] CoreDNS Addon을 FARGATE로 띄우기 (w. Terraform) (0) | 2024.04.28 |
[AWS EKS] 클러스터 보안그룹 vs 추가 보안그룹 (Cluster SG vs Additional SG) (1) | 2024.04.28 |
댓글