フラミナル

考え方や調べたことを書き殴ります。IT技術系記事多め

[解決方法]TerraformでtfstateをS3で管理しようとすると「S3 bucket does not exist.」がでる

f:id:lirlia:20200624112925p:plain

Error: 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: xxx, host id: xxx


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.

S3バケットを先に作成しても出る場合は.terraformディレクトリを削除してあげると成功します。