前提・実現したいこと
今回はじめてterraformを利用して開発を行うため、tfstateファイルをS3へアップロードしたいのですが、以下のようなエラーが出てしまいアップロードができません。
どなたかわかる方がいましたら回答をいただけますと幸いです。
※初投稿のため、不足情報等ありましたらご連絡ください。
発生している問題・エラーメッセージ
(base) $ terraform apply Backend reinitialization required. Please run "terraform init". Reason: Initial configuration of the requested backend "s3" The "backend" is the interface that Terraform uses to store state, perform operations, etc. If this message is showing up, it means that the Terraform configuration you're using is using a custom configuration for the Terraform backend. Changes to backend configurations require reinitialization. This allows Terraform to setup the new configuration, copy existing state, etc. This is only done during "terraform init". Please run that command now then try again. If the change reason above is incorrect, please verify your configuration hasn't changed and try again. At this point, no changes to your existing configuration or state have been made. Error: Initialization required. Please see the error message above. (base) $ terraform init Initializing the backend... Error: Error inspecting states in the "s3" backend: AccessDenied: Access Denied status code: 403, request id: aaaaa, host id: bbbbb Prior to changing backends, Terraform inspects the source and destination states to determine what kind of migration steps need to be taken, if any. Terraform failed to load the states. The data in both the source and the destination remain unmodified. Please resolve the above error and try again.
<provider.tf> ※terraformのDSLを記載しているファイル
provider "aws" { version = "~> 2.0" region = "ap-northeast-1" } resource "aws_instance" "sandbox" { count = 1 ami = "ami-785c491f" # Ubuntu 16.04 LTS official ami instance_type = "t2.micro" tags = { Name = "${format("sandbox-%02d", count.index + 1)}" } } terraform { backend "s3" { bucket = "terraform-sample1" key = "terraform.tfstate" region = "ap-northeast-1" } }
補足情報(FW/ツールのバージョンなど)
Terraform v0.12.17
OS:mac
AWS IAMのアクセス権限:AdministratorAccess
awsのアクセスキー、シークレットキーについてはaws CLIの「.aws/credentials」に記載
回答1件
あなたの回答
tips
プレビュー