4

I'm creating few resources like Alb, security group and I use modules from github :

module "efs_sg" { 
  source  = "git::https://github.com/terraform-aws-modules/terraform-aws-security-group.git" 
  version = "3.2.0" 

  name        = "${var.default_tags["app"]}-efs" 
  description = "Security group for FE " 
  vpc_id      = data.terraform_remote_state.network.outputs.vpc_id


  computed_ingress_with_source_security_group_id = [ 
    { 
      from_port   = 2049 
      to_port     = 2049 
      protocol    = "tcp" 
      description = "NFS" 
      source_security_group_id = "${module.asg_sg.this_security_group_id}" 
    } 
  ] 
  number_of_computed_ingress_with_source_security_group_id = 1 

  tags      = "${var.default_tags}" 
}

when I do terraform apply/plan I get this error:

Error: Invalid version constraint

Cannot apply a version constraint to module "efs_sg" (at
terraform/dev/eu-west-1/sg.tf:107) because it has a non Registry
URL. 

I'm using Terraform v0.12.12

How to fix this?

1 Answer 1

6

You can't use the version constraint with a git hosted module. The version constraint requires a Terraform Registry hosted module.

You can add a tag to the repo and use the ?ref query.

eg:

"git::https://github.com/terraform-aws-modules/terraform-aws-security-group.git?ref=3.2.0"

https://www.terraform.io/docs/modules/sources.html#selecting-a-revision

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.