Terraform Level 1 task 1


by viewing this image we can say that i have created the devops-kp.pem file and its of type RSA but why am i still failing the task am i missing something?
Kindly let me know thanks in advance
even i have freed the file permission for key file to 777 for facing any permission denied issue during task validation

Please post your terraform script in a code block; just tried this lab today, so I’m pretty sure it works.

Hi Rob,
kindly check it out.

# RSA based Key pair creation
resource "tls_private_key" "nautilus_keypair" {
    algorithm = "RSA"
}

# saving in local file
resource "local_file" "save_nautilus_keypair" {
    content = tls_private_key.nautilus_keypair.private_key_pem
    filename = "/home/bob/nautilus-kp.pem"
}

I think you also have to create an aws keypair that corresponds to the key. Code would look something like:

resource "aws_key_pair" "nautilus" {
  key_name   = "nautilus-kp"
  public_key = tls_private_key.nautilus_keypair.public_key_openssh
}

You might also need to set the permissions on the private key, something like

resource "local_file" "save_nautilus_keypair" {
    content = tls_private_key.nautilus_keypair.private_key_pem
    filename = "/home/bob/nautilus-kp.pem"
    file_permission      = "0600"
}

Thanks Rob the solution works,

but the question doesn’t says. to upload the keypair to aws environment isn’t it kindly mention in the question.

Thank you in advance.

The task definition says:

The Nautilus DevOps team is strategizing the migration of a portion of their infrastructure to the AWS cloud. Recognizing the scale of this undertaking, they have opted to approach the migration in incremental steps rather than as a single massive transition. To achieve this, they have segmented large tasks into smaller, more manageable units. This granular approach enables the team to execute the migration in gradual phases, ensuring smoother implementation and minimizing disruption to ongoing operations. By breaking down the migration into smaller tasks, the Nautilus DevOps team can systematically progress through each stage, allowing for better control, risk mitigation, and optimization of resources throughout the migration process.

For this task, create a key pair using Terraform with the following requirements:

  • Name of the key pair should be datacenter-kp.

  • Key pair type must be rsa.

  • The private key file should be saved under /home/bob/datacenter-kp.pem.The Terraform working directory is /home/bob/terraform. Create the main.tf file (do not create a different .tf file) to accomplish this task.

So this key is part of an AWS architecture, per the task. Until you create a keypair object in AWS, AWS doesn’t know anything about your keypair on the jump host. So uploading the key pair (and defining it to AWS) is an essential part of the task.