0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

今日からteraform

Last updated at Posted at 2025-08-11

環境

Centos8

以下の手順書に沿って

まずはいつものエラー

root@docker163 ~]# sudo yum install -y yum-utils
CentOS Stream 8 - Extras common packages                                                                                     0.0  B/s |   0  B     00:00
Errors during downloading metadata for repository 'extras-common':
  - Curl error (6): Couldn't resolve host name for http://mirrorlist.centos.org/?release=8-stream&arch=x86_64&repo=extras-extras-common [Could not resolve host: mirrorlist.centos.org]
エラー: repo 'extras-common' のメタデータのダウンロードに失敗しました : Cannot prepare internal mirrorlist: Curl error (6): Couldn't resolve host name for http://mirrorlist.centos.org/?release=8-stream&arch=x86_64&repo=extras-extras-common [Could not resolve host: mirrorlist.centos.org]

以下のサイトを参考に対応

無事にインストール完了しました。皆様ありがとうございます。

[root@docker163 ~]# sudo yum install -y yum-utils
CentOS Stream 8 - AppStream                                                                                                   13 kB/s | 4.4 kB     00:00
CentOS Stream 8 - BaseOS                                                                                                     135 kB/s | 3.9 kB     00:00
CentOS Stream 8 - Extras                                                                                                      95 kB/s | 2.9 kB     00:00
CentOS Stream 8 - Extras common packages                                                                                     126 kB/s | 8.0 kB     00:00
Extra Packages for Enterprise Linux 8 - x86_64                                                                                13 kB/s |  12 kB     00:00
Extra Packages for Enterprise Linux 8 - x86_64                                                                                11 MB/s |  14 MB     00:01
依存関係が解決しました。
=============================================================================================================================================================
 パッケージ                            アーキテクチャー                   バージョン                                リポジトリー                       サイズ
=============================================================================================================================================================
インストール:
 yum-utils                             noarch                             4.0.21-25.el8                             baseos                              80 k

トランザクションの概要
=============================================================================================================================================================
インストール  1 パッケージ

ダウンロードサイズの合計: 80 k
インストール後のサイズ: 23 k
パッケージのダウンロード:
yum-utils-4.0.21-25.el8.noarch.rpm                                                                                           1.8 MB/s |  80 kB     00:00
-------------------------------------------------------------------------------------------------------------------------------------------------------------
合計                                                                                                                         1.8 MB/s |  80 kB     00:00
トランザクションを確認しています
トランザクションの確認に成功しました。
トランザクションをテストしています
トランザクションのテストに成功しました。
トランザクションを実行しています
  準備中           :                                                                                                                                     1/1
  インストール中   : yum-utils-4.0.21-25.el8.noarch                                                                                                      1/1
  scriptletの実行中: yum-utils-4.0.21-25.el8.noarch                                                                                                      1/1
  検証中           : yum-utils-4.0.21-25.el8.noarch                                                                                                      1/1

インストール済み:
  yum-utils-4.0.21-25.el8.noarch

完了しました!
[root@docker163 ~]# sudo yum-config-manager --add-repo https://rpm.releases.hashicorp.com/RHEL/hashicorp.repo
repo の追加: https://rpm.releases.hashicorp.com/RHEL/hashicorp.repo
[root@docker163 ~]#
[root@docker163 ~]#
[root@docker163 ~]# sudo yum -y install terraform
Hashicorp Stable - x86_64                                                                                                     12 MB/s | 1.9 MB     00:00
依存関係が解決しました。
=============================================================================================================================================================
 パッケージ                                アーキテクチャー                バージョン                               リポジトリー                       サイズ
=============================================================================================================================================================
インストール:
 terraform                                 x86_64                          1.12.2-1                                 hashicorp                           28 M
依存関係のインストール:
 emacs-filesystem                          noarch                          1:26.1-11.el8                            baseos                              70 k
 git                                       x86_64                          2.43.0-1.el8                             appstream                           92 k
 git-core-doc                              noarch                          2.43.0-1.el8                             appstream                          3.3 M
 perl-Error                                noarch                          1:0.17025-2.el8                          appstream                           46 k
 perl-Git                                  noarch                          2.43.0-1.el8                             appstream                           79 k

トランザクションの概要
=============================================================================================================================================================
インストール  6 パッケージ

ダウンロードサイズの合計: 32 M
インストール後のサイズ: 103 M
パッケージのダウンロード:
(1/6): git-2.43.0-1.el8.x86_64.rpm                                                                                           185 kB/s |  92 kB     00:00
(2/6): perl-Error-0.17025-2.el8.noarch.rpm                                                                                    92 kB/s |  46 kB     00:00
(3/6): emacs-filesystem-26.1-11.el8.noarch.rpm                                                                               4.3 MB/s |  70 kB     00:00
(4/6): perl-Git-2.43.0-1.el8.noarch.rpm                                                                                      2.0 MB/s |  79 kB     00:00
(5/6): git-core-doc-2.43.0-1.el8.noarch.rpm                                                                                  5.9 MB/s | 3.3 MB     00:00
(6/6): terraform-1.12.2-1.x86_64.rpm                                                                                          19 MB/s |  28 MB     00:01
-------------------------------------------------------------------------------------------------------------------------------------------------------------
合計                                                                                                                          15 MB/s |  32 MB     00:02
Hashicorp Stable - x86_64                                                                                                     69 kB/s | 3.9 kB     00:00
GPG 鍵 0xA621E701 をインポート中:
 Userid     : "HashiCorp Security (HashiCorp Package Signing) <security+packaging@hashicorp.com>"
 Fingerprint: 798A EC65 4E5C 1542 8C8E 42EE AA16 FCBC A621 E701
 From       : https://rpm.releases.hashicorp.com/gpg
鍵のインポートに成功しました
トランザクションを確認しています
トランザクションの確認に成功しました。
トランザクションをテストしています
トランザクションのテストに成功しました。
トランザクションを実行しています
  準備中           :                                                                                                                                     1/1
  インストール中   : emacs-filesystem-1:26.1-11.el8.noarch                                                                                               1/6
  インストール中   : perl-Error-1:0.17025-2.el8.noarch                                                                                                   2/6
  インストール中   : git-core-doc-2.43.0-1.el8.noarch                                                                                                    3/6
  インストール中   : perl-Git-2.43.0-1.el8.noarch                                                                                                        4/6
  インストール中   : git-2.43.0-1.el8.x86_64                                                                                                             5/6
  インストール中   : terraform-1.12.2-1.x86_64                                                                                                           6/6
  scriptletの実行中: terraform-1.12.2-1.x86_64                                                                                                           6/6
  検証中           : git-2.43.0-1.el8.x86_64                                                                                                             1/6
  検証中           : git-core-doc-2.43.0-1.el8.noarch                                                                                                    2/6
  検証中           : perl-Error-1:0.17025-2.el8.noarch                                                                                                   3/6
  検証中           : perl-Git-2.43.0-1.el8.noarch                                                                                                        4/6
  検証中           : emacs-filesystem-1:26.1-11.el8.noarch                                                                                               5/6
  検証中           : terraform-1.12.2-1.x86_64                                                                                                           6/6

インストール済み:
  emacs-filesystem-1:26.1-11.el8.noarch       git-2.43.0-1.el8.x86_64         git-core-doc-2.43.0-1.el8.noarch       perl-Error-1:0.17025-2.el8.noarch
  perl-Git-2.43.0-1.el8.noarch                terraform-1.12.2-1.x86_64

完了しました!
[root@docker163 ~]#

aws cliも必要なので(よく仕組みをわかっていない。本を買わねば)

aws cliを以下手順を参考にインストール

aws configure
aws sts get-caller-identity
aws s3 ls
pwd
/root/vpc-handson
vi main.tf

[root@docker163 vpc-handson]# cat main.tf
provider "aws" {
  region = "ap-northeast-1"
}

resource "aws_vpc" "main" {
  cidr_block = "192.168.8.0/24"

  tags = {
    Name = "vpc-handson"
  }
}


#初回だけ?
terraform init
#文法チェック?
terraform plan
#適用
#terraform apply
0
1
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
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?