2. 사전준비
Update : 2024-06-07
Seoul Region에서 구성을 시작합니다.
제공되는 LAB 환경에서 VPC Lattice의 편리한 구성을 위해, 아래와 같이 IAM user와 Password, Policy를 cloudshell에서 구성합니다. (User ID는 변경가능합니다.)

Cloudshell 터미널에서 아래 aws cli script를 실행합니다.
# user01 사용자를 생성하고, password는 "1234Qwer", IAM Policy는 "AdministratorAccess" 권한을 부여합니다.
aws iam create-user --user-name user01
aws iam create-login-profile --user-name user01 --password 1234Qwer --no-password-reset-required
aws iam attach-user-policy --user-name user01 --policy-arn arn:aws:iam::aws:policy/AdministratorAccess
User ID : user01
Password : xxxxxxx
IAM User Policy : AdministratorAccess
LAB 구성의 편의성을 위해 Cloudshell 터미널에서 AWS Account Alias를 생성하기 위한 awscli를 실행합니다. (alias는 고유한 값을 입력해야 합니다.)
aws iam create-account-alias --account-alias xxxxxx
생성이 모두 완료되었으면, AWS Console에서 Logout 한 이후에 재접속해서 "user01"로 접속합니다.
계정 : 신규생성한 alias
user id : user01
password : 이전에 생성한 암호 입력
이제 콘솔에서 선택하고, 다시 cloudshell을 실행합니다.

앞서 생성한 Alias로 접속하고, 새로운 User로 인증해서 로그인 합니다.
정상적으로 접속하면, 다시 CloudShell을 사용해서 , VSCode Server를 구성합니다.
# 아래 git을 cloudshell에 복제합니다.
git clone https://github.com/whchoi98/ec2_vscode.git
VSCode Server 구성
CloudShell에서 VSCode 서버를 구성하기 위한 환경 변수를 정의합니다. VSCode Server는 Default VPC, Public Subnet에 설치합니다.
source ~/.bash_profile
export AWS_REGION=ap-northeast-2
~/ec2_vscode/defaultvpcid.sh
source ~/.bashrc
Cloudshell에서 Cloudformation 을 배포해서 VSCode 서버를 구성합니다.
aws cloudformation deploy \
--template-file "~/ec2_vscode/ec2vscode.yaml" \
--stack-name=ec2vscodeserver \
--parameter-overrides \
InstanceType=t3.xlarge \
AMIType=AmazonLinux2023 \
DefaultVPCId=$DEFAULT_VPC_ID \
PublicSubnetId=$PUBLIC_SUBNET_ID \
--capabilities CAPABILITY_NAMED_IAM
10분 이후 VSCode 서버가 생성됩니다.
cloudshell 에서 아래 Shell을 실행시켜, vscode server의 Public IP를 확인하고, VSCode에 접속합니다.
~/ec2_vscode/vscode_ip.sh
아래는 출력예입니다.
$ ~/ec2_vscode/vscode_ip.sh
EC2VSCodeServer = 15.165.36.130
CodeServer Connect = 15.165.36.130:8080
해당 VSCodeServer 공인 IP 주소로 접속합니다.
EC2SVSCodeServer:8080
EC2가 완전하게 배포된 후 3~5분 뒤에 브라우저에서 EC2VSCodeServer PublicIP:8080으로 접속합니다.

EC2VSCodeServer Terminal에서 아래를 실행합니다.
git clone https://github.com/whchoi98/ec2_vscode.git
VSCodeServer는 패스워드 설정이 되어 있지 않습니다.
비밀번호 설정을 확인하고, 적절한 비밀번호로 변경한 후 다음 스크립트를 실행합니다.
cat ~/ec2_vscode/vscode_pwd.sh
~/ec2_vscode/vscode_pwd.sh
이제 다시 브라우저에서 재접속합니다.
이 랩의 모든 콘솔은 VSCode Server 터미널에서 수행합니다.
패스워드 설정 후에 VSCode Server에서 아래를 수행합니다.
#LAB에서 사용할 Shell Script를 복제하고, 환경변수를 설정합니다.
mkdir ~/environment/
cd ~/environment/
git clone https://github.com/whchoi98/vpclattice.git
#LAB에서 사용할 패키지를 다운로드 받고, 설치합니다.
~/environment/vpclattice/cloud9/init.sh
source <(kubectl completion bash)
VPC Lattice LAB에서 사용할 환경 변수와 Cloudformation을 수행합니다.
#LAB에서 사용할 환경변수를 설정합니다.
~/environment/vpclattice/cloud9/lattice_env.sh
source ~/.bash_profile
#LAB에서 사용할 Cloudformation을 실행합니다.
cd ~/environment/vpclattice/cloudformation
aws cloudformation deploy \
--stack-name "latticebaseinfrawithapiserver" \
--template-file "./LatticeBaseInfraWithAPIServer.yaml" \
--capabilities CAPABILITY_NAMED_IAM
Last updated