variable "service_name" {
}

variable "environment" {
}

provider "aws" {
  region = "us-east-1"
}

module "rs_sftp" {
  source = "../modules/sftp"

  environment       = var.environment
  service_name      = var.service_name
  aws_key_name      = "orchard_admin"
  aws_instance_type = "t3.small"
  user_data         = module.chef_bootstrap_rs_sftp.user_data_output
  vpc_id            = "vpc-34dbfd51"
  bucket_name       = "dev-orchard-elb-logs"
  elb_vpc_subnet_ids = [
    "subnet-2ff85972",
    "subnet-9ee89ffa",
  ]
  aws_elb_access_ips = [
    "192.168.32.0/24",
    "192.168.33.0/24",
    "192.168.40.0/22",
    "10.30.0.0/22",
    "10.141.0.0/29",
  ]
  aws_route53_params = {
    zone_id = "Z21XEY26C989RH"
  }
  asg_vpc_subnet_ids = [
    "subnet-b649dfef",
    "subnet-44c19a21",
  ]
}

module "chef_bootstrap_rs_sftp" {
  source = "git@github.com:theorchard/terraform-chef-bootstrap.git"

  chef_version      = "14.3.37"
  chef_server       = "dev-chef01.theorchard.local"
  chef_server_url   = "https://dev-chef01.theorchard.local/organizations/orchard"
  s3_chef_bucket    = "chef-validator-keys"
  chef_environment  = "_default"
  chef_role         = "${var.environment}_aws_rs_sftp"
  log_file          = "/var/log/chef/bootstrap.log"
  aws_instance_name = "${var.environment}-${var.service_name}"
  aws_iam_role_id   = module.rs_sftp.aws_iam_role_id_output
  aws_asg_name      = module.rs_sftp.aws_asg_name_output
}

output "route53_record" {
  value = module.rs_sftp.aws_route53_record_output
}

