🏄‍♂️

思い立って70分で tfenv の CircleCI Orb を作った

2021/08/27に公開

いろいろ後で書き足して記事っぽくしていこうとは思うのですが、
tfenvCircleCI Orb を作りました。
役立ちそうであれば使ってみてください。

sogaoh/orb-tfenv

https://circleci.com/developer/orbs/orb/sogaoh/orb-tfenv

使い方の例は以下のような感じです。
terraform --version しかやってないですが、plan や apply もできると思います。destroy も。
https://github.com/sogaoh/orb-tfenv/blob/main/.circleci/config.yml

.circleci/config.yml

version: 2.1
orbs:
  tfenv: sogaoh/orb-tfenv@0.0.1

jobs:
  build:
    docker:
    - image: amazonlinux:2
    parameters:
      terraform_version:
        description: version of terraform
        type: string
        default: 1.0.5
    steps:
    - run:
       name: Install Tools (PreRequirements for orb-tfenv)
       command: |
         yum install -y git unzip
    - tfenv/install
    - run:
        name: Install terraform & Show Version
        command: |
          VERSION="<< parameters.terraform_version >>"
          tfenv install ${VERSION}
          tfenv use ${VERSION}
          terraform --version

workflows:
  main:
    jobs:
    - build
local実行したときのコンソール出力

❯ circleci local execute --job build
Docker image digest: sha256:35d5389d587ca45d1fd79940e34fa916c8ca2ef7b9515f1c0920d722dff8d02a
--> Processing Dependency: /usr/bin/perl for package: git-2.32.0-1.amzn2.0.1.x86_64
---> Package unzip.x86_64 0:6.0-43.amzn2 will be installed
--> Running transaction check
---> Package emacs-filesystem.noarch 1:27.2-4.amzn2.0.1 will be installed
---> Package git-core.x86_64 0:2.32.0-1.amzn2.0.1 will be installed
--> Processing Dependency: openssh-clients for package: git-core-2.32.0-1.amzn2.0.1.x86_64
--> Processing Dependency: less for package: git-core-2.32.0-1.amzn2.0.1.x86_64
--> Processing Dependency: libpcre2-8.so.0()(64bit) for package: git-core-2.32.0-1.amzn2.0.1.x86_64
---> Package git-core-doc.noarch 0:2.32.0-1.amzn2.0.1 will be installed
---> Package perl.x86_64 4:5.16.3-299.amzn2.0.1 will be installed
--> Processing Dependency: perl-libs = 4:5.16.3-299.amzn2.0.1 for package: 4:perl-5.16.3-299.amzn2.0.1.x86_64
--> Processing Dependency: perl(Socket) >= 1.3 for package: 4:perl-5.16.3-299.amzn2.0.1.x86_64
--> Processing Dependency: perl(Scalar::Util) >= 1.10 for package: 4:perl-5.16.3-299.amzn2.0.1.x86_64
--> Processing Dependency: perl-macros for package: 4:perl-5.16.3-299.amzn2.0.1.x86_64
--> Processing Dependency: perl-libs for package: 4:perl-5.16.3-299.amzn2.0.1.x86_64
--> Processing Dependency: perl(threads::shared) for package: 4:perl-5.16.3-299.amzn2.0.1.x86_64
--> Processing Dependency: perl(threads) for package: 4:perl-5.16.3-299.amzn2.0.1.x86_64
--> Processing Dependency: perl(constant) for package: 4:perl-5.16.3-299.amzn2.0.1.x86_64
--> Processing Dependency: perl(Time::Local) for package: 4:perl-5.16.3-299.amzn2.0.1.x86_64
--> Processing Dependency: perl(Time::HiRes) for package: 4:perl-5.16.3-299.amzn2.0.1.x86_64
--> Processing Dependency: perl(Storable) for package: 4:perl-5.16.3-299.amzn2.0.1.x86_64
--> Processing Dependency: perl(Socket) for package: 4:perl-5.16.3-299.amzn2.0.1.x86_64
--> Processing Dependency: perl(Scalar::Util) for package: 4:perl-5.16.3-299.amzn2.0.1.x86_64
--> Processing Dependency: perl(Pod::Simple::XHTML) for package: 4:perl-5.16.3-299.amzn2.0.1.x86_64
--> Processing Dependency: perl(Pod::Simple::Search) for package: 4:perl-5.16.3-299.amzn2.0.1.x86_64
--> Processing Dependency: perl(Filter::Util::Call) for package: 4:perl-5.16.3-299.amzn2.0.1.x86_64
--> Processing Dependency: perl(File::Temp) for package: 4:perl-5.16.3-299.amzn2.0.1.x86_64
--> Processing Dependency: perl(File::Path) for package: 4:perl-5.16.3-299.amzn2.0.1.x86_64
--> Processing Dependency: perl(Exporter) for package: 4:perl-5.16.3-299.amzn2.0.1.x86_64
--> Processing Dependency: perl(Carp) for package: 4:perl-5.16.3-299.amzn2.0.1.x86_64
--> Processing Dependency: libperl.so()(64bit) for package: 4:perl-5.16.3-299.amzn2.0.1.x86_64
---> Package perl-Getopt-Long.noarch 0:2.40-3.amzn2 will be installed
--> Processing Dependency: perl(Pod::Usage) >= 1.14 for package: perl-Getopt-Long-2.40-3.amzn2.noarch
--> Processing Dependency: perl(Text::ParseWords) for package: perl-Getopt-Long-2.40-3.amzn2.noarch
---> Package perl-Git.noarch 0:2.32.0-1.amzn2.0.1 will be installed
--> Processing Dependency: perl(Error) for package: perl-Git-2.32.0-1.amzn2.0.1.noarch
---> Package perl-PathTools.x86_64 0:3.40-5.amzn2.0.2 will be installed
---> Package perl-TermReadKey.x86_64 0:2.30-20.amzn2.0.2 will be installed
--> Running transaction check
---> Package less.x86_64 0:458-9.amzn2.0.2 will be installed
--> Processing Dependency: groff-base for package: less-458-9.amzn2.0.2.x86_64
---> Package openssh-clients.x86_64 0:7.4p1-21.amzn2.0.3 will be installed
--> Processing Dependency: openssh = 7.4p1-21.amzn2.0.3 for package: openssh-clients-7.4p1-21.amzn2.0.3.x86_64
--> Processing Dependency: fipscheck-lib(x86-64) >= 1.3.0 for package: openssh-clients-7.4p1-21.amzn2.0.3.x86_64
--> Processing Dependency: libfipscheck.so.1()(64bit) for package: openssh-clients-7.4p1-21.amzn2.0.3.x86_64
--> Processing Dependency: libedit.so.0()(64bit) for package: openssh-clients-7.4p1-21.amzn2.0.3.x86_64
---> Package pcre2.x86_64 0:10.23-2.amzn2.0.2 will be installed
---> Package perl-Carp.noarch 0:1.26-244.amzn2 will be installed
---> Package perl-Error.noarch 1:0.17020-2.amzn2 will be installed
---> Package perl-Exporter.noarch 0:5.68-3.amzn2 will be installed
---> Package perl-File-Path.noarch 0:2.09-2.amzn2 will be installed
---> Package perl-File-Temp.noarch 0:0.23.01-3.amzn2 will be installed
---> Package perl-Filter.x86_64 0:1.49-3.amzn2.0.2 will be installed
---> Package perl-Pod-Simple.noarch 1:3.28-4.amzn2 will be installed
--> Processing Dependency: perl(Pod::Escapes) >= 1.04 for package: 1:perl-Pod-Simple-3.28-4.amzn2.noarch
--> Processing Dependency: perl(Encode) for package: 1:perl-Pod-Simple-3.28-4.amzn2.noarch
---> Package perl-Pod-Usage.noarch 0:1.63-3.amzn2 will be installed
--> Processing Dependency: perl(Pod::Text) >= 3.15 for package: perl-Pod-Usage-1.63-3.amzn2.noarch
--> Processing Dependency: perl-Pod-Perldoc for package: perl-Pod-Usage-1.63-3.amzn2.noarch
---> Package perl-Scalar-List-Utils.x86_64 0:1.27-248.amzn2.0.2 will be installed
---> Package perl-Socket.x86_64 0:2.010-4.amzn2.0.2 will be installed
---> Package perl-Storable.x86_64 0:2.45-3.amzn2.0.2 will be installed
---> Package perl-Text-ParseWords.noarch 0:3.29-4.amzn2 will be installed
---> Package perl-Time-HiRes.x86_64 4:1.9725-3.amzn2.0.2 will be installed
---> Package perl-Time-Local.noarch 0:1.2300-2.amzn2 will be installed
---> Package perl-constant.noarch 0:1.27-2.amzn2.0.1 will be installed
---> Package perl-libs.x86_64 4:5.16.3-299.amzn2.0.1 will be installed
---> Package perl-macros.x86_64 4:5.16.3-299.amzn2.0.1 will be installed
---> Package perl-threads.x86_64 0:1.87-4.amzn2.0.2 will be installed
---> Package perl-threads-shared.x86_64 0:1.43-6.amzn2.0.2 will be installed
--> Running transaction check
---> Package fipscheck-lib.x86_64 0:1.4.1-6.amzn2.0.2 will be installed
--> Processing Dependency: /usr/bin/fipscheck for package: fipscheck-lib-1.4.1-6.amzn2.0.2.x86_64
---> Package groff-base.x86_64 0:1.22.2-8.amzn2.0.2 will be installed
---> Package libedit.x86_64 0:3.0-12.20121213cvs.amzn2.0.2 will be installed
---> Package openssh.x86_64 0:7.4p1-21.amzn2.0.3 will be installed
--> Processing Dependency: audit-libs >= 1.0.8 for package: openssh-7.4p1-21.amzn2.0.3.x86_64
--> Processing Dependency: /sbin/nologin for package: openssh-7.4p1-21.amzn2.0.3.x86_64
---> Package perl-Encode.x86_64 0:2.51-7.amzn2.0.2 will be installed
---> Package perl-Pod-Escapes.noarch 1:1.04-299.amzn2.0.1 will be installed
---> Package perl-Pod-Perldoc.noarch 0:3.20-4.amzn2 will be installed
--> Processing Dependency: perl(parent) for package: perl-Pod-Perldoc-3.20-4.amzn2.noarch
--> Processing Dependency: perl(HTTP::Tiny) for package: perl-Pod-Perldoc-3.20-4.amzn2.noarch
---> Package libsmartcols.x86_64 0:2.30.2-2.amzn2.0.4 will be installed
---> Package libutempter.x86_64 0:1.1.6-4.amzn2.0.2 will be installed
--> Processing Dependency: shadow-utils for package: libutempter-1.1.6-4.amzn2.0.2.x86_64
---> Package pam.x86_64 0:1.1.8-23.amzn2.0.1 will be installed
--> Processing Dependency: libpwquality >= 0.9.9 for package: pam-1.1.8-23.amzn2.0.1.x86_64
--> Processing Dependency: cracklib-dicts >= 2.8 for package: pam-1.1.8-23.amzn2.0.1.x86_64
--> Processing Dependency: libcrack.so.2()(64bit) for package: pam-1.1.8-23.amzn2.0.1.x86_64
---> Package systemd-libs.x86_64 0:219-78.amzn2.0.14 will be installed
--> Processing Dependency: liblz4.so.1()(64bit) for package: systemd-libs-219-78.amzn2.0.14.x86_64
--> Processing Dependency: libdw.so.1()(64bit) for package: systemd-libs-219-78.amzn2.0.14.x86_64
--> Running transaction check
---> Package cracklib.x86_64 0:2.9.0-11.amzn2.0.2 will be installed
--> Processing Dependency: gzip for package: cracklib-2.9.0-11.amzn2.0.2.x86_64
---> Package cracklib-dicts.x86_64 0:2.9.0-11.amzn2.0.2 will be installed
---> Package elfutils-libs.x86_64 0:0.176-2.amzn2 will be installed
--> Processing Dependency: default-yama-scope for package: elfutils-libs-0.176-2.amzn2.x86_64
---> Package libpwquality.x86_64 0:1.2.3-5.amzn2 will be installed
---> Package lz4.x86_64 0:1.7.5-2.amzn2.0.1 will be installed
---> Package shadow-utils.x86_64 2:4.1.5.1-24.amzn2.0.2 will be installed
--> Processing Dependency: libsemanage.so.1(LIBSEMANAGE_1.0)(64bit) for package: 2:shadow-utils-4.1.5.1-24.amzn2.0.2.x86_64
--> Processing Dependency: libsemanage.so.1()(64bit) for package: 2:shadow-utils-4.1.5.1-24.amzn2.0.2.x86_64
--> Running transaction check
---> Package elfutils-default-yama-scope.noarch 0:0.176-2.amzn2 will be installed
--> Processing Dependency: systemd for package: elfutils-default-yama-scope-0.176-2.amzn2.noarch
--> Processing Dependency: systemd for package: elfutils-default-yama-scope-0.176-2.amzn2.noarch
--> Processing Dependency: systemd for package: elfutils-default-yama-scope-0.176-2.amzn2.noarch
---> Package gzip.x86_64 0:1.5-10.amzn2 will be installed
---> Package libsemanage.x86_64 0:2.5-11.amzn2 will be installed
--> Processing Dependency: libustr-1.0.so.1(USTR_1.0.1)(64bit) for package: libsemanage-2.5-11.amzn2.x86_64
--> Processing Dependency: libustr-1.0.so.1(USTR_1.0)(64bit) for package: libsemanage-2.5-11.amzn2.x86_64
--> Processing Dependency: libustr-1.0.so.1()(64bit) for package: libsemanage-2.5-11.amzn2.x86_64
--> Running transaction check
---> Package systemd.x86_64 0:219-78.amzn2.0.14 will be installed
--> Processing Dependency: kmod >= 18-4 for package: systemd-219-78.amzn2.0.14.x86_64
--> Processing Dependency: libkmod.so.2(LIBKMOD_5)(64bit) for package: systemd-219-78.amzn2.0.14.x86_64
--> Processing Dependency: libcryptsetup.so.4(CRYPTSETUP_1.0)(64bit) for package: systemd-219-78.amzn2.0.14.x86_64
--> Processing Dependency: dbus for package: systemd-219-78.amzn2.0.14.x86_64
--> Processing Dependency: acl for package: systemd-219-78.amzn2.0.14.x86_64
--> Processing Dependency: libqrencode.so.3()(64bit) for package: systemd-219-78.amzn2.0.14.x86_64
--> Processing Dependency: libkmod.so.2()(64bit) for package: systemd-219-78.amzn2.0.14.x86_64
--> Processing Dependency: libcryptsetup.so.4()(64bit) for package: systemd-219-78.amzn2.0.14.x86_64
---> Package ustr.x86_64 0:1.0.4-16.amzn2.0.3 will be installed
--> Running transaction check
---> Package acl.x86_64 0:2.2.51-14.amzn2 will be installed
---> Package cryptsetup-libs.x86_64 0:1.7.4-4.amzn2 will be installed
--> Processing Dependency: libdevmapper.so.1.02(DM_1_02_97)(64bit) for package: cryptsetup-libs-1.7.4-4.amzn2.x86_64
--> Processing Dependency: libdevmapper.so.1.02(Base)(64bit) for package: cryptsetup-libs-1.7.4-4.amzn2.x86_64
--> Processing Dependency: libdevmapper.so.1.02()(64bit) for package: cryptsetup-libs-1.7.4-4.amzn2.x86_64
---> Package dbus.x86_64 1:1.10.24-7.amzn2 will be installed
--> Processing Dependency: dbus-libs(x86-64) = 1:1.10.24-7.amzn2 for package: 1:dbus-1.10.24-7.amzn2.x86_64
--> Processing Dependency: libdbus-1.so.3(LIBDBUS_PRIVATE_1.10.24)(64bit) for package: 1:dbus-1.10.24-7.amzn2.x86_64
--> Processing Dependency: libdbus-1.so.3(LIBDBUS_1_3)(64bit) for package: 1:dbus-1.10.24-7.amzn2.x86_64
--> Processing Dependency: libdbus-1.so.3()(64bit) for package: 1:dbus-1.10.24-7.amzn2.x86_64
---> Package kmod.x86_64 0:25-3.amzn2.0.2 will be installed
---> Package kmod-libs.x86_64 0:25-3.amzn2.0.2 will be installed
---> Package qrencode-libs.x86_64 0:3.4.1-3.amzn2.0.2 will be installed
--> Running transaction check
---> Package dbus-libs.x86_64 1:1.10.24-7.amzn2 will be installed
---> Package device-mapper-libs.x86_64 7:1.02.146-4.amzn2.0.2 will be installed
--> Processing Dependency: device-mapper = 7:1.02.146-4.amzn2.0.2 for package: 7:device-mapper-libs-1.02.146-4.amzn2.0.2.x86_64
--> Running transaction check
---> Package device-mapper.x86_64 7:1.02.146-4.amzn2.0.2 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

================================================================================
 Package                   Arch   Version                      Repository  Size
================================================================================
Installing:
 git                       x86_64 2.32.0-1.amzn2.0.1           amzn2-core 126 k
 unzip                     x86_64 6.0-43.amzn2                 amzn2-core 179 k
Installing for dependencies:
 acl                       x86_64 2.2.51-14.amzn2              amzn2-core  82 k
 audit-libs                x86_64 2.8.1-3.amzn2.1              amzn2-core  99 k
 cracklib                  x86_64 2.9.0-11.amzn2.0.2           amzn2-core  80 k
 cracklib-dicts            x86_64 2.9.0-11.amzn2.0.2           amzn2-core 3.6 M
 cryptsetup-libs           x86_64 1.7.4-4.amzn2                amzn2-core 224 k
 dbus                      x86_64 1:1.10.24-7.amzn2            amzn2-core 247 k
 dbus-libs                 x86_64 1:1.10.24-7.amzn2            amzn2-core 169 k
 device-mapper             x86_64 7:1.02.146-4.amzn2.0.2       amzn2-core 289 k
 device-mapper-libs        x86_64 7:1.02.146-4.amzn2.0.2       amzn2-core 320 k
 elfutils-default-yama-scope
 kmod-libs                 x86_64 25-3.amzn2.0.2               amzn2-core  59 k
 less                      x86_64 458-9.amzn2.0.2              amzn2-core 121 k
 libcap-ng                 x86_64 0.7.5-4.amzn2.0.4            amzn2-core  25 k
 libedit                   x86_64 3.0-12.20121213cvs.amzn2.0.2 amzn2-core  93 k
 libfdisk                  x86_64 2.30.2-2.amzn2.0.4           amzn2-core 240 k
 libpwquality              x86_64 1.2.3-5.amzn2                amzn2-core  84 k
 libsemanage               x86_64 2.5-11.amzn2                 amzn2-core 152 k
 libsmartcols              x86_64 2.30.2-2.amzn2.0.4           amzn2-core 156 k
 libutempter               x86_64 1.1.6-4.amzn2.0.2            amzn2-core  25 k
 lz4                       x86_64 1.7.5-2.amzn2.0.1            amzn2-core  99 k
 openssh                   x86_64 7.4p1-21.amzn2.0.3           amzn2-core 507 k
 openssh-clients           x86_64 7.4p1-21.amzn2.0.3           amzn2-core 650 k
 pam                       x86_64 1.1.8-23.amzn2.0.1           amzn2-core 715 k
 pcre2                     x86_64 10.23-2.amzn2.0.2            amzn2-core 209 k
 perl                      x86_64 4:5.16.3-299.amzn2.0.1       amzn2-core 8.0 M
 perl-Carp                 noarch 1.26-244.amzn2               amzn2-core  19 k
 perl-Encode               x86_64 2.51-7.amzn2.0.2             amzn2-core 1.5 M
 perl-Error                noarch 1:0.17020-2.amzn2            amzn2-core  32 k
 perl-Exporter             noarch 5.68-3.amzn2                 amzn2-core  29 k
 perl-File-Path            noarch 2.09-2.amzn2                 amzn2-core  27 k
 perl-File-Temp            noarch 0.23.01-3.amzn2              amzn2-core  56 k
 perl-Filter               x86_64 1.49-3.amzn2.0.2             amzn2-core  76 k
 perl-Getopt-Long          noarch 2.40-3.amzn2                 amzn2-core  56 k
 perl-Git                  noarch 2.32.0-1.amzn2.0.1           amzn2-core  43 k
 perl-HTTP-Tiny            noarch 0.033-3.amzn2                amzn2-core  38 k
 perl-PathTools            x86_64 3.40-5.amzn2.0.2             amzn2-core  83 k
 perl-Pod-Escapes          noarch 1:1.04-299.amzn2.0.1         amzn2-core  52 k
 perl-Pod-Perldoc          noarch 3.20-4.amzn2                 amzn2-core  87 k
 perl-Pod-Simple           noarch 1:3.28-4.amzn2               amzn2-core 216 k
 perl-Pod-Usage            noarch 1.63-3.amzn2                 amzn2-core  27 k
 perl-Scalar-List-Utils    x86_64 1.27-248.amzn2.0.2           amzn2-core  36 k
 perl-Socket               x86_64 2.010-4.amzn2.0.2            amzn2-core  49 k
 perl-Storable             x86_64 2.45-3.amzn2.0.2             amzn2-core  78 k
 perl-TermReadKey          x86_64 2.30-20.amzn2.0.2            amzn2-core  31 k
 perl-Text-ParseWords      noarch 3.29-4.amzn2                 amzn2-core  14 k
 perl-Time-HiRes           x86_64 4:1.9725-3.amzn2.0.2         amzn2-core  45 k
 perl-Time-Local           noarch 1.2300-2.amzn2               amzn2-core  24 k
 perl-constant             noarch 1.27-2.amzn2.0.1             amzn2-core  19 k
 perl-libs                 x86_64 4:5.16.3-299.amzn2.0.1       amzn2-core 685 k
 perl-macros               x86_64 4:5.16.3-299.amzn2.0.1       amzn2-core  44 k
 perl-parent               noarch 1:0.225-244.amzn2.0.1        amzn2-core  12 k
 perl-podlators            noarch 2.5.1-3.amzn2.0.1            amzn2-core 112 k
 perl-threads              x86_64 1.87-4.amzn2.0.2             amzn2-core  50 k
 perl-threads-shared       x86_64 1.43-6.amzn2.0.2             amzn2-core  39 k
 qrencode-libs             x86_64 3.4.1-3.amzn2.0.2            amzn2-core  50 k
 shadow-utils              x86_64 2:4.1.5.1-24.amzn2.0.2       amzn2-core 1.1 M
 systemd                   x86_64 219-78.amzn2.0.14            amzn2-core 5.0 M
 systemd-libs              x86_64 219-78.amzn2.0.14            amzn2-core 408 k
 ustr                      x86_64 1.0.4-16.amzn2.0.3           amzn2-core  96 k
 util-linux                x86_64 2.30.2-2.amzn2.0.4           amzn2-core 2.3 M

Transaction Summary
================================================================================
Install  2 Packages (+69 Dependent packages)

Total download size: 38 M
Installed size: 138 M
Downloading packages:
(1/71): acl-2.2.51-14.amzn2.x86_64.rpm                     |  82 kB   00:00
(2/71): cracklib-2.9.0-11.amzn2.0.2.x86_64.rpm             |  80 kB   00:00
(3/71): audit-libs-2.8.1-3.amzn2.1.x86_64.rpm              |  99 kB   00:00
(4/71): cryptsetup-libs-1.7.4-4.amzn2.x86_64.rpm           | 224 kB   00:00
(21/71): kmod-libs-25-3.amzn2.0.2.x86_64.rpm               |  59 kB   00:00
(22/71): less-458-9.amzn2.0.2.x86_64.rpm                   | 121 kB   00:00
(23/71): libcap-ng-0.7.5-4.amzn2.0.4.x86_64.rpm            |  25 kB   00:00
(24/71): libedit-3.0-12.20121213cvs.amzn2.0.2.x86_64.rpm   |  93 kB   00:00
(25/71): libfdisk-2.30.2-2.amzn2.0.4.x86_64.rpm            | 240 kB   00:00
(26/71): libpwquality-1.2.3-5.amzn2.x86_64.rpm             |  84 kB   00:00
(27/71): libsmartcols-2.30.2-2.amzn2.0.4.x86_64.rpm        | 156 kB   00:00
(28/71): libsemanage-2.5-11.amzn2.x86_64.rpm               | 152 kB   00:00
(29/71): libutempter-1.1.6-4.amzn2.0.2.x86_64.rpm          |  25 kB   00:00
(30/71): lz4-1.7.5-2.amzn2.0.1.x86_64.rpm                  |  99 kB   00:00
(31/71): openssh-clients-7.4p1-21.amzn2.0.3.x86_64.rpm     | 650 kB   00:00
(32/71): openssh-7.4p1-21.amzn2.0.3.x86_64.rpm             | 507 kB   00:00
(33/71): pcre2-10.23-2.amzn2.0.2.x86_64.rpm                | 209 kB   00:00
(34/71): pam-1.1.8-23.amzn2.0.1.x86_64.rpm                 | 715 kB   00:00
(35/71): perl-Carp-1.26-244.amzn2.noarch.rpm               |  19 kB   00:00
(36/71): perl-Encode-2.51-7.amzn2.0.2.x86_64.rpm           | 1.5 MB   00:00
(48/71): perl-Pod-Simple-3.28-4.amzn2.noarch.rpm           | 216 kB   00:00
(49/71): perl-5.16.3-299.amzn2.0.1.x86_64.rpm              | 8.0 MB   00:00
(50/71): perl-Pod-Usage-1.63-3.amzn2.noarch.rpm            |  27 kB   00:00
(51/71): perl-Scalar-List-Utils-1.27-248.amzn2.0.2.x86_64. |  36 kB   00:00
(52/71): perl-Storable-2.45-3.amzn2.0.2.x86_64.rpm         |  78 kB   00:00
(53/71): perl-TermReadKey-2.30-20.amzn2.0.2.x86_64.rpm     |  31 kB   00:00
(54/71): perl-Text-ParseWords-3.29-4.amzn2.noarch.rpm      |  14 kB   00:00
(55/71): perl-Time-HiRes-1.9725-3.amzn2.0.2.x86_64.rpm     |  45 kB   00:00
(56/71): perl-Time-Local-1.2300-2.amzn2.noarch.rpm         |  24 kB   00:00
(57/71): perl-constant-1.27-2.amzn2.0.1.noarch.rpm         |  19 kB   00:00
(58/71): perl-libs-5.16.3-299.amzn2.0.1.x86_64.rpm         | 685 kB   00:00
(59/71): perl-macros-5.16.3-299.amzn2.0.1.x86_64.rpm       |  44 kB   00:00
(60/71): perl-parent-0.225-244.amzn2.0.1.noarch.rpm        |  12 kB   00:00
(61/71): perl-podlators-2.5.1-3.amzn2.0.1.noarch.rpm       | 112 kB   00:00
(62/71): perl-Socket-2.010-4.amzn2.0.2.x86_64.rpm          |  49 kB   00:00
(63/71): perl-threads-1.87-4.amzn2.0.2.x86_64.rpm          |  50 kB   00:00
(64/71): perl-threads-shared-1.43-6.amzn2.0.2.x86_64.rpm   |  39 kB   00:00
(65/71): qrencode-libs-3.4.1-3.amzn2.0.2.x86_64.rpm        |  50 kB   00:00
(71/71): systemd-219-78.amzn2.0.14.x86_64.rpm              | 5.0 MB   00:00
--------------------------------------------------------------------------------
Total                                               59 MB/s |  38 MB  00:00
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : libcap-ng-0.7.5-4.amzn2.0.4.x86_64                          1/71
  Installing : audit-libs-2.8.1-3.amzn2.1.x86_64                           2/71
  Installing : groff-base-1.22.2-8.amzn2.0.2.x86_64                        3/71
  Installing : lz4-1.7.5-2.amzn2.0.1.x86_64                                4/71
  Installing : less-458-9.amzn2.0.2.x86_64                                 5/71
  Installing : perl-HTTP-Tiny-0.033-3.amzn2.noarch                         6/71
  Installing : 1:perl-parent-0.225-244.amzn2.0.1.noarch                    7/71
  Installing : perl-podlators-2.5.1-3.amzn2.0.1.noarch                     8/71
  Installing : perl-Pod-Perldoc-3.20-4.amzn2.noarch                        9/71
  Installing : 1:perl-Pod-Escapes-1.04-299.amzn2.0.1.noarch               10/71
  Installing : perl-Text-ParseWords-3.29-4.amzn2.noarch                   11/71
  Installing : perl-Pod-Usage-1.63-3.amzn2.noarch                         12/71
  Installing : perl-Encode-2.51-7.amzn2.0.2.x86_64                        13/71
  Installing : 4:perl-macros-5.16.3-299.amzn2.0.1.x86_64                  14/71
  Installing : perl-Filter-1.49-3.amzn2.0.2.x86_64                        15/71
  Installing : perl-Carp-1.26-244.amzn2.noarch                            16/71
  Installing : 4:perl-libs-5.16.3-299.amzn2.0.1.x86_64                    17/71
  Installing : perl-Time-Local-1.2300-2.amzn2.noarch                      18/71
  Installing : perl-constant-1.27-2.amzn2.0.1.noarch                      19/71
  Installing : perl-PathTools-3.40-5.amzn2.0.2.x86_64                     20/71
  Installing : perl-Scalar-List-Utils-1.27-248.amzn2.0.2.x86_64           21/71
  Installing : perl-threads-shared-1.43-6.amzn2.0.2.x86_64                22/71
  Installing : perl-threads-1.87-4.amzn2.0.2.x86_64                       23/71
  Installing : 4:perl-Time-HiRes-1.9725-3.amzn2.0.2.x86_64                24/71
  Installing : 2:shadow-utils-4.1.5.1-24.amzn2.0.2.x86_64                 41/71
  Installing : libutempter-1.1.6-4.amzn2.0.2.x86_64                       42/71
  Installing : pcre2-10.23-2.amzn2.0.2.x86_64                             43/71
  Installing : libsmartcols-2.30.2-2.amzn2.0.4.x86_64                     44/71
  Installing : qrencode-libs-3.4.1-3.amzn2.0.2.x86_64                     45/71
  Installing : acl-2.2.51-14.amzn2.x86_64                                 46/71
  Installing : 1:emacs-filesystem-27.2-4.amzn2.0.1.noarch                 47/71
  Installing : libfdisk-2.30.2-2.amzn2.0.4.x86_64                         48/71
  Installing : libedit-3.0-12.20121213cvs.amzn2.0.2.x86_64                49/71
  Installing : gzip-1.5-10.amzn2.x86_64                                   50/71
  Installing : cracklib-2.9.0-11.amzn2.0.2.x86_64                         51/71
  Installing : cracklib-dicts-2.9.0-11.amzn2.0.2.x86_64                   52/71
  Installing : pam-1.1.8-23.amzn2.0.1.x86_64                              53/71
  Installing : libpwquality-1.2.3-5.amzn2.x86_64                          54/71
  Installing : util-linux-2.30.2-2.amzn2.0.4.x86_64                       55/71
  Installing : 7:device-mapper-1.02.146-4.amzn2.0.2.x86_64                56/71
  Installing : 7:device-mapper-libs-1.02.146-4.amzn2.0.2.x86_64           57/71
  Installing : cryptsetup-libs-1.7.4-4.amzn2.x86_64                       58/71
  Installing : elfutils-libs-0.176-2.amzn2.x86_64                         59/71
  Installing : systemd-libs-219-78.amzn2.0.14.x86_64                      60/71
  Installing : 1:dbus-libs-1.10.24-7.amzn2.x86_64                         61/71
  Installing : systemd-219-78.amzn2.0.14.x86_64                           62/71
Failed to get D-Bus connection: Operation not permitted
  Installing : elfutils-default-yama-scope-0.176-2.amzn2.noarch           63/71
  Installing : 1:dbus-1.10.24-7.amzn2.x86_64                              64/71
  Installing : openssh-7.4p1-21.amzn2.0.3.x86_64                          65/71
  Installing : openssh-clients-7.4p1-21.amzn2.0.3.x86_64                  66/71
  Installing : git-core-2.32.0-1.amzn2.0.1.x86_64                         67/71
  Installing : git-core-doc-2.32.0-1.amzn2.0.1.noarch                     68/71
  Installing : perl-Git-2.32.0-1.amzn2.0.1.noarch                         69/71
  Installing : git-2.32.0-1.amzn2.0.1.x86_64                              70/71
  Installing : unzip-6.0-43.amzn2.x86_64                                  71/71
  Verifying  : perl-Exporter-5.68-3.amzn2.noarch                           1/71
  Verifying  : 4:perl-5.16.3-299.amzn2.0.1.x86_64                          2/71
  Verifying  : perl-Filter-1.49-3.amzn2.0.2.x86_64                         3/71
  Verifying  : perl-Time-Local-1.2300-2.amzn2.noarch                       4/71
  Verifying  : gzip-1.5-10.amzn2.x86_64                                    5/71
  Verifying  : elfutils-default-yama-scope-0.176-2.amzn2.noarch            6/71
  Verifying  : openssh-7.4p1-21.amzn2.0.3.x86_64                           7/71
  Verifying  : 4:perl-macros-5.16.3-299.amzn2.0.1.x86_64                   8/71
  Verifying  : perl-Pod-Usage-1.63-3.amzn2.noarch                          9/71
  Verifying  : perl-Carp-1.26-244.amzn2.noarch                            10/71
  Verifying  : cracklib-2.9.0-11.amzn2.0.2.x86_64                         11/71
  Verifying  : 1:dbus-libs-1.10.24-7.amzn2.x86_64                         12/71
  Verifying  : 7:device-mapper-libs-1.02.146-4.amzn2.0.2.x86_64           13/71
  Verifying  : perl-PathTools-3.40-5.amzn2.0.2.x86_64                     14/71
  Verifying  : libsemanage-2.5-11.amzn2.x86_64                            15/71
  Verifying  : perl-HTTP-Tiny-0.033-3.amzn2.noarch                        16/71
  Verifying  : cryptsetup-libs-1.7.4-4.amzn2.x86_64                       17/71
  Verifying  : 4:perl-libs-5.16.3-299.amzn2.0.1.x86_64                    18/71
  Verifying  : libedit-3.0-12.20121213cvs.amzn2.0.2.x86_64                19/71
  Verifying  : libfdisk-2.30.2-2.amzn2.0.4.x86_64                         20/71
  Verifying  : perl-threads-shared-1.43-6.amzn2.0.2.x86_64                21/71
  Verifying  : 1:emacs-filesystem-27.2-4.amzn2.0.1.noarch                 22/71
  Verifying  : unzip-6.0-43.amzn2.x86_64                                  23/71
  Verifying  : acl-2.2.51-14.amzn2.x86_64                                 24/71
  Verifying  : libutempter-1.1.6-4.amzn2.0.2.x86_64                       25/71
  Verifying  : lz4-1.7.5-2.amzn2.0.1.x86_64                               26/71
  Verifying  : qrencode-libs-3.4.1-3.amzn2.0.2.x86_64                     27/71
  Verifying  : perl-constant-1.27-2.amzn2.0.1.noarch                      28/71
  Verifying  : 1:perl-Pod-Simple-3.28-4.amzn2.noarch                      29/71
  Verifying  : systemd-219-78.amzn2.0.14.x86_64                           30/71
  Verifying  : git-core-2.32.0-1.amzn2.0.1.x86_64                         31/71
  Verifying  : libsmartcols-2.30.2-2.amzn2.0.4.x86_64                     32/71
  Verifying  : perl-Scalar-List-Utils-1.27-248.amzn2.0.2.x86_64           33/71
  Verifying  : fipscheck-1.4.1-6.amzn2.0.2.x86_64                         34/71
  Verifying  : perl-threads-1.87-4.amzn2.0.2.x86_64                       35/71
  Verifying  : perl-podlators-2.5.1-3.amzn2.0.1.noarch                    36/71
  Verifying  : kmod-libs-25-3.amzn2.0.2.x86_64                            71/71

Installed:
  git.x86_64 0:2.32.0-1.amzn2.0.1          unzip.x86_64 0:6.0-43.amzn2

Dependency Installed:
  acl.x86_64 0:2.2.51-14.amzn2
  audit-libs.x86_64 0:2.8.1-3.amzn2.1
  cracklib.x86_64 0:2.9.0-11.amzn2.0.2
  cracklib-dicts.x86_64 0:2.9.0-11.amzn2.0.2
  cryptsetup-libs.x86_64 0:1.7.4-4.amzn2
  dbus.x86_64 1:1.10.24-7.amzn2
  dbus-libs.x86_64 1:1.10.24-7.amzn2
  device-mapper.x86_64 7:1.02.146-4.amzn2.0.2
  device-mapper-libs.x86_64 7:1.02.146-4.amzn2.0.2
  elfutils-default-yama-scope.noarch 0:0.176-2.amzn2
  elfutils-libs.x86_64 0:0.176-2.amzn2
  emacs-filesystem.noarch 1:27.2-4.amzn2.0.1
  fipscheck.x86_64 0:1.4.1-6.amzn2.0.2
  fipscheck-lib.x86_64 0:1.4.1-6.amzn2.0.2
  git-core.x86_64 0:2.32.0-1.amzn2.0.1
  git-core-doc.noarch 0:2.32.0-1.amzn2.0.1
  groff-base.x86_64 0:1.22.2-8.amzn2.0.2
  gzip.x86_64 0:1.5-10.amzn2
  kmod.x86_64 0:25-3.amzn2.0.2
  kmod-libs.x86_64 0:25-3.amzn2.0.2
  libfdisk.x86_64 0:2.30.2-2.amzn2.0.4
  libpwquality.x86_64 0:1.2.3-5.amzn2
  libsemanage.x86_64 0:2.5-11.amzn2
  libsmartcols.x86_64 0:2.30.2-2.amzn2.0.4
  libutempter.x86_64 0:1.1.6-4.amzn2.0.2
  lz4.x86_64 0:1.7.5-2.amzn2.0.1
  openssh.x86_64 0:7.4p1-21.amzn2.0.3
  openssh-clients.x86_64 0:7.4p1-21.amzn2.0.3
  pam.x86_64 0:1.1.8-23.amzn2.0.1
  pcre2.x86_64 0:10.23-2.amzn2.0.2
  perl.x86_64 4:5.16.3-299.amzn2.0.1
  perl-Carp.noarch 0:1.26-244.amzn2
  perl-Encode.x86_64 0:2.51-7.amzn2.0.2
  perl-Error.noarch 1:0.17020-2.amzn2
  perl-Exporter.noarch 0:5.68-3.amzn2
  perl-File-Path.noarch 0:2.09-2.amzn2
  perl-File-Temp.noarch 0:0.23.01-3.amzn2
  perl-Filter.x86_64 0:1.49-3.amzn2.0.2
  perl-Getopt-Long.noarch 0:2.40-3.amzn2
  perl-Git.noarch 0:2.32.0-1.amzn2.0.1
  perl-HTTP-Tiny.noarch 0:0.033-3.amzn2
  perl-PathTools.x86_64 0:3.40-5.amzn2.0.2
  perl-Pod-Escapes.noarch 1:1.04-299.amzn2.0.1
  perl-Pod-Perldoc.noarch 0:3.20-4.amzn2
  perl-Pod-Simple.noarch 1:3.28-4.amzn2
  perl-Pod-Usage.noarch 0:1.63-3.amzn2
  perl-Scalar-List-Utils.x86_64 0:1.27-248.amzn2.0.2
  perl-Socket.x86_64 0:2.010-4.amzn2.0.2
  perl-Storable.x86_64 0:2.45-3.amzn2.0.2
  perl-TermReadKey.x86_64 0:2.30-20.amzn2.0.2
  perl-Text-ParseWords.noarch 0:3.29-4.amzn2
  perl-Time-HiRes.x86_64 4:1.9725-3.amzn2.0.2
  perl-Time-Local.noarch 0:1.2300-2.amzn2
  perl-constant.noarch 0:1.27-2.amzn2.0.1
  perl-libs.x86_64 4:5.16.3-299.amzn2.0.1
  perl-macros.x86_64 4:5.16.3-299.amzn2.0.1
  perl-parent.noarch 1:0.225-244.amzn2.0.1
  perl-podlators.noarch 0:2.5.1-3.amzn2.0.1
  perl-threads.x86_64 0:1.87-4.amzn2.0.2
  perl-threads-shared.x86_64 0:1.43-6.amzn2.0.2
  qrencode-libs.x86_64 0:3.4.1-3.amzn2.0.2
  shadow-utils.x86_64 2:4.1.5.1-24.amzn2.0.2
  systemd.x86_64 0:219-78.amzn2.0.14
  systemd-libs.x86_64 0:219-78.amzn2.0.14
  ustr.x86_64 0:1.0.4-16.amzn2.0.3
  util-linux.x86_64 0:2.30.2-2.amzn2.0.4

Complete!
====>> Check out tfenv into ~/.tfenv
  #!/bin/bash -eo pipefail
git clone https://github.com/tfutils/tfenv.git ~/.tfenv

Cloning into '/root/.tfenv'...
remote: Enumerating objects: 1559, done.
remote: Counting objects: 100% (374/374), done.
remote: Compressing objects: 100% (147/147), done.
remote: Total 1559 (delta 233), reused 334 (delta 213), pack-reused 1185
Receiving objects: 100% (1559/1559), 336.56 KiB | 14.63 MiB/s, done.
Resolving deltas: 100% (996/996), done.
====>> Make symlinks for tfenv/bin/* scripts into a path that is already added to your $PATH
  #!/bin/bash -eo pipefail
ln -s ~/.tfenv/bin/* /usr/bin

====>> Install terraform & Show Version
  #!/bin/bash -eo pipefail
VERSION="1.0.5"
tfenv install ${VERSION}
tfenv use ${VERSION}
terraform --version

Installing Terraform v1.0.5
Downloading release tarball from https://releases.hashicorp.com/terraform/1.0.5/terraform_1.0.5_linux_amd64.zip
######################################################################## 100.0%
Downloading SHA hash file from https://releases.hashicorp.com/terraform/1.0.5/terraform_1.0.5_SHA256SUMS
No keybase install found, skipping OpenPGP signature verification
terraform_1.0.5_linux_amd64.zip: OK
Archive:  /tmp/tfenv_download.MKlqyq/terraform_1.0.5_linux_amd64.zip
  inflating: /root/.tfenv/versions/1.0.5/terraform
Installation of terraform v1.0.5 successful. To make this your default version, run 'tfenv use 1.0.5'
Switching default version to v1.0.5
Switching completed
Terraform v1.0.5
on linux_amd64
Success!

自分個人の Orb としては初のパブリックリポジトリにしているので、 issue 等あればお知らせください。
TwitterにでもOKです。
https://twitter.com/sogaoh

補足:"70分"の記録

ジャスト 0:00 に思いついて・・・
https://twitter.com/sogaoh/status/1430907957231841295

1:10 にリポジトリを公開してました。
https://twitter.com/sogaoh/status/1430925621765443588

作成過程

0. 参考情報

シンプルな↓を参考にしました

それと、見本にしたのが↓

その他、↓あたりも参照したメモがありました

公式の開発キットもあるようですが使いこなせませんでした(6月)

https://circleci.com/docs/ja/2.0/orb-author/#orb-開発キット
https://circleci.com/docs/ja/2.0/creating-orbs/

1. create orb

実は namespace は以前に作ってました

https://circleci.com/developer/orbs/orb/sogaoh/orb-ecschedule

なので、 circleci orb create sogaoh/orb-tfenv だけしました。

2. orb.yml 編集

リポジトリを README.md だけで作成して、

https://github.com/sogaoh/orb-tfenv

orb.yml を編集し、circleci orb validate orb.yml でチェック、という流れで作りました。

3. とりあえず publish

circleci orb publish orb.yml sogaoh/orb-tfenv@0.0.1 でシンタックスエラーなければ pushlish 完了

4. ローカルで動作チェック

.circleci/config.yml を調整したうえで
リポジトリのルートディレクトリで

circleci config validate

で問題なければ以下を実行

circleci local execute --job tftest \
  -e AWS_ACCESS_KEY_ID="XXXXXXXXXXXXXXXXXXXX" \
  -e AWS_SECRET_ACCESS_KEY="XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" \
  -e AWS_DEFAULT_REGION="ap-northeast-1" \
  -e AWS_ACCOUNT_ID="123456789012" \
  -e SLACK_ENDPOINT="https://hooks.slack.com/services/XXXXXXXXX/YYYYYYYYYYY/ZZZZZZZZZZZZZZZZZZZZZZZZ"

結果が良くない感じだったら 2. に戻る、良かったら完成、です

Discussion