Amazon Linux 2023 が AWS CloudShell に来たよ! さっそく深掘りしてみよう

本記事は TechHarmony Advent Calendar 12/9付の記事です。

どうも、CLI推進派の寺内です。

かねてよりAWSより周知のあった、AWS CloudShell の Amazon Linux 2023 への変更が、ついに東京リージョンに来ました。12/4 から順次リリースということで、毎日チェックしていたのですが私が確認できたのは12/6の日本時間朝になります。

CloudShellを起動すると、以下のようなメッセージが現れます。

ということで、中身を見ていきましょう。

OSの確認

Amazon Linux 2 の頃から変わらずインテルですね。そろそろArmになるかと思ってました。

$ cat /etc/system-release
Amazon Linux release 2023 (Amazon Linux)

$ uname -a
Linux ip-10-132-91-243.ap-northeast-1.compute.internal 6.1.61-85.141.amzn2023.x86_64 #1 SMP PREEMPT_DYNAMIC Wed Nov 8 00:39:18 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux

認証情報

$ export
declare -x AWS_CONTAINER_AUTHORIZATION_TOKEN="ABCDEFGHIJKLMNOPQRSTUVWXYZ12345="
declare -x AWS_CONTAINER_CREDENTIALS_FULL_URI="<http://localhost:1338/latest/meta-data/container/security-credentials>"
declare -x AWS_DEFAULT_REGION="ap-northeast-1"
declare -x AWS_EXECUTION_ENV="CloudShell"
declare -x AWS_PAGER="less -K"
declare -x AWS_REGION="ap-northeast-1"
declare -x AWS_TOOLING_USER_AGENT="AWS-CloudShell/2023.10.01"
declare -x EDITOR="/usr/bin/nano"
(以下略)

こちらも変わりはないですね。

以下のようにこの環境変数を使いトークン情報も取得できます。

$ curl -sH "X-aws-ec2-metadata-token: $AWS_CONTAINER_AUTHORIZATION_TOKEN" $AWS_CONTAINER_CREDENTIALS_FULL_URI
{
"Type": "",
"AccessKeyId": "ASIABCDEFGHIJKLM",
"SecretAccessKey": "ABCDEFGHIJKLMNOPQRSTUVWXYZ",
"Token": "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA",
"Expiration": "2023-12-05T23:14:16Z",
"Code": "Success"
}

AWS CloudShellのインフラ

CloudShellが実行しているコンテナについて見ていきましょう。以下のドキュメントに仕様があります。

CPU

ドキュメントにvCPU1つとあるとおり、vCPUは1つで2コアのようです。

$ cat /proc/cpuinfo
processor       : 0
vendor_id       : GenuineIntel
cpu family      : 6
model           : 85
model name      : Intel(R) Xeon(R) Platinum 8259CL CPU @ 2.50GHz
stepping        : 7
microcode       : 0x5003604
cpu MHz         : 2499.998
cache size      : 36608 KB
physical id     : 0
siblings        : 2
core id         : 0
cpu cores       : 1
apicid          : 0
initial apicid  : 0
fpu             : yes
fpu_exception   : yes
cpuid level     : 13
wp              : yes
flags           : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ss ht syscall nx pdpe1gb rdtscp lm constant_tsc rep_good nopl xtopology nonstop_tsc cpuid tsc_known_freq pni pclmulqdq ssse3 fma cx16 pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand hypervisor lahf_lm abm 3dnowprefetch invpcid_single pti fsgsbase tsc_adjust bmi1 avx2 smep bmi2 erms invpcid mpx avx512f avx512dq rdseed adx smap clflushopt clwb avx512cd avx512bw avx512vl xsaveopt xsavec xgetbv1 xsaves ida arat pku ospke
bugs            : cpu_meltdown spectre_v1 spectre_v2 spec_store_bypass l1tf mds swapgs itlb_multihit mmio_stale_data retbleed gds
bogomips        : 4999.99
clflush size    : 64
cache_alignment : 64
address sizes   : 46 bits physical, 48 bits virtual
power management:

processor       : 1
vendor_id       : GenuineIntel
cpu family      : 6
model           : 85
model name      : Intel(R) Xeon(R) Platinum 8259CL CPU @ 2.50GHz
stepping        : 7
microcode       : 0x5003604
cpu MHz         : 2499.998
cache size      : 36608 KB
physical id     : 0
siblings        : 2
core id         : 0
cpu cores       : 1
apicid          : 1
initial apicid  : 1
fpu             : yes
fpu_exception   : yes
cpuid level     : 13
wp              : yes
flags           : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ss ht syscall nx pdpe1gb rdtscp lm constant_tsc rep_good nopl xtopology nonstop_tsc cpuid tsc_known_freq pni pclmulqdq ssse3 fma cx16 pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand hypervisor lahf_lm abm 3dnowprefetch invpcid_single pti fsgsbase tsc_adjust bmi1 avx2 smep bmi2 erms invpcid mpx avx512f avx512dq rdseed adx smap clflushopt clwb avx512cd avx512bw avx512vl xsaveopt xsavec xgetbv1 xsaves ida arat pku ospke
bugs            : cpu_meltdown spectre_v1 spectre_v2 spec_store_bypass l1tf mds swapgs itlb_multihit mmio_stale_data retbleed gds
bogomips        : 4999.99
clflush size    : 64
cache_alignment : 64
address sizes   : 46 bits physical, 48 bits virtual
power management:

メモリ

ドキュメントの記載は2GBですが、4GBあります。

$ cat /proc/meminfo
MemTotal:        3919564 kB
MemFree:          212156 kB
MemAvailable:    3155248 kB
Buffers:           82420 kB
Cached:          3004044 kB
SwapCached:            0 kB
Active:           564328 kB
Inactive:        2840924 kB
Active(anon):        684 kB
Inactive(anon):   318944 kB
Active(file):     563644 kB
Inactive(file):  2521980 kB
Unevictable:           0 kB
Mlocked:               0 kB
SwapTotal:             0 kB
SwapFree:              0 kB
Zswap:                 0 kB
Zswapped:              0 kB
Dirty:             14640 kB
Writeback:             0 kB
AnonPages:        309560 kB
Mapped:           454664 kB
Shmem:               840 kB
KReclaimable:     123512 kB
Slab:             194032 kB
SReclaimable:     123512 kB
SUnreclaim:        70520 kB
KernelStack:        5664 kB
PageTables:         7648 kB
SecPageTables:         0 kB
NFS_Unstable:          0 kB
Bounce:                0 kB
WritebackTmp:          0 kB
CommitLimit:     1959780 kB
Committed_AS:    3479776 kB
VmallocTotal:   34359738367 kB
VmallocUsed:       17648 kB
VmallocChunk:          0 kB
Percpu:              984 kB
HardwareCorrupted:     0 kB
AnonHugePages:     34816 kB
ShmemHugePages:        0 kB
ShmemPmdMapped:        0 kB
FileHugePages:         0 kB
FilePmdMapped:         0 kB
HugePages_Total:       0
HugePages_Free:        0
HugePages_Rsvd:        0
HugePages_Surp:        0
Hugepagesize:       2048 kB
Hugetlb:               0 kB
DirectMap4k:      115120 kB
DirectMap2M:     3997696 kB
DirectMap1G:           0 kB

ネットワーク

ensというネットワークインターフェースがありますね。何かしらのセキュリティのインターフェースでしょうか。

$ cat /proc/net/dev
Inter-|   Receive                                                |  Transmit
 face |bytes    packets errs drop fifo frame compressed multicast|bytes    packets errs drop fifo colls carrier compressed
    lo:  246936    1988    0    0    0     0          0         0   246936    1988    0    0    0     0       0          0
  ens5: 737030808  378013    0    0    0     0          0         0 14131513   31527    0    0    0     0       0          0
docker0:       0       0    0    0    0     0          0         0        0       0    0    0    0     0       0          0

グローバルIPも今まで通り取得できます。

$ curl <http://checkip.amazonaws.com/>
XX.XX.XX.XX

ストレージ

/home 領域、ドキュメントの記載は1GBですが、なんだかんだ1.5GBありますね。
またAmazon Linux 2の頃のCloudShellのファイルは、ちゃんと引き継がれています。
この/home領域は120日アクセスがないと自動的に削除されますので注意してください。数日前に削除する旨の警告メールが届きます。

$ df -m
Filesystem     1M-blocks  Used Available Use% Mounted on
overlay            15955  3806     11314  26% /
tmpfs                 64     0        64   0% /dev
shm                   64     0        64   0% /dev/shm
/dev/nvme1n1       15955  3806     11314  26% /home
/dev/loop0           974    10       897   2% /home/cloudshell-user
/dev/nvme0n1p1     30644  4280     26365  14% /aws/mde/mde

AWS CloudShellのシェル環境

AWS CloudShellでは、ドキュメントにあるように以下のシェルが使えます。

  • Bash
  • PowerShell
  • zsh
cshは入っていません。

バージョンは、2023/12/06時点のものです。

$ bash --version
GNU bash, version 5.2.15(1)-release (x86_64-amazon-linux-gnu)
Copyright (C) 2022 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>

This is free software; you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

$ zsh --version
zsh 5.8.1 (x86_64-amazon-linux-gnu)

$ pwsh --version
PowerShell 7.3.8

AWS関連のコマンド

AWS CLIをはじめとして、各種AWSが提供するサービス操作コマンドが入っています。

  • AWS CLI
  • AWS Elastic Beanstalk CLI
  • Amazon ECS CLI
  • AWS SAM

バージョンは、2023/12/06時点のものです。

$ aws --version
aws-cli/2.14.5 Python/3.11.6 Linux/6.1.61-85.141.amzn2023.x86_64 exec-env/CloudShell exe/x86_64.amzn.2023 prompt/off

$ eb --version
EB CLI 3.20.10 (Python 3.9.16 (main, Sep  8 2023, 00:00:00) 
[GCC 11.4.1 20230605 (Red Hat 11.4.1-2)])

$ ecs-cli --version
ecs-cli version 1.21.0 (bb0b8f0)

$ sam --version
SAM CLI, version 1.98.0

ランタイム

プログラム実行環境は、Node.js とPython3が入っています。Amazon Linux 2023 に従い、Python2は削除されていますので気をつけてください。 ruby、gccは入っていないようです。

バージョンは、2023/12/06 時点のものです。

$ node --version
v18.18.2

$ npm --version
9.8.1

$ npm -g ls --depth 0 2>/dev/null | grep aws-sdk
`-- aws-sdk@2.1472.0

$ python --version
Python 3.9.16

$ python3 --version
Python 3.9.16

$ pip --version
pip 21.3.1 from /usr/lib/python3.9/site-packages/pip (python 3.9)

$ pip3 --version
pip 21.3.1 from /usr/lib/python3.9/site-packages/pip (python 3.9)

$ pip3 list | grep boto3
boto3                     1.28.62
boto3-stubs               1.28.55
mypy-boto3-apigateway     1.28.36
mypy-boto3-cloudformation 1.28.48
mypy-boto3-ecr            1.28.45
mypy-boto3-iam            1.28.37
mypy-boto3-lambda         1.28.36
mypy-boto3-s3             1.28.55
mypy-boto3-schemas        1.28.36
mypy-boto3-secretsmanager 1.28.36
mypy-boto3-signer         1.28.36
mypy-boto3-stepfunctions  1.28.36
mypy-boto3-sts            1.28.58
mypy-boto3-xray           1.28.47

その他

エディターは、nano と vim が使えます。

$ nano --version
 GNU nano, version 5.8
 (C) 1999-2011, 2013-2021 Free Software Foundation, Inc.
 (C) 2014-2021 the contributors to nano
 Compiled options: --enable-utf8

$ vim --version
VIM - Vi IMproved 9.0 (2022 Jun 28, compiled Nov 03 2023 00:00:00)
Included patches: 1-2081
Modified by <amazon-linux-engine@amazon.com>
Compiled by <amazon-linux-engine@amazon.com>
(以下略)

また make コマンドが入っています。Amazon Linux 2023 には入っていなかったと思います。

$ make --version
GNU Make 4.3Built for x86_64-amazon-linux-gnu
Copyright (C) 1988-2020 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

ということで、あまり大きくは変わっていませんが、OSが新しくなったのは気持ちがいいですね。
無料で使えるAWS CloudShell を活用していきましょう。

Amazon Linux 2 の深掘りは以下にあります。

タイトルとURLをコピーしました