0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Terraformの環境をセットアップしてみた

Posted at

背景・目的

以前、TerraformでS3を作成してみたでは、AWS Cloud Shell からTerraform環境を構築しましたが、今回は、Mac環境で、AWS CLI + SSOのセットアップメモで設定したSSOを交えてセットアップします。

実践

anyenvのセットアップ

  1. 下記のコマンドでanyenvをインストールします

    $ brew install anyenv
    
  2. initを実行します

    $ anyenv init
    # Load anyenv automatically by adding
    # the following to ~/.zshrc:
    
    eval "$(anyenv init -)"
    
    echo 'eval "$(anyenv init -)"' >> ~/.zshrc    
    $ cat ~/.zshrc                              
    eval "$(anyenv init -)"
    $
    
  3. シェルを再起動します

    $ exec $SHELL -l
    
  4. 複数環境をインストールするためにinitします

    $ anyenv install --init
    Manifest directory doesn't exist: /Users/XXXX/.config/anyenv/anyenv-install
    Do you want to checkout https://github.com/anyenv/anyenv-install.git? [y/N]: y
    Cloning https://github.com/anyenv/anyenv-install.git master to /Users/XXXXX/.config/anyenv/anyenv-install...
    Cloning into '/Users/XXXX/.config/anyenv/anyenv-install'...
    remote: Enumerating objects: 71, done.
    remote: Counting objects: 100% (14/14), done.
    remote: Compressing objects: 100% (13/13), done.
    remote: Total 71 (delta 4), reused 4 (delta 1), pack-reused 57
    Receiving objects: 100% (71/71), 13.15 KiB | 2.63 MiB/s, done.
    Resolving deltas: 100% (11/11), done.
    
    Completed!
    $
    

tfenvのセットアップ

  1. anyenvを介して、tfenvをインストールします
    $ anyenv install tfenv
    /var/folders/0q/XXXXXXXXX/T/tfenv.20240424224350.2727 ~
    Cloning https://github.com/tfutils/tfenv.git master to tfenv...
    Cloning into 'tfenv'...
    remote: Enumerating objects: 2057, done.
    remote: Counting objects: 100% (662/662), done.
    remote: Compressing objects: 100% (207/207), done.
    remote: Total 2057 (delta 517), reused 522 (delta 446), pack-reused 1395
    Receiving objects: 100% (2057/2057), 437.19 KiB | 2.16 MiB/s, done.
    Resolving deltas: 100% (1321/1321), done.
    ~
    
    Install tfenv succeeded!
    Please reload your profile (exec $SHELL -l) or open a new session.
    $
    

Terraformのインストール

  1. tfenvから、目当てのバージョンをインストールします

    $ tfenv install 1.8.0
    Installing Terraform v1.8.0
    Downloading release tarball from https://releases.hashicorp.com/terraform/1.8.0/terraform_1.8.0_darwin_amd64.zip
    ######################################################################################################################################################################################################################################################### 100.0%
    Downloading SHA hash file from https://releases.hashicorp.com/terraform/1.8.0/terraform_1.8.0_SHA256SUMS
    Not instructed to use Local PGP (/Users/XXXXX/.anyenv/envs/tfenv/use-{gpgv,gnupg}) & No keybase install found, skipping OpenPGP signature verification
    Archive:  /var/folders/0q/3t1v6lb91qj08tz8t9sqyp5m0000gn/T/tfenv_download.XXXXXX.STCIXa7XKb/terraform_1.8.0_darwin_amd64.zip
      inflating: /Users/XXXXX/.anyenv/envs/tfenv/versions/1.8.0/terraform  
    Installation of terraform v1.8.0 successful. To make this your default version, run 'tfenv use 1.8.0'
    $ 
    
  2. anyenv からも確認してみます

    $ anyenv versions    
    tfenv:
      1.8.0
    No default set. Set with 'tfenv use <version>'
    $
    
  3. バージョンを選択します

    $ tfenv use 1.8.0
    Switching default version to v1.8.0
    Default version (when not overridden by .terraform-version or TFENV_TERRAFORM_VERSION) is now: 1.8.0
    $
    
  4. バージョンを確認します

    $ terraform -version
    Terraform v1.8.0
    on darwin_amd64
    
    Your version of Terraform is out of date! The latest version
    is 1.8.2. You can update by downloading from https://www.terraform.io/downloads.html
    $ 
    

考察

今回は、Terraformをtfenvとanyenvを介してインストールしました。

参考

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?