Week 4 lab

Everything is smooth with week 4 lab until ‘terraform plan’ is added to the terminal. At this point, a series of prompts beginning with

var.db_sg_id

  • Security group ID for RDS*

  • Enter a value:*

Unfortunately my knowledge of TF is limited and I’m unable to resolve. The prompts, regardless of what I for values, usually end with a series of logs and this:

Plan: 9 to add, 0 to change, 0 to destroy.

Changes to Outputs:
  + data_lake_bucket_id = (known after apply)
  + scripts_bucket_id   = (known after apply)
╷
│ Error: no matching EC2 Subnet found
│ 
│   with module.etl.data.aws_subnet.private_a,
│   on modules/etl/network.tf line 1, in data "aws_subnet" "private_a":
│    1: data "aws_subnet" "private_a" {
│ 
╵
╷
│ Error: reading EC2 Security Group: operation error EC2: DescribeSecurityGroups, https response error StatusCode: 400, RequestID: ef715870-fb90-4f46-87b3-6f80b741dbf1, api error InvalidGroupId.Malformed: Invalid id: "0" (expecting "sg-...")
│ 
│   with module.etl.data.aws_security_group.db_sg,
│   on modules/etl/network.tf line 5, in data "aws_security_group" "db_sg":
│    5: data "aws_security_group" "db_sg" {
│ 

The lab walkthrough included footage of removing comments in 2 TF files which I did; however the video’s use of ‘terraform plan’ doesn’t match the prompts I received. Help. Thank you.

Hello @Jesse_B
I went through the lab and was not able to reproduce the problem. Everything seems to be working fine.
However, from the logs you have attached, I guess that the problem might be with a network problem. Can you please make sure that you have chosen the correct subnet for your Cloud9 environment and try again? You should choose the public subnet, and choosing the private ones creates issues.

thank you @Amir_Zare. I’ll try again tomorrow.

I’m running into the same issue as this. I know it’s been a while but @Jesse_B any chance you remember how this worked out for you? (if it did at all…)

At first I thought I may have just entered an incorrect answer at some point throughout the lab, but I’ve verified my terraform files against the provided solution and they appear correct, but I still get these errors when I run terraform plan


Plan: 7 to add, 0 to change, 0 to destroy.

Changes to Outputs:
  + project = "de-c2w3lab1"
╷
│ Error: no matching EC2 VPC found
│ 
│   with module.bastion_host.data.aws_vpc.main,
│   on modules/bastion_host/network.tf line 1, in data "aws_vpc" "main":
│    1: data "aws_vpc" "main" {
│ 
╵
╷
│ Error: no matching EC2 Subnet found
│ 
│   with module.bastion_host.data.aws_subnet.public_subnet,
│   on modules/bastion_host/network.tf line 9, in data "aws_subnet" "public_subnet":
│    9: data "aws_subnet" "public_subnet" {
│ 
╵
╷
│ Error: no matching EC2 Subnet found
│ 
│   with module.bastion_host.data.aws_subnet.private_subnet_a,
│   on modules/bastion_host/network.tf line 15, in data "aws_subnet" "private_subnet_a":
│   15: data "aws_subnet" "private_subnet_a" {
│ 
╵
╷
│ Error: no matching EC2 Subnet found
│ 
│   with module.bastion_host.data.aws_subnet.private_subnet_b,
│   on modules/bastion_host/network.tf line 21, in data "aws_subnet" "private_subnet_b":
│   21: data "aws_subnet" "private_subnet_b" {

Hello @kirah
My guess is that you have accidentally deleted a line or a character in the terraform/modules/bastion_host/network.tf file. Please, check this file line by line with the provided solution. If the issue persists, please send your network.tf file so that we can investigate further.

It’s been awhile but I don’t recall the problem was in TF.

I believe the issue I encountered was failing to select “Public subnet” and potentially other configs in the AWS UI

Sorry to bother you with this, I realized I just completely missed the step about updating the terraform.tfvars file with the values from the cloud formation output. It still had all the placeholder values, like "<VPCID-Value>" and "<PublicSubnetID-Value>"! Just a very stupid oversight on my part.

For any future students running into a similar error, I figured it out by running terraform console and inspecting the values of var.vpc_id, var.public_subnet_id, etc. which revealed that these were clearly wrong.