nccgroup / sadcloud

A tool for standing up (and tearing down!) purposefully insecure cloud infrastructure
https://www.nccgroup.trust/us/about-us/newsroom-and-events/blog/2019/october/sadcloud-templating-cloud-misconfigurations/
GNU Affero General Public License v3.0
656 stars 94 forks source link

Terraform Version, subnet_ids Not Recognized #20

Open joswr1ght opened 3 years ago

joswr1ght commented 3 years ago

I'm unable to get the sadcloud scripts to deploy following an error in the Cloud Trail module.

(aws) sadcloud (master) $ terraform -version
Terraform v0.15.1
on darwin_amd64
(aws) sadcloud (master) $ git log -1
commit b3de799d960c51503558af749ed41f44efd7d359 (HEAD -> master, origin/master, origin/HEAD)
Author: Rami McCarthy <ramimac@users.noreply.github.com>
Date:   Tue Jun 30 16:14:33 2020 -0400

    Update README.md
(aws) sadcloud (master) $ terraform apply

... some time later:

│ Error: Error launching source instance: VPCResourceNotSpecified: The specified instance type can only be used in a VPC. A subnet ID or network interface ID is required to carry out the request.
│   status code: 400, request id: 2f47199d-6ed6-42ce-99e0-aa7982a5df6e
│
│   with module.ec2.aws_instance.main[0],
│   on ../modules/aws/ec2/main.tf line 18, in resource "aws_instance" "main":
│   18: resource "aws_instance" "main" {

Here is the context of the main.tf file:

(aws) sadcloud (master) $ cat -n ../modules/aws/ec2/main.tf | sed -n 17,23p
    17
    18  resource "aws_instance" "main" {
    19    ami           = data.aws_ami.ubuntu.id
    20    instance_type = var.disallowed_instance_type ? "t2.micro" : "t2.small"
    21    subnet_id     = var.main_subnet_id
    22    count         = var.disallowed_instance_type || var.instance_with_user_data_secrets || var.instance_with_public_ip ? 1 : 0
    23

I'm new to Terraform, and I'm not sure how to respond to this error. When I tried to build I get an error about the use of list() as deprecated, so I converted them to tolist() per the new API use. I've attached my diff, though it doesn't seem to be related to anything for subnets or network IDs. Any ideas? Thanks!

joswr1ght commented 3 years ago

tolist.diff.txt