-
Notifications
You must be signed in to change notification settings - Fork 321
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added possibility of sec group being a var (#5208)
- Loading branch information
1 parent
e7da059
commit 37ca249
Showing
2 changed files
with
112 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
100 changes: 100 additions & 0 deletions
100
assets/queries/terraform/aws/security_groups_not_used/test/negative4.tf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
terraform { | ||
required_providers { | ||
aws = { | ||
source = "hashicorp/aws" | ||
version = "~> 4.0" | ||
} | ||
} | ||
|
||
required_version = ">= 1.1.0" | ||
} | ||
|
||
variable "iam_role" { | ||
type = string | ||
default = "AmazonSSMRoleForInstancesQuickSetup" | ||
description = "Set AWS IAM role." | ||
} | ||
|
||
variable "ami_owner" { | ||
type = string | ||
default = "self" | ||
description = "Set AWS image owner." | ||
} | ||
|
||
variable "region" { | ||
type = string | ||
default = "eu-west-3" | ||
description = "Set AWS region." | ||
} | ||
|
||
variable "secgroups" { | ||
type = list(string) | ||
default = ["CowrieSSH"] | ||
description = "Set AWS security groups." | ||
} | ||
|
||
data "aws_ami" "cowrie" { | ||
most_recent = true | ||
owners = ["${var.ami_owner}"] | ||
|
||
filter { | ||
name = "name" | ||
values = ["cowrie-packer-*"] | ||
} | ||
|
||
filter { | ||
name = "virtualization-type" | ||
values = ["hvm"] | ||
} | ||
} | ||
|
||
provider "aws" { | ||
profile = "default" | ||
region = var.region | ||
} | ||
|
||
resource "aws_security_group" "cowrie" { | ||
name = "CowrieSSH" | ||
description = "CowrieSSH Terraform security group" | ||
|
||
ingress { | ||
description = "Allow anyone to connect to the honeypot." | ||
from_port = 22 | ||
to_port = 22 | ||
protocol = "tcp" | ||
cidr_blocks = ["0.0.0.0/0"] | ||
} | ||
|
||
egress { | ||
description = "Allow all outgoing traffic." | ||
from_port = 0 | ||
to_port = 0 | ||
protocol = "-1" | ||
cidr_blocks = ["0.0.0.0/0"] | ||
ipv6_cidr_blocks = ["::/0"] | ||
} | ||
|
||
tags = { | ||
Name = "cowrie_ssh_sg" | ||
purpose = "honeypot" | ||
} | ||
} | ||
|
||
resource "aws_instance" "cowrie_server" { | ||
ami = data.aws_ami.cowrie.id | ||
instance_type = "t3.nano" | ||
security_groups = var.secgroups | ||
iam_instance_profile = var.iam_role | ||
|
||
metadata_options { | ||
http_endpoint = "enabled" | ||
http_tokens = "required" | ||
} | ||
|
||
tags = { | ||
Name = "cowrie", | ||
author = "konstruktoid" | ||
vcs-url = "https://github.com/konstruktoid/ansible-cowrie-rootless" | ||
purpose = "honeypot" | ||
} | ||
} |