Error: Unsupported argument
on main.tf line 3, in module "ec2_test":
3: ec2_count = 2
An argument named "ec2_count" is not expected here.
Error: Unsupported argument
on main.tf line 4, in module "ec2_test":
4: ami_id = "ami-123"
An argument named "ami_id" is not expected here.
Error: Unsupported argument
on main.tf line 5, in module "ec2_test":
5: instance_type = "t2.micro"
An argument named "instance_type" is not expected here.
The same module is working fine when I use it from local. The problem arises when I try to use the modules uploaded to bitbucket and give the URL as source in main.tf. Terraform init works fine and it cloned the repo to .terraform/modules/ec2
but on Terraform apply it gives the above error.
Below mentioned are the module for ec2 and respective var file from the Bitbucket private-repo instance.tf:
provider "aws"{
region = var.region
}
resource "aws_instance" "ec2" {
count = var.ec2_count
ami = var.ami_id
instance_type = var.instance_type
subnet_id = var.subnet_id
vpc_security_group_ids = var.security_grp
tags = {
Name = "Terraform_module_test"
}
}
var.tf
variable "ec2_count" {
default = "1"
}
variable "ami_id" {}
variable "instance_type" {
default = "t2.micro"
}
variable "subnet_id" {}
variable "security_grp" {}
variable "region" {}
The main.tf from which the modules are accessed
module "ec2_test" {
source = "[email protected]:private-repo/terraform.git/modules_terraform/ec2"
ec2_count = 2
ami_id = "ami-123"
instance_type = "t2.micro"
subnet_id = "subnet-123"
security_grp = ["sg-123"]
region = "ap-southeast-1"
}