# Terraform backends cannot contain interpolations
terraform {
  backend "s3" {
    bucket  = "orcd-terraform-state"
    key     = "prod/github/rs-sample-files/terraform.tfstate"
    region  = "us-east-1"
    encrypt = "true"
  }
}

module "github_repository" {
  source = "git@github.com:theorchard/terraform-github.git//?ref=6.0.0"

  repository_name     = var.repository_name
  description         = "Royalty Share sample files repository"
  default_code_owner  = "royaltyshare"
  application_family  = var.application_family
  github_pull_teams   = []
  github_push_teams   = ["mergers", "royaltyshare-eng"]
  github_triage_teams = ["orcharddevs-ro"]
}

resource "github_repository_deploy_key" "staging_deploy_key" {
  title      = "awstaging"
  repository = var.repository_name
  key        = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIF8j4eP/ZU3RIxYvlXNGgkW9wt0FjHNMp4ClBMxLlsfS sample-files-deploy-key"
  read_only  = "true"
  lifecycle {
    ignore_changes = [key]
  }
}

resource "github_repository_deploy_key" "prod_deploy_key" {
  title      = "rpsweb01"
  repository = var.repository_name
  key        = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIH8XWFRzNHXllRMO2pz+NaXhfty/eAq/df79Xk9ecDRg sample-files-deploy-key"
  read_only  = "true"
  lifecycle {
    ignore_changes = [key]
  }
}
