provider "aws" {
  region = var.aws_region
}

terraform {
  backend "s3" {
    bucket  = "qa-songwhip-terraform-state"
    key     = "qa/dynamodb/terraform.state"
    region  = "us-east-1"
    encrypt = "true"
  }
}

data "aws_caller_identity" "current" {}

module "songwhip-api-fan-data-staging" {
  # checkov:skip=ORCD_AWS_2: Live table; terraform-dynamodb bump out of scope for AD-2916 teardown
  source = "git@github.com:theorchard/terraform-dynamodb.git//?ref=2.2.2"

  application_family             = var.application_family
  env                            = var.environment
  hash_key                       = "partitionKey"
  range_key                      = "sortKey"
  range_key_enabled              = true
  server_side_encryption_enabled = true
  table_name                     = "songwhip-api-fan-data-staging"
  use_on_demand                  = true
  use_custom_table_name          = true
  custom_table_name              = "songwhip-api-fan-data-staging"

  attribute = [
    {
      name = "partitionKey"
      type = "S"
    },
    {
      name = "sortKey"
      type = "S"
    }
  ]
}

module "songwhip-release-tasks-staging" {
  # checkov:skip=ORCD_AWS_2: Live table; terraform-dynamodb bump out of scope for AD-2916 teardown
  source = "git@github.com:theorchard/terraform-dynamodb.git//?ref=2.2.2"

  application_family             = var.application_family
  env                            = var.environment
  hash_key                       = "partitionKey"
  range_key                      = "sortKey"
  range_key_enabled              = true
  server_side_encryption_enabled = true
  table_name                     = "songwhip-release-tasks-staging"
  ttl_enabled                    = true
  ttl_attribute_name             = "deleteAt"
  use_on_demand                  = true
  use_custom_table_name          = true
  custom_table_name              = "songwhip-release-tasks-staging"

  attribute = [
    {
      name = "partitionKey"
      type = "S"
    },
    {
      name = "sortKey"
      type = "S"
    }
  ]
}

module "songwhip-queue-staging" {
  source = "git@github.com:theorchard/terraform-dynamodb.git//?ref=3.3.1"

  application_family             = var.application_family
  env                            = var.environment
  hash_key                       = "partitionKey"
  range_key                      = "sortKey"
  range_key_enabled              = true
  server_side_encryption_enabled = true
  table_name                     = "songwhip-queue-staging"
  ttl_enabled                    = true
  ttl_attribute_name             = "deleteAt"
  use_on_demand                  = true
  use_custom_table_name          = true
  custom_table_name              = "songwhip-queue-staging"

  attribute = [
    {
      name = "partitionKey"
      type = "S"
    },
    {
      name = "sortKey"
      type = "N"
    }
  ]
}
