Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(modules/asg): Accept entire SG list for ENI in ASG module #88

Merged
merged 3 commits into from
Oct 29, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion modules/asg/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ resource "aws_launch_template" "this" {

network_interfaces {
device_index = 0
security_groups = [local.default_eni_sg_ids[0]]
security_groups = local.default_eni_sg_ids
subnet_id = values(local.default_eni_subnet_names[0])[0]
associate_public_ip_address = try(local.default_eni_public_ip[0])
}
Expand Down
6 changes: 3 additions & 3 deletions modules/asg/scripts/lambda.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ def create_interface_settings(instance_zone: str) -> list:
for k, v in sett.items():
interface[eni] = {} if eni not in interface.keys() else interface[eni]
interface[eni]["index"] = int(v) if 'device_index' in k else interface.get(eni).get('index')
interface[eni]["sg"] = v[0] if 'security_group_ids' in k else interface.get(eni).get('sg')
interface[eni]["sg"] = v if 'security_group_ids' in k else interface.get(eni).get('sg')
interface[eni]["c_pub_ip"] = v if 'create_public_ip' in k else interface.get(eni).get('c_pub_ip')
interface[eni]["s_dest_ch"] = v if 'source_dest_check' in k else interface.get(eni).get('s_dest_ch')
if 'subnet_id' in k:
Expand All @@ -180,7 +180,7 @@ def inspect_ec2_instance(self, instance_id: str) -> tuple:
return instance_info.get('Placement').get('AvailabilityZone') if 'Placement' in instance_info else None, \
instance_info.get('SubnetId'), instance_info.get('NetworkInterfaces')

def create_network_interface(self, instance_id: str, subnet_id: str, sg_id: int) -> str:
def create_network_interface(self, instance_id: str, subnet_id: str, sg_id: list) -> str:
acelebanski marked this conversation as resolved.
Show resolved Hide resolved
"""
As function name, it creates new ENI, if something wrong it catch error.

Expand All @@ -196,7 +196,7 @@ def create_network_interface(self, instance_id: str, subnet_id: str, sg_id: int)
tag_specifications = [{'Key': k, 'Value': v} for k, v in tags.items()]
network_interface = self.ec2_client.create_network_interface(
SubnetId=subnet_id,
Groups=[sg_id],
Groups=sg_id,
acelebanski marked this conversation as resolved.
Show resolved Hide resolved
TagSpecifications=[
{
'ResourceType': 'network-interface',
Expand Down
Loading