質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.50%
Terraform

Terraformは、インフラ構築のためのツールです。AWS/DigitalOcean/GoogleCloudといった様々なインフラに対応。インフラ構成のコード管理や変更の作業などの手間を自動化し、インフラ構築の効率化を図ることができます。

GitLab

GitLabは Gitoliteをブラウザから管理できるようにする Rubyアプリケーションで、 GitHubのようなサービスをクローズドな環境に独自で構築できるように 公開されたものです。

CI(継続的インテグレーション)

CI(継続的インテグレーション)は、アプリ開発においてビルドとテストを繰り返すことで品質改善と納期短縮を図る手法です。JenkinsやTravis CIなどの専用ツールを利用してプロセスを自動化・半自動化して効率的に実施します。

Q&A

解決済

1回答

2076閲覧

GitLab CI/CDを使ったTerraformの実行時のエラーについて

yami_0613

総合スコア22

Terraform

Terraformは、インフラ構築のためのツールです。AWS/DigitalOcean/GoogleCloudといった様々なインフラに対応。インフラ構成のコード管理や変更の作業などの手間を自動化し、インフラ構築の効率化を図ることができます。

GitLab

GitLabは Gitoliteをブラウザから管理できるようにする Rubyアプリケーションで、 GitHubのようなサービスをクローズドな環境に独自で構築できるように 公開されたものです。

CI(継続的インテグレーション)

CI(継続的インテグレーション)は、アプリ開発においてビルドとテストを繰り返すことで品質改善と納期短縮を図る手法です。JenkinsやTravis CIなどの専用ツールを利用してプロセスを自動化・半自動化して効率的に実施します。

0グッド

0クリップ

投稿2020/12/28 06:47

実現したいこと

GitLab CI/CDを使ったTerraformを実行させたいが下記のエラーが出ております。
解決にご助力ください。

発生している問題・エラーメッセージ

パイプラインで実行した「Terraform plan」のデバッグ全てです。

Running with gitlab-runner 13.7.0 (943fc252) on shell-runner piBzsG8K Preparing the "docker" executor 00:05 Using Docker executor with image hashicorp/terraform:latest ... Pulling docker image hashicorp/terraform:latest ... Using docker image sha256:7de55dfbda43eafac5d7789dd3c2ded5764c217e8369f92b366ff295044e9276 for hashicorp/terraform:latest with digest docker.io/hashicorp/terraform@sha256:7b1e232f564132b949b812ee138249b5398bedf3c6fab42b468d4ec8acf5343c ... Preparing environment 00:01 Running on runner-pibzsg8k-project-2-concurrent-0 via ec-te-53... Getting source from Git repository 00:01 Fetching changes with git depth set to 50... Reinitialized existing Git repository in /builds/root/test/.git/ Checking out 78d5c5b2 as master... Removing .terraform.lock.hcl Removing .terraform/ Skipping Git submodules setup Executing "step_script" stage of the job script 00:01 $ terraform plan Warning: Version constraints inside provider configuration blocks are deprecated on variables.tf line 2, in provider "aws": 2: version = "~> 2.0" Terraform 0.13 and earlier allowed provider version constraints inside the provider configuration block, but that is now deprecated and will be removed in a future version of Terraform. To silence this warning, move the provider version constraint into the required_providers block. Error: Could not load plugin Plugin reinitialization required. Please run "terraform init". Plugins are external binaries that Terraform uses to access and manipulate resources. The configuration provided requires plugins which can't be located, don't satisfy the version constraints, or are otherwise incompatible. Terraform automatically discovers provider requirements from your configuration, including providers used in child modules. To see the requirements and constraints, run "terraform providers". Failed to instantiate provider "registry.terraform.io/hashicorp/aws" to obtain schema: unknown provider "registry.terraform.io/hashicorp/aws" ERROR: Job failed: exit code 1

.gitlab-ci.ymlの中身

image: name: hashicorp/terraform:latest entrypoint: [""] stages: - init - plan stage1: stage: init script: - terraform init stage2: stage: plan script: - terraform plan

環境構築について

下記記事を参考にGitLab emとRunnerをインストールいたしました。
GitLabインストール方法
Runner登録方法

補足情報(FW/ツールのバージョンなど)

terraform --version

Terraform v0.14.3

  • provider registry.terraform.io/hashicorp/aws v2.70.0

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

yami_0613

2021/01/06 02:07

.gitlab-ci.ymlで変数をexportしていない事が原因でした。 自己解決いたしました。
guest

回答1

0

自己解決

.gitlab-ci.ymlで変数をexportしていない事が原因でした。
自己解決いたしました。

投稿2021/01/13 06:56

yami_0613

総合スコア22

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.50%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問