Skip to content

Commit

Permalink
Adds support for additional security groups (#4)
Browse files Browse the repository at this point in the history
* Added support for attaching additional security groups to the EC2 instance

* Performed terraform fmt

* Restored sample
  • Loading branch information
Kralizek authored Dec 4, 2023
1 parent 7b8aad0 commit f19577a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
5 changes: 4 additions & 1 deletion ec2.tf
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,10 @@ resource "aws_launch_template" "main" {
description = "${var.name} ephemeral public ENI"
subnet_id = var.subnet_id
associate_public_ip_address = true
security_groups = [aws_security_group.main.id]
security_groups = concat(
[aws_security_group.main.id],
var.additional_security_group_ids
)
}

dynamic "instance_market_options" {
Expand Down
6 changes: 6 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -115,4 +115,10 @@ variable "tags" {
description = "Tags to apply to resources created within the module"
type = map(string)
default = {}
}

variable "additional_security_group_ids" {
description = "A list of identifiers of security groups to be added to the EC2 instance"
type = list(string)
default = []
}

0 comments on commit f19577a

Please sign in to comment.