Amazon Linux 2023

  • 2023년 3월 15일 Amazon Linux 2 후속버전으로 출시

  • 클라우드 애플리케이션 개발 및 실행에 더욱 최적화된 환경을 제공

기존 Amazon Linux 2 기반 메타데이터 조회 방법

curl http://169.254.169.254/latest/meta-data/
> (실행결과)
ami-id
ami-launch-index
ami-manifest-path
block-device-mapping/
events/
hostname
identity-credentials/
instance-action
instance-id
instance-life-cycle
instance-type
local-hostname
local-ipv4
mac
metrics/
network/
placement/
profile
public-hostname
public-ipv4
public-keys/
reservation-id
security-groups
services/


# AMI Key 조회
curl http://169.254.169.254/latest/meta-data/ami-id

# 인스턴스 ID 조회
curl http://169.254.169.254/latest/meta-data/instance-id
> (출력결과)
i-0df8321768b104bcb

# Region 조회
curl http://169.254.169.254/latest/meta-data/placement/region
> (출력결과)
ap-northeast-2

Amazon Linux 2023 기반 메타데이터 조회 방법

TOKEN=$(curl --request PUT "http://169.254.169.254/latest/api/token" --header "X-aws-ec2-metadata-token-ttl-seconds: 3600")

echo $TOKEN

INSTANCE_METADATA=$(curl -s http://169.254.169.254/latest/meta-data/ --header "X-aws-ec2-metadata-token: $TOKEN")

echo $INSTANCE_METADATA

INSTANCE_ID=$(curl -s http://169.254.169.254/latest/meta-data/instance-id --header "X-aws-ec2-metadata-token: $TOKEN")

REGION=$(curl -s http://169.254.169.254/latest/meta-data/placement/region --header "X-aws-ec2-metadata-token: $TOKEN")

Amazon Linux 2023에서 MySQL 설치 및 DB 연결

(참고 공식문서 링크: Link)

# install
sudo dnf install mariadb105

# check
mysql --version

# connect 
# (ex. user: master, password: tf-password, endpoint: tf-db.cso8wtmrwb6r.ap-northeast-2.rds.amazonaws.com)
mysql -umaster -ptf-password -htf-db.cso8wtmrwb6r.ap-northeast-2.rds.amazonaws.com

# Using MySQL
MySQL [(none)]> show databases;
>
+--------------------+
| Database           | 
+--------------------+
| information_schema |
| innodb             |
| mysql              |
| performance_schema |
| sys                |
| tf                 |
+--------------------+

MySQL [(none)]> use tf
> Database changed
    
MySQL [tf]> show tables;
> Empty set (0.00 sec)

MySQL [tf]> quit
> Bye