AWS-CLIを利用して、EC2インスタンスの情報を一覧化して取得することができます。
各EC2の設定内容が一目瞭然でございます。そのままパラメータシートにできます。
aws ec2 describe-instances --output=table --query 'sort_by(Reservations[].Instances[].{InstanceType: InstanceType, ImageID: ImageId, Monitoring: Monitoring.State, InstanceId: InstanceId, SubnetId: join(`, `, NetworkInterfaces[].SubnetId), PrivateIp: join(`, `, NetworkInterfaces[].PrivateIpAddress), Platform:Platform, State: State.Name, KeyName: KeyName, AName: Tags[?Key==`Name`].Value|[0]}, &AName)'
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | DescribeInstances | +--------------------------+------------------------+----------------------+---------------+--------------------+-------------+-----------+----------------+-----------+----------------------------+ | AName | ImageID | InstanceId | InstanceType | KeyName | Monitoring | Platform | PrivateIp | State | SubnetId | +--------------------------+------------------------+----------------------+---------------+--------------------+-------------+-----------+----------------+-----------+----------------------------+ | test-RHEL8.2 | ami-xxxxxxxxxxxxxxxxx | i-xxxxxxxxxxxxxxxxx | t2.micro | test-key | disabled | None | 192.168.10.5 | stopped | subnet-xxxxxxxxxxxxxxxxx | | test-Windows | ami-xxxxxxxxxxxxxxxxx | i-xxxxxxxxxxxxxxxxx | t3.medium | test-key | disabled | windows | 192.168.10.6 | stopped | subnet-xxxxxxxxxxxxxxxxx | | test-Linux | ami-xxxxxxxxxxxxxxxxx | i-xxxxxxxxxxxxxxxxx | t2.micro | test-key | disabled | None | 172.30.20.1 | stopped | subnet-xxxxxxxxxxxxxxxxx | +--------------------------+------------------------+----------------------+---------------+--------------------+-------------+-----------+----------------+-----------+----------------------------+
Nameタグの列名をANameとしているのは、その列を左端に表示させるためです。もっといい方法ありそうだけど。
aws ec2 describe-instances --output=table --query 'sort_by(Reservations[].Instances[].{DeleteOnTermination: join(`, `, NetworkInterfaces[].Attachment.to_string(DeleteOnTermination)), SourceDestCheck: join(`, `, NetworkInterfaces[].to_string(SourceDestCheck)), SecurityGroupName: join(`, `, SecurityGroups[].GroupName) , AName: Tags[?Key==`Name`].Value|[0], ROLE: IamInstanceProfile.Arn}, &AName)'
---------------------------------------------------------------------------------------------------------------------------------------------------------- | DescribeInstances | +--------------------------+----------------------+-------------------------------------------------------------+--------------------+-------------------+ | AName | DeleteOnTermination | ROLE | SecurityGroupName | SourceDestCheck | +--------------------------+----------------------+-------------------------------------------------------------+--------------------+-------------------+ | test-RHEL8.2 | true | arn:aws:iam::xxxxxxxxxxxx:instance-profile/test_CWL | test-public-sg | true | | test-Windows | true | None | test-public-sg | true | | test-Linux | true | None | test-private-sg | true | +--------------------------+----------------------+-------------------------------------------------------------+--------------------+-------------------+
その他よく気にされる項目を出力。上のコマンドと合わせてもいいのですが、横に長くなりすぎるので分割しました。