in functions/source/lambda_function.py [0:0]
def get_instance_private_ip_addresses(tagvalue):
instance_private_ip_addresses = []
# Get the private IP addressess of instances with the given characteristics:
# 1. Tagged with directory service ID.
# 2. Tagged with teh RadiusConfigured=True tag, which is applied by the
# "UpdateDirectoryServiceMfaSettings" Lambda function.
#.3. The instance state is running.
response = ec2_client.describe_instances(
Filters=[
{"Name": "tag:duo:DirectoryServiceId", "Values": [tagvalue]},
{"Name": "tag:RadiusConfigured", "Values": ["True"]},
{"Name": "instance-state-name", "Values": ["running"]}
]
)
for reservation in (response["Reservations"]):
for instance in reservation['Instances']:
instance_private_ip_addresses.append(instance["PrivateIpAddress"])
return instance_private_ip_addresses