C2W3 Terraform Lab - SSH tunneling not working

When creating a post, please add:

  • Module # must be added in the tags option of the post. (ex: Module-1)
  • Link to the classroom item you are referring to:
  • Description (include relevant info but please do not post solution code or your entire notebook)

Issue in the Terraform Assignment (Lab):

When attempting to create the SSH tunnel for the newly created RDB, it hangs. As per lab, the instructions are :

  • <RDS-HOST> with the output from the command terraform output db_host ,
  • <DATABASE-PORT> with the output from the command terraform output db_port ,
  • <BASTION-HOST-DNS> with the output from the command terraform output bastion_host_dns :
ssh -i de-c2w3lab1-bastion-host-key.pem -L 5432:<RDS-HOST>:<DATABASE-PORT> ec2-user@<BASTION-HOST

My output from terraform output:

terraform output db_port
5432

this seems suspicious as it’s the same as the local port?

terraform output bastion_host_dns
ec2-54-152-54-145.compute-1.amazonaws.com
terraform output db_host
"de-c2w3lab1-db.cxcsg80ioalq.us-east-1.rds.amazonaws.com"

so the final command for the SSH tunnel is:

ssh -i de-c2w3lab1-bastion-host-key.pem -L 5432:de-c2w3lab1-db.cxcsg80ioalq.us-east-1.rds.amazonaws.com:5432 ec2-user@ec2-54-152-54-145.compute-1.amazonaws.com -N -f

When running the command it hangs for a while and then times out:


ssh: connect to host ec2-54-152-54-145.compute-1.amazonaws.com port 22: Connection timed out

This implies that the local port is the same as the db port, nut I’m not sure how to fix the issue?

Hello @marinaganopolsky
Your command for establishing the SSH tunnel seems correct, and the database port is the same as local port, both 5432. My guess is that there is a misconfiguration in your terraform files, most probably in the network.tf file, that has caused this issue.
If you have run the command terraform apply without any errors and if your bastion host is up, the problem should be that you cannot perform a connection between your Cloud9 instance and the bastion host. I suggest checking your filled out files with the solution files that are available to you to find out any potential mismatch between your answers and the verified ones.