Ошибка при добавлении сертификата SSL - Использование модулей Terraform - PullRequest
0 голосов
/ 06 января 2020

Извините за мой плохой английский sh.

Модуль: terraform- aws -elb Версия: 2.0 Ссылка: https://github.com/terraform-aws-modules/

Я пытаюсь использовать этот модуль, но когда я добавляю ARN из SSL-сертификата, это сообщение показывает мне:

terraform apply myplan 

module.elb_http.module.elb.aws_elb.this: Creating...
Error: Error creating ELB: ValidationError: Secure Listeners need to specify a SSLCertificateId
        status code: 400, request id: id-for-my-request1

  on .terraform/modules/elb_http/terraform-aws-modules-terraform-aws-elb-43e3e76/modules/elb/main.tf line 1, in resource "aws_elb" "this":
   1: resource "aws_elb" "this" {

Для теста я изменил этот файл:

.terraform/modules/elb_http/terraform-aws-modules-terraform-aws-elb-43e3e76/modules/elb/main.tf

И, изменив ssl_certificate_id параметр, lookup (listener.value, "ssl_certificate_id", null) для моего ARN из моего сертификата, модуль ACM и ELB работают нормально.

Если Кто-нибудь прошел через это, спасибо, если вы можете помочь, если это плохая конфигурация с моей стороны, я прошу прощения.


Конфигурации среды

  • Версия Terraform: поставщик Terraform v0.12.18
  • . aws v2.43.0

  • Версия модуля ACM: 2.0

  • Версия модуля ELB_HTTP: 2.0

  • ОС: Ubuntu 19.04

main.tf

provider "aws" {
    region = var.aws_region
}

module "acm" {
  source  = "terraform-aws-modules/acm/aws"
  version = "~> v2.0"

validate_certificate  = false

  domain_name  = "domain.name.example"
  zone_id      = "zone-id"

  subject_alternative_names = [
    "*.example.domain.name",
  ]

  tags = {
    Name = "example.domain.name"
  }
}


module "elb_http" {
  source  = "terraform-aws-modules/elb/aws"
  version = "~> 2.0"

  name = var.name

  subnets         = var.lb_subnets
  security_groups = var.sgs
  internal        = false

  listener = [
    {
      instance_port     = var.instance_port
      instance_protocol = var.instance_protocol
      lb_port           = var.lb_port
      lb_protocol       = var.lb_protocol
    },
    {
      instance_port     = var.instance_port
      instance_protocol = var.instance_protocol
      lb_port           = var.lb_port
      lb_protocol       = var.lb_protocol
      ssl_certificate_id  = "ssl_ARN"

    },
  ]

  health_check = {
    target              = "HTTP:80/"
    interval            = 30
    healthy_threshold   = 2
    unhealthy_threshold = 2
    timeout             = 5
  }


  // ELB attachments
  number_of_instances = var.instaces_number
  instances           = var.instances_id

  tags = {
    Owner       = var.owner
    Environment = var.tag
  }
}

variables.tf

variable "aws_region" {
  description = "AWS Region"
}

variable "name" {
  description = "Cluster Name"
}
variable "lb_subnets" {
  description = "Cluster subnets"
  type  = list(string)
}

variable "sgs" {
  description = "Security Groups"
  type  = list(string)
}

variable "instance_port" {
  description = "Instance port"
  type  = number
}
variable "instance_protocol" {
  description = "Instance protocol"
  type  = string
}
variable "lb_port" {
  description = "LB port"
  type  = number
}
variable "lb_protocol" {
  description = "LB protocol"
  type  = string
}
variable "instaces_number" {
  description = "instances numbers"
  type  = number
}
variable "instances_id" {
  description = "Instance IDs"
  type  = list(string)
}

variable "owner" {
  description = "lb owner"
  type  = string
}
variable "tag" {
  description = "lb tag"
  type  = string
}

С уважением!

...