resource "aws_dynamodb_global_table" "myTable" {

  depends_on = [
    aws_dynamodb_table.ap_northeast_2,
    aws_dynamodb_table.us_east_1,
  ]

  provider = aws.seoul
  name     = "order"

  replica {
    region_name = "ap-northeast-2"
  }

  replica {
    region_name = "us-east-1"
  }
}

resource "aws_dynamodb_table" "us_east_1" {
  provider = aws.usa
  billing_mode   = "PAY_PER_REQUEST"
  hash_key         = "id"
  name             = "order"
  stream_enabled   = true
  stream_view_type = "NEW_AND_OLD_IMAGES"

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

resource "aws_dynamodb_table" "ap_northeast_2" {
  provider = aws.seoul
  billing_mode   = "PAY_PER_REQUEST"
  hash_key         = "id"
  name             = "order"
  stream_enabled   = true
  stream_view_type = "NEW_AND_OLD_IMAGES"

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