【AWS CLI】【SSM】全マネージドインスタンスのアプリケーション一覧が欲しい!

記事タイトルとURLをコピーする

こんにちは。AWS CLIが好きな福島です。

今回はタイトル通り、SSMで管理しているマネージドインスタンスのアプリケーション一覧を抽出するコマンドをご紹介いたします。

結論

aws ssm describe-instance-information --query "InstanceInformationList[].[ResourceType,InstanceId]" --output text | while read line
do
   echo "#############################################################"
   echo "### $line"
   echo "#############################################################"
   echo "Name@ApplicationType@Publisher@Version@Release@Epoch@InstalledTime@Architecture@URL@Summary@PackageId" > /tmp/awscli.tmp
   aws ssm list-inventory-entries --instance-id $(echo $line | awk '{print $2}') --type-name AWS:Application --query "Entries[].[Name,ApplicationType,Publisher,Version,Release,Epoch,InstalledTime,Architecture,URL,Summary,PackageId]" --output text | tr "\t" "@" >> /tmp/awscli.tmp;\
   column -s@ -t /tmp/awscli.tmp
done;\
rm /tmp/awscli.tmp
  • 実行結果
#############################################################
### EC2Instance i-0653ccf3e3a08c46b
#############################################################
Name                                                                ApplicationType  Publisher                                Version        Release  Epoch  InstalledTime         Architecture  URL   Summary  PackageId
AWS Tools for Windows                                               None             Amazon Web Services Developer Relations  3.15.1280      None     None   2021-04-14T00:00:00Z  i386          None  None     {02C99ED8-6C38-4D5B-900C-FEAE9CD1AEFF}
aws-cfn-bootstrap                                                   None             Amazon Web Services                      2.0.6          None     None   None                  i386          None  None     {09259595-ce26-4705-b47e-59d9e3ccebb9}
Microsoft Visual C++ 2015-2019 Redistributable (x64) - 14.28.29913  None             Microsoft Corporation                    14.28.29913.0  None     None   None                  i386          None  None     {855e31d2-9031-46e1-b06d-c9d7777deefb}
Amazon SSM Agent                                                    None             Amazon Web Services                      3.1.459.0      None     None   None                  i386          None  None     {a51b2bba-eaff-477d-b802-acd1e2f5329b}
Trend Micro Deep Security Agent                                     None             Trend Micro Inc.                         20.0.2204      None     None   2021-05-18T00:00:00Z  x86_64        None  None     {545B7DBA-39A1-499B-B562-E674B156E0B5}
AWS PV Drivers                                                      None             Amazon Web Services                      8.4.0          None     None   2021-04-14T00:00:00Z  x86_64        None  None     {639AA1C1-738F-4C39-8BFD-135991C6EBE9}
#############################################################
### EC2Instance i-0808672558492fde8
#############################################################
Name                                 ApplicationType               Publisher       Version   Release                     Epoch  InstalledTime         Architecture  URL                                                            Summary                                                                  PackageId
perl-Compress-Raw-Zlib               Development/Libraries         Amazon Linux    2.061     4.amzn2.0.2                 1      2021-06-11T06:18:15Z  x86_64        http://search.cpan.org/dist/Compress-Raw-Zlib/                 Low-level interface to the zlib compression library                      perl-Compress-Raw-Zlib-2.061-4.amzn2.0.2.src.rpm
epel-release                         System Environment/Base       Fedora Project  7         12                          None   2020-08-22T07:24:48Z  noarch        http://download.fedoraproject.org/pub/epel                     Extra Packages for Enterprise Linux repository configuration             epel-release-7-12.src.rpm
dmidecode                            System Environment/Base       Amazon Linux    3.0       5.amzn2.0.2                 1      2020-03-07T03:42:41Z  x86_64        http://www.nongnu.org/dmidecode/                               Tool to analyse BIOS DMI data                                            dmidecode-3.0-5.amzn2.0.2.src.rpm
kbd-misc                             System Environment/Base       Amazon Linux    1.15.5    15.amzn2                    None   2020-03-07T03:42:25Z  noarch        http://ftp.altlinux.org/pub/people/legion/kbd                  Data for kbd package                                                     kbd-1.15.5-15.amzn2.src.rpm
squid                                System Environment/Daemons    Amazon Linux    3.5.20    17.amzn2.6.1                7      2021-06-11T06:18:16Z  x86_64        http://www.squid-cache.org                                     The Squid proxy caching server                                           squid-3.5.20-17.amzn2.6.1.src.rpm
python2-pyrfc3339                    Unspecified                   Fedora Project  1.1       3.el7                       None   2020-08-22T07:25:06Z  noarch        https://pypi.python.org/pypi/pyRFC3339                         Generate and parse RFC 3339 timestamps                                   python-pyrfc3339-1.1-3.el7.src.rpm
hardlink                             System Environment/Base       Amazon Linux    1.3       3.amzn2                     1      2020-03-07T03:42:42Z  x86_64        https://pagure.io/hardlink.git                                 Create a tree of hardlinks                                               hardlink-1.3-3.amzn2.src.rpm
basesystem                           System Environment/Base       Amazon Linux    10.0      7.amzn2.0.1                 None   2020-03-07T03:42:25Z  noarch        (none)                                                         The skeleton package which defines a simple Amazon Linux system          basesystem-10.0-7.amzn2.0.1.src.rpm
python-ndg_httpsclient               Unspecified                   Fedora Project  0.3.2     1.el7                       None   2020-08-22T07:25:07Z  noarch        http://ndg-security.ceda.ac.uk/wiki/ndg_httpsclient/           Provides enhanced HTTPS support for httplib and urllib2 using PyOpenSSL  python-ndg_httpsclient-0.3.2-1.el7.src.rpm
libsepol                             System Environment/Libraries  Amazon Linux    2.5       8.1.amzn2.0.2               None   2020-03-07T03:42:26Z  x86_64        https://github.com/SELinuxProject/selinux/wiki                 SELinux binary policy manipulation library                               libsepol-2.5-8.1.amzn2.0.2.src.rpm
python-zope-component                Development/Libraries         Fedora Project  4.1.0     5.el7                       1      2020-08-22T07:25:07Z  noarch        http://pypi.python.org/pypi/zope.component                     Zope Component Architecture                                              python-zope-component-4.1.0-5.el7.src.rpm
cracklib                             System Environment/Libraries  Amazon Linux    2.9.0     11.amzn2.0.2                None   2020-03-07T03:42:46Z  x86_64        http://sourceforge.net/projects/cracklib/                      A password-checking library                                              cracklib-2.9.0-11.amzn2.0.2.src.rpm
chkconfig                            System Environment/Base       Amazon Linux    1.7.4     1.amzn2.0.2                 None   2020-03-07T03:42:26Z  x86_64        https://github.com/fedora-sysv/chkconfig                       A system tool for maintaining the /etc/rc*.d hierarchy                   chkconfig-1.7.4-1.amzn2.0.2.src.rpm
python2-parsedatetime                Development/Languages         Fedora Project  2.4       6.el7                       None   2020-08-22T07:25:07Z  noarch        https://github.com/bear/parsedatetime                          Parse human-readable date/time strings in Python                         python-parsedatetime-2.4-6.el7.src.rpm
grubby                               System Environment/Base       Amazon Linux    8.28      23.amzn2.0.1                None   2020-03-07T03:42:47Z  x86_64        http://git.fedorahosted.org/git/grubby.git                     Command line tool for updating bootloader configs                        grubby-8.28-23.amzn2.0.1.src.rpm
libdb                                System Environment/Libraries  Amazon Linux    5.3.21    24.amzn2.0.3                None   2020-03-07T03:42:27Z  x86_64        http://www.oracle.com/database/berkeley-db/                    The Berkeley DB database library for C                                   libdb-5.3.21-24.amzn2.0.3.src.rpm
libverto-libevent                    Unspecified                   Amazon Linux    0.2.5     4.amzn2.0.2                 None   2020-03-07T03:42:47Z  x86_64        https://fedorahosted.org/libverto/                             libevent module for libverto                                             libverto-0.2.5-4.amzn2.0.2.src.rpm
kmod                                 System Environment/Kernel     Amazon Linux    25        3.amzn2.0.2                 None   2020-03-07T03:42:27Z  x86_64        http://git.kernel.org/?p=utils/kernel/kmod/kmod.git;a=summary  Linux kernel module management utilities                                 kmod-25-3.amzn2.0.2.src.rpm
python2-dateutil                     Development/Languages         Amazon Linux    2.6.0     3.amzn2.0.1                 1      2020-03-07T03:42:47Z  noarch        https://github.com/dateutil/dateutil                           Powerful extensions to the standard datetime module                      python-dateutil-2.6.0-3.amzn2.0.1.src.rpm
which                                Applications/System           Amazon Linux    2.20      7.amzn2.0.2                 None   2020-03-07T03:42:28Z  x86_64        http://www.xs4all.nl/~carlo17/which/                           Displays where a particular program in your path is located              which-2.20-7.amzn2.0.2.src.rpm
spax                                 Applications/Archiving        Amazon Linux    1.5.2     13.amzn2.0.1                None   2020-09-15T22:41:58Z  x86_64        http://cdrecord.berlios.de/old/private/star.html               Portable archive exchange                                                star-1.5.2-13.amzn2.0.1.src.rpm
python-configobj                     System Environment/Libraries  Amazon Linux    4.7.2     7.amzn2                     None   2020-03-07T03:42:48Z  noarch        http://www.voidspace.org.uk/python/configobj.html              Config file reading, writing, and validation                             python-configobj-4.7.2-7.amzn2.src.rpm
ncurses-compat-libs                  System Environment/Libraries  Amazon Linux    6.0       8.20170212.amzn2.1.3        None   2020-09-15T22:41:58Z  x86_64        http://invisible-island.net/ncurses/ncurses.html               Ncurses compatibility libraries                                          ncurses-6.0-8.20170212.amzn2.1.3.src.rpm
python-colorama                      Unspecified                   Amazon Linux    0.3.2     3.amzn2                     None   2020-03-07T03:42:48Z  noarch        http://pypi.python.org/pypi/colorama/                          Cross-platform colored terminal text                                     python-colorama-0.3.2-3.amzn2.src.rpm
libldb                               Development/Libraries         Amazon Linux    1.5.4     1.amzn2                     None   2020-10-04T03:30:26Z  x86_64        http://ldb.samba.org/                                          A schema-less, ldap like, API and database                               libldb-1.5.4-1.amzn2.src.rpm
python-backports-ssl_match_hostname  Unspecified                   Amazon Linux    3.5.0.1   1.amzn2                     None   2020-03-07T03:42:49Z  noarch        https://bitbucket.org/brandon/backports.ssl_match_hostname     The ssl.match_hostname() function from Python 3                          python-backports-ssl_match_hostname-3.5.0.1-1.amzn2.src.rpm
libmnl                               System Environment/Libraries  Amazon Linux    1.0.3     7.amzn2.0.2                 None   2020-03-07T03:42:30Z  x86_64        http://netfilter.org/projects/libmnl                           A minimalistic Netlink library                                           libmnl-1.0.3-7.amzn2.0.2.src.rpm
glusterfs                            System Environment/Base       Amazon Linux    3.12.2    18.amzn2                    None   2020-10-04T03:30:26Z  x86_64        http://gluster.readthedocs.io/en/latest/                       Distributed File System                                                  glusterfs-3.12.2-18.amzn2.src.rpm
tcpdump                              Applications/Internet         Amazon Linux    4.9.2     4.amzn2.1                   14     2020-03-07T03:43:24Z  x86_64        http://www.tcpdump.org                                         A network traffic monitoring tool                                        tcpdump-4.9.2-4.amzn2.1.src.rpm
libcollection                        Development/Libraries         Amazon Linux    0.7.0     29.amzn2                    None   2020-03-07T03:42:35Z  x86_64        https://pagure.io/SSSD/ding-libs                               Collection data-type for C                                               ding-libs-0.6.1-29.amzn2.src.rpm
libtevent-devel                      Development/Libraries         Amazon Linux    0.9.39    1.amzn2                     None   2020-10-04T03:30:26Z  x86_64        http://tevent.samba.org/                                       Developer tools for the Tevent library                                   libtevent-0.9.39-1.amzn2.src.rpm
boost-thread                         System Environment/Libraries  Amazon Linux    1.53.0    27.amzn2.0.3                None   2020-03-07T03:42:35Z  x86_64        http://www.boost.org                                           Run-Time component of boost thread library                               boost-1.53.0-27.amzn2.0.3.src.rpm
python-dns                           Development/Languages         Amazon Linux    1.12.0    4.20150617git465785f.amzn2  None   2020-10-04T03:30:27Z  noarch        http://www.dnspython.org/                                      DNS toolkit for Python                                                   python-dns-1.12.0-4.20150617git465785f.amzn2.src.rpm
wget                                 Applications/Internet         Amazon Linux    1.14      18.amzn2.1                  None   2020-03-07T03:43:26Z  x86_64        http://www.gnu.org/software/wget/                              A utility for retrieving files using the HTTP or FTP protocols           wget-1.14-18.amzn2.1.src.rpm
perl-Encode                          Development/Libraries         Amazon Linux    2.51      7.amzn2.0.2                 None   2020-03-07T03:42:36Z  x86_64        http://search.cpan.org/dist/Encode/                            Character encodings in Perl                                              perl-Encode-2.51-7.amzn2.0.2.src.rpm
trousers                             System Environment/Libraries  Amazon Linux    0.3.14    2.amzn2.0.2                 None   2020-10-04T03:30:27Z  x86_64        http://trousers.sourceforge.net                                TCG's Software Stack v1.2                                                trousers-0.3.14-2.amzn2.0.2.src.rpm
nano                                 Unspecified                   Amazon Linux    2.9.8     2.amzn2.0.1                 None   2020-03-07T03:43:27Z  x86_64        https://www.nano-editor.org                                    A small text editor                                                      nano-2.9.8-2.amzn2.0.1.src.rpm
perl-Carp                            Development/Libraries         Amazon Linux    1.26      244.amzn2                   None   2020-03-07T03:42:36Z  noarch        http://search.cpan.org/dist/Carp/                              Alternative warn and die for modules                                     perl-Carp-1.26-244.amzn2.src.rpm
psmisc                               Applications/System           Amazon Linux    22.20     15.amzn2.0.2                None   2020-03-07T03:43:27Z  x86_64        http://sourceforge.net/projects/psmisc                         Utilities for managing processes on your system                          psmisc-22.20-15.amzn2.0.2.src.rpm
perl-Storable                        Development/Libraries         Amazon Linux    2.45      3.amzn2.0.2                 None   2020-03-07T03:42:36Z  x86_64        http://search.cpan.org/dist/Storable/                          Persistence for Perl data structures                                     perl-Storable-2.45-3.amzn2.0.2.src.rpm
setserial                            Applications/System           Amazon Linux    2.17      33.amzn2.0.1                None   2020-03-07T03:43:28Z  x86_64        http://setserial.sourceforge.net/                              A utility for configuring serial ports                                   setserial-2.17-33.amzn2.0.1.src.rpm
keyutils                             System Environment/Base       Amazon Linux    1.5.8     3.amzn2.0.2                 None   2020-03-07T03:42:37Z  x86_64        http://people.redhat.com/~dhowells/keyutils/                   Linux Key Management Utilities                                           keyutils-1.5.8-3.amzn2.0.2.src.rpm
rootfiles                            System Environment/Base       Amazon Linux    8.1       11.amzn2                    None   2020-03-07T03:43:36Z  noarch        (none)                                                         The basic required files for the root user's directory                   rootfiles-8.1-11.amzn2.src.rpm
sysvinit-tools                       System Environment/Base       Amazon Linux    2.88      14.dsf.amzn2.0.2            None   2020-03-07T03:42:37Z  x86_64        http://savannah.nongnu.org/projects/sysvinit/                  Tools used for process and utmp management.                              sysvinit-2.88-14.dsf.amzn2.0.2.src.rpm
boost-date-time                      System Environment/Libraries  Amazon Linux    1.53.0    27.amzn2.0.3                None   2020-03-07T03:42:38Z  x86_64        http://www.boost.org                                           Run-Time component of boost date-time library                            boost-1.53.0-27.amzn2.0.3.src.rpm
setup                                System Environment/Base       Amazon Linux    2.8.71    10.amzn2.0.1                None   2020-03-07T03:42:25Z  noarch        https://pagure.io/setup/                                       A set of system configuration and setup files                            setup-2.8.71-10.amzn2.0.1.src.rpm
sgpio                                System Environment/Base       Amazon Linux    1.2.0.10  13.amzn2.0.1                None   2020-03-07T03:42:41Z  x86_64        http://sources.redhat.com/lvm2/wiki/DMRAID_Eventing            SGPIO captive backplane tool                                             sgpio-1.2.0.10-13.amzn2.0.1.src.rpm
jbigkit-libs                         Development/Libraries         Amazon Linux    2.0       11.amzn2.0.2                None   2020-03-07T03:42:41Z  x86_64        http://www.cl.cam.ac.uk/~mgk25/jbigkit/                        JBIG1 lossless image compression library                                 jbigkit-2.0-11.amzn2.0.2.src.rpm
tzdata                               System Environment/Base       Amazon Linux    2020a     1.amzn2                     None   2020-11-16T05:46:09Z  noarch        https://www.iana.org/time-zones                                Timezone data                                                            tzdata-2020a-1.amzn2.src.rpm
xz-libs                              System Environment/Libraries  Amazon Linux    5.2.2     1.amzn2.0.2                 None   2020-03-07T03:42:26Z  x86_64        http://tukaani.org/xz/                                         Libraries for decoding LZMA compression                                  xz-5.2.2-1.amzn2.0.2.src.rpm

終わりに

今回は、マネージドインスタンスのアプリケーション一覧を出力するコマンドをご紹介いたしました。 どなたかのお役に立てれば幸いです。

福島 和弥 (記事一覧)

SRE3課

2019/10 入社

AWS CLIが好きです。