Skip to content

Commit

Permalink
chore: Update based on PR review feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
bryantbiggs committed Feb 7, 2023
1 parent a840ae3 commit 0ad1649
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
repos:
- repo: https://github.com/antonbabenko/pre-commit-terraform
rev: v1.77.0
rev: v1.77.1
hooks:
- id: terraform_fmt
- id: terraform_wrapper_module_for_each
Expand Down
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,6 @@ No modules.
| [aws_lb_target_group_attachment.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/lb_target_group_attachment) | resource |
| [aws_security_group.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/security_group) | resource |
| [aws_security_group_rule.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/security_group_rule) | resource |
| [aws_subnet.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/subnet) | data source |

## Inputs

Expand Down
5 changes: 4 additions & 1 deletion examples/complete-alb/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ locals {

tags = {
Example = local.name
GithubRepo = "terraform-aws-eks"
GithubRepo = "terraform-aws-alb"
GithubOrg = "terraform-aws-modules"
}
}
Expand All @@ -33,6 +33,9 @@ module "alb" {

vpc_id = module.vpc.vpc_id
subnets = module.vpc.public_subnets
# Attach security groups
security_groups = [module.vpc.default_security_group_id]
# Attach rules to the created security group
security_group_rules = {
ingress_all_http = {
type = "ingress"
Expand Down
14 changes: 6 additions & 8 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -774,21 +774,19 @@ locals {
security_group_name = try(coalesce(var.security_group_name, var.name, var.name_prefix), "")
}

data "aws_subnet" "this" {
count = local.create_security_group ? 1 : 0

id = element(var.subnets, 0)
}

resource "aws_security_group" "this" {
count = local.create_security_group ? 1 : 0

name = var.security_group_use_name_prefix ? null : local.security_group_name
name_prefix = var.security_group_use_name_prefix ? "${local.security_group_name}-" : null
description = var.security_group_description
vpc_id = data.aws_subnet.this[0].vpc_id
vpc_id = var.vpc_id

tags = merge(var.tags, var.security_group_tags)
tags = merge(
var.tags,
var.security_group_tags,
{ "Name" = local.security_group_name },
)

lifecycle {
create_before_destroy = true
Expand Down

0 comments on commit 0ad1649

Please sign in to comment.