Skip to content

Cellar as TF backend, init ok but Unknown error Error: Failed to save state on PUT #340

Description

@MathFrenchToast

Description

My setup is simple:
a cellar an dbucket to store my tfstate
then addon and app creation

Steps to Reproduce

  1. [Step 1] create a backend
provider "clevercloud" {
  organisation = var.clever_org_id #add your own
}

resource "clevercloud_cellar" "tf_backend" {
  name   = "test_cc_backend"
  region = var.region
}

resource "clevercloud_cellar_bucket" "backend_bucket" {
     cellar_id = clevercloud_cellar.tf_backend.id
     id       = "test_cc_backend_bucket"     
}

terraform {
  required_providers {
    clevercloud = {
      source = "CleverCloud/clevercloud"
      version = ">= 1.9.0"
    }
  }
}

connect with the cli:

clever login
export ORGA_ID=yout orga id
export CLEVER_TOKEN=from the previous login
export CLEVER_SECRET=from the previous login

then

terraform init
terraform apply

this should create the cellar and the bucket

  1. [Step 2]

Try to use this backend with:
set
AWS_ACCESS_KEY_ID=your cellar key id
AWS_SECRET_ACCESS_KEY=your cellar access key

terraform {
  required_providers {
    clevercloud = {
      source = "CleverCloud/clevercloud"
      version = ">= 1.9.0" 
    }
  }

  # Backend S3 configuration
  backend "s3" {
    bucket                      = "test_cc_backend_bucket"
    key                         = "infra-cc-test.tfstate"
    region                      = "us-east-1"
    endpoints = {
      s3 = "https://cellar-c2.services.clever-cloud.com"
    }

    # Options de compatibilité S3/Ceph
    skip_s3_checksum            = true  
    use_path_style              = true      
    skip_region_validation      = true
    skip_credentials_validation = true
    skip_metadata_api_check     = true
    skip_requesting_account_id  = true
  }
}

and try to create any ressource
with

terraform init
terraform apply

Expected Behavior

terraform apply should not fails on state PUSH

Actual Behavior

on terraform apply
after ressource creation or modification, error

.... ressources creation ok ...

│ Error: Failed to save state
│ 
│ Error saving state: failed to upload state: operation error S3: PutObject, https response error StatusCode: 400, RequestID: tx000001c276c2acfbfa3f5-00697b4382-3bae0cb2-default, HostID:
│ 3bae0cb2-default-default, api error XAmzContentSHA256Mismatch: UnknownError
│ Error: Failed to persist state to backend 

Environment

  • OS: Ubuntu 24 on amd64
  • tf version: v1.14.4

Additional Information

trying to push it manually
using aws cli:
aws s3 cp errored.tfstate ...
gives: argument of type 'NoneType' is not iterable

idem with "aws s3api put-object ..."
I managed to push my state with "s3cmd",

after this push terraform plan says ok.
So READ is OK but not PUT on the S3

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions