Skip to content

Commit

Permalink
Use indices to prevent security group name clobbers
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanjjung committed Jan 31, 2025
1 parent 326476c commit 37bf195
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
1 change: 1 addition & 0 deletions tb_pulumi/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
# <https://thunderbird.github.io/pulumi/getting-started.html>`_
import boto3
import pulumi
import string

Check failure on line 8 in tb_pulumi/__init__.py

View workflow job for this annotation

GitHub Actions / lint

Ruff (F401)

tb_pulumi/__init__.py:8:8: F401 `string` imported but unused
import yaml

from functools import cached_property
Expand Down
8 changes: 4 additions & 4 deletions tb_pulumi/network.py
Original file line number Diff line number Diff line change
Expand Up @@ -319,22 +319,22 @@ def __init__(
egress_rules = []

ingress_ruledefs = rules['ingress']
for rule in ingress_ruledefs:
for idx, rule in enumerate(ingress_ruledefs):
rule.update({'type': 'ingress', 'security_group_id': sg.id})
ingress_rules.append(
aws.ec2.SecurityGroupRule(
f'{name}-ingress-{rule["to_port"]}',
f'{name}-ingress-{idx}',
opts=pulumi.ResourceOptions(parent=self, depends_on=[sg]),
**rule,
)
)

egress_ruledefs = rules['egress']
for rule in egress_ruledefs:
for idx, rule in enumerate(egress_ruledefs):
rule.update({'type': 'egress', 'security_group_id': sg.id})
egress_rules.append(
aws.ec2.SecurityGroupRule(
f'{name}-egress-{rule["to_port"]}',
f'{name}-egress-{idx}',
opts=pulumi.ResourceOptions(parent=self, depends_on=[sg]),
**rule,
)
Expand Down

0 comments on commit 37bf195

Please sign in to comment.