Skip to content

Commit bb0279f

Browse files
committed
feat: adds support for creating security group
1 parent 6697ec6 commit bb0279f

File tree

5 files changed

+49
-1
lines changed

5 files changed

+49
-1
lines changed

data.tf

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
data "aws_vpc" "default" {
2+
default = true
3+
}

main.tf

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
resource "aws_security_group" "this" {
2+
name = var.name
3+
description = var.description
4+
vpc_id = coalesce(var.vpc_id, data.aws_vpc.default.id)
5+
6+
tags = var.tags
7+
}

outputs.tf

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
output "security_group_id" {
2+
description = "The ID of the security group"
3+
value = aws_security_group.this.id
4+
}
5+
6+
output "security_group_arn" {
7+
description = "The ARN of the security group"
8+
value = aws_security_group.this.arn
9+
}

variables.tf

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
variable "name" {
2+
description = "(Optional, Forces new resource) Name of the security group."
3+
type = string
4+
}
5+
6+
variable "description" {
7+
description = "(Optional, Forces new resource) Security group description."
8+
type = string
9+
default = "Managed by Terraform"
10+
}
11+
12+
variable "vpc_id" {
13+
description = "(Optional, Forces new resource) VPC ID."
14+
type = string
15+
default = null
16+
}
17+
18+
variable "tags" {
19+
description = " (Optional) Map of tags to assign to the resource. "
20+
type = map(string)
21+
default = {}
22+
}

versions.tf

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
11
terraform {
2-
required_version = ">= 1.8.4"
2+
required_version = ">= 1.8.4"
3+
4+
required_providers {
5+
aws = {
6+
source = "hashicorp/aws"
7+
version = ">= 5.51.0"
8+
}
9+
}
310
}

0 commit comments

Comments
 (0)