locals {
  environment      = "${get_env("ENV_NAME") == "production-eu" ? "production" : get_env("ENV_NAME")}"
  region           = "${get_env("ENV_NAME") == "production-eu" ? "eu-west-1" : "us-east-1"}"
}

generate "data" {
  path      = "data.tf"
  if_exists = "overwrite_terragrunt"
  contents  = <<EOF

data "terraform_remote_state" "api-gw" {
  backend = "s3"
  config = {
    bucket         = "p81-devops-terraform-states"
    dynamodb_table = "devops-us-terraform-tfstate-lock"
    encrypt        = true
    key            = "sdpv2/infra/sdpv2-agent-apigw-rest/${local.environment}/${local.region}/terraform.tfstate"
    region         = "${local.region}"
  }
}

output "exec-id" {
  value = data.terraform_remote_state.api-gw.outputs.apigateway_api_id
}

EOF
}
