【问题标题】:Error on adding SSL ceritifcate - Using Terraform modules添加 SSL 证书时出错 - 使用 Terraform 模块
【发布时间】:2020-01-06 20:47:22
【问题描述】:

对不起,我的英语不好。

模块:terraform-aws-elb 版本:2.0 链接:https://github.com/terraform-aws-modules/

我尝试使用此模块,但是当我从 SSL 证书添加 ARN 时,此消息显示给我:

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

并且,将 lookup(listener.value, "ssl_certificate_id", null)ssl_certificate_id 参数从我的证书更改为我的 ARN,ACM 模块和 ELB 工作正常。

如果有人经历过这个,如果你能提供帮助,谢谢你,如果我的配置不好,我很抱歉。


环境配置

  • Terraform 版本:Terraform v0.12.18
  • provider.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
  }
}

变量.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
}

问候!

【问题讨论】:

  • 你能把你修改的那行贴出来吗
  • 您能否编辑您的问题以包含您的 Terraform 代码,最好在 minimal reproducible example 中重现您的错误?
  • 对不起!!在模块中,我更改了第 21 行。我正在编辑帖子并添加配置示例。

标签: terraform aws-load-balancer


【解决方案1】:

main.tf 我有这些行:

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"
},

但是,我不需要两次声明值。我换了:

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

【讨论】:

    猜你喜欢
    • 2020-11-17
    • 2020-10-24
    • 1970-01-01
    • 2021-12-18
    • 2021-07-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多