Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Associated Security Groups doesn't work #102

Closed
gandraa opened this issue Dec 7, 2021 · 1 comment
Closed

Associated Security Groups doesn't work #102

gandraa opened this issue Dec 7, 2021 · 1 comment
Labels
bug 🐛 An issue with the system

Comments

@gandraa
Copy link
Contributor

gandraa commented Dec 7, 2021

Found a bug? Maybe our Slack Community can help.

Slack Community

Describe the Bug

Creating an efs and assigning a security group, the modules throws exception

# ===================================================== #
# - - EFS and allow access from Instances - - - #
# ===================================================== #
module "efs" {
  source = "cloudposse/efs/aws"
  version = "~> 0.32"

  region                    = var.efs_region
  vpc_id                    = module.fetch_existing_infra.vpc_base_id
  subnets                  = module.fetch_existing_infra.target_private_subnets
  encrypted                 = true

  efs_backup_policy_enabled       = true

  associated_security_group_ids   = [module.efs_security_group.id]
  create_security_group           = false
}

module "efs_security_group" {
  source = "cloudposse/security-group/aws"

  name                       = "${var.system_tag}_efs_security_group"
  security_group_name        = ["${var.system_tag}_efs_security_group"]
  security_group_description = "Security Group for EFS for ${var.system_tag} hosts"
  vpc_id                     = module.fetch_existing_infra.vpc_base_id

  rules = [
    {
      type                     = "ingress"
      from_port                = var.efs_port
      to_port                  = var.efs_port
      protocol                 = "TCP"
      source_security_group_id = module.ec2_security_group.security_group_id
      description              = "Allow EC2 instances to get access on EFS over port ${var.efs_port}"
    }
  ]
}

The exception:

╷
│ Error: Error in function call
│ 
│   on .terraform/modules/efs/main.tf line 44, in resource "aws_efs_mount_target" "default":44:     sort(concat(
│   45:       [module.security_group.id],
│   46:       var.associated_security_group_ids47:     ))
│     ├────────────────
│     │ module.security_group.id is null
│     │ var.associated_security_group_ids is empty list of string
│ 
│ Call to function "sort" failed: given list element 0 is null; a null string cannot be sorted.
╵
╷
│ Error: Error in function call
│ 
│   on .terraform/modules/efs/main.tf line 44, in resource "aws_efs_mount_target" "default":44:     sort(concat(
│   45:       [module.security_group.id],
│   46:       var.associated_security_group_ids47:     ))
│     ├────────────────
│     │ module.security_group.id is null
│     │ var.associated_security_group_ids is empty list of string
│ 
│ Call to function "sort" failed: given list element 0 is null; a null string cannot be sorted.
@gandraa gandraa added the bug 🐛 An issue with the system label Dec 7, 2021
@dspv
Copy link

dspv commented Dec 14, 2021

The same issue. Don't want to create security groups

nitrocode pushed a commit that referenced this issue Dec 23, 2021
* fix security group issue when security_group is null

* fix security group issue when security_group is null

* return back the initial example

Co-authored-by: Dragan Dragicevic <dragan.dragicevic@gls-itservices.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐛 An issue with the system
Projects
None yet
Development

No branches or pull requests

3 participants