cyberlabrs / terraform-aws-opensearch

Terraform module to provision an OpenSearch cluster with SAML and Cognito authentication.
Apache License 2.0
31 stars 13 forks source link

Setting master_password fails with errors. #11

Closed nirmalpathak closed 1 year ago

nirmalpathak commented 1 year ago
Plan: 2 to add, 0 to change, 0 to destroy.
╷
│ Error: Invalid index
│ 
│   on .terraform/modules/opensearch/main.tf line 28, in resource "aws_ssm_parameter" "opensearch_master_user":
│   28:   value       = "${var.master_user_name},${coalesce(var.master_password, random_password.password[0].result)}"
│     ├────────────────
│     │ random_password.password is empty tuple
│ 
│ The given key does not identify an element in this collection value: the collection has no elements.
╵
╷
│ Error: Invalid index
│ 
│   on .terraform/modules/opensearch/main.tf line 76, in resource "aws_opensearch_domain" "opensearch":
│   76:       master_user_password = var.internal_user_database_enabled ? coalesce(var.master_password, random_password.password[0].result) : ""
│     ├────────────────
│     │ random_password.password is empty tuple
│ 
│ The given key does not identify an element in this collection value: the collection has no elements.
╵

My Code:-

module "opensearch" {
  source                                         = "cyberlabrs/opensearch/aws"
  version                    = "0.0.15"

  name                                           = "my-os"
  engine_version                 = var.engine_ver
  region                                         = var.region
  instance_type                  = var.instance_type
  master_user_name               = var.master_username
  #master_password               = var.master_password
  master_password                = "MyPassw0rD_String"

  advanced_security_options_enabled              = true
  default_policy_for_fine_grained_access_control = true
  internal_user_database_enabled                 = true
  inside_vpc                                     = true
  create_linked_role                 = false
  vpc                                            = var.vpc_id
  subnet_ids                                     = var.private_subnet_ids
  allowed_cidrs                                  = var.ingress_cidr_blocks
  node_to_node_encryption                        = true

  volume_size                    = 50
  volume_type                    = "gp3"
  encrypt_at_rest = {
    enabled = true
  }

  tags                       = var.tags
}
Dhirva commented 1 year ago

Yes, same error has arrived to me. Stuck because of this issue.

andros3 commented 1 year ago

Hello, bug is fixed. Thanks for feedback. :+1: