Create and Use Terraform Modules Requirements not clear

Terraform Level 4, Task 3 is failing because the name of the vpc is not correct while the vpc name is not stated in the lab requirements.
lab link: https://engineer.kodekloud.com/task?id=690aee58b572684d84d32aa7

Also, tried this task multiple times, each time it’s stuck in “… Still creating”.
Logs show continues calls to “Action=DescribeInstanceCreditSpecification”

Hi @Mederbek @moustafaroushdy1

I was able to complete the task using the main.tf file below. Please ensure that it is applied in both the Dev and Prod workspaces.

# Define locals for name prefix and default tags
locals {
  name_prefix  = "xfusion-${terraform.workspace}"
  default_tags = {
    Project     = "xfusion"
    Environment = terraform.workspace
  }
}

# Network module
module "network" {
  source          = "./modules/network"
  KKE_NAME_PREFIX = local.name_prefix
  KKE_VPC_CIDR    = var.KKE_VPC_CIDR
  KKE_TAGS        = local.default_tags
}

# Compute module
module "compute" {
  source           = "./modules/compute"
  KKE_NAME_PREFIX  = local.name_prefix
  KKE_SUBNET_ID    = module.network.kke_subnet_id
  KKE_INSTANCE_TYPE = var.KKE_INSTANCE_TYPE
  KKE_TAGS         = local.default_tags
}

I find task objectives for this task very vague:
image
image

I tried ec2 name as “devops-dev-ec2”, “devops-dev”, still not able to pass it.
does it wants as output ec2 name (which we output from tag[Name]), or ec2 id?

Hi @Mederbek

It should be devops-dev-instance based on the task information.

Here is the main.tf of compute module:

resource "aws_instance" "this" {
  ami           = "ami-0c94855ba95c71c99"
  instance_type = var.KKE_INSTANCE_TYPE
  subnet_id     = var.KKE_SUBNET_ID

  tags = merge(var.KKE_TAGS, {
    Name = "${var.KKE_NAME_PREFIX}-instance"
  })
}
1 Like