LoginSignup
2
1

More than 3 years have passed since last update.

【Terraform】S3が存在しているのに、terraform initがエラー出る問題

Last updated at Posted at 2020-02-28

コード

resource "aws_ecr_repository" “XXXXimage" {
    name = “XXXXmage"
}
terraform {
  backend "s3" {
    bucket = "ston-terraform-container"
    key    = “XXXXXterraform/ecr/terraform.tfstate"
    region = "ap-northeast-1"
  }
}

provider "aws" {
    region = "ap-northeast-1" 
}

エラー

Error inspecting states in the "s3" backend:

S3 bucket does not exist.
The referenced S3 bucket must have been previously created. If the S3 bucket
was created within the last minute, please wait for a minute or two and try
again.
Error: NoSuchBucket: The specified bucket does not exist
status code: 404, request id: xxxxxxxxxhost id: xxxxxxxxxxxxxx

結論

失敗した際のXXXX.tfstateファイルが残っていると、差分が起きてしまうらしいので、ファイルを削除して、再度initコマンドで解決しました!

詳細はわかっていないので、わかり次第追記します!

参考記事

StackOverFlow-Error inspecting states in the “s3” backend: NoSuchBucket: The specified bucket does not exist

2
1
1

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
2
1