provider "aws" {
  region = "${var.region}"
}

# Terraform backends cannot contain interpolations
terraform {
  backend "s3" {
    bucket         = "orcd-terraform-state"
    key            = "qa/lambda-looker/terraform.tfstate"
    region         = "us-east-1"
    encrypt        = "true"
  }
}

module "gfk_lambda" {
  source = "git@github.com:theorchard/terraform-lambda.git"

  environment                  = "${var.environment}"
  lambda_name                  = "looker-gfk"
  lambda_function_package_path = "lambda.zip"
  lambda_function_timeout      = "100"
  lambda_description           = "Post-processing and delivery of the files, uploaded by Looker for GfK"

  lambda_function_environment_variables = {
    Environment      = "${var.environment}"
    GFK_FTP_HOST     = "${var.gfk_ftp_host}"
    GFK_FTP_PASSWORD = "${var.gfk_ftp_password}"
    GFK_FTP_USERNAME = "${var.gfk_ftp_username}"
    GFK_FTP_PATH     = "${var.gfk_ftp_path}"
  }

  s3_event_enabled                               = true
  lambda_function_reserved_concurrent_executions = "5"
  vpc_security_group_ids                         = "${var.vpc_security_group_ids}"
  vpc_subnet_ids                                 = "${var.vpc_subnet_ids}"
  s3_event_bucket_name                           = "${var.s3_event_bucket_name}"
  s3_event_filter_prefix                         = "${var.s3_event_filter_prefix}"
}
