Priyadharshini
Priyadharshini

Reputation: 1

Error message: operation error DynamoDB: PutItem, https response error │ StatusCode: 400

I'm using AWS S3 and dynamodb to maintain state file in remote backend , i keep getting the following after moving state file to remote backend using terraform .. Any idea how to resolve this?
Error: Error acquiring the state lock │ │ Error message: operation error DynamoDB: PutItem, https response error │ StatusCode: 400, RequestID: │ │ ConditionalCheckFailedException: The conditional request failed

resource "aws_dynamodb_table" "" {
  name         = var.table_name
  billing_mode = "PAY_PER_REQUEST"
  hash_key     = "LockID"

  attribute {
    name = "LockID"
    type = "S"
 }

Upvotes: 0

Views: 696

Answers (1)

Leeroy Hannigan
Leeroy Hannigan

Reputation: 19653

ConditionalCheckFailedException is caused by the condition that you set in your PutItem evaluated to false. It's not an error per-se, but more so an indication on the result of the condition:

https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.ConditionExpressions.html

Understand what condition you're setting, and that'll allow you to understand why it's failing. You can return the item as it's stored in DynamoDB by using ReturnValuesOnConditionCheckFailedException:

https://aws.amazon.com/blogs/database/handle-conditional-write-errors-in-high-concurrency-scenarios-with-amazon-dynamodb/

Upvotes: 0

Related Questions