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

Roundrobin DNS for a shared hostname #4

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Conversation

lizard-boy
Copy link

Creating DNS for multihost entries aka roundrobin DNS.
Updated to TF 12

This addresses meltwater#33

For the repo owner
If you want people such as myself raising PR's please consider adding CODEOWNERS and Contributing.md files.
The CODEOWNERS will auto add reviewers and Contributing.md would detail any other process / code quality etc that submitters should follow

@lizard-boy
Copy link
Author

@greptileai

Copy link

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR Summary

This pull request introduces round-robin DNS functionality for shared hostnames in Auto Scaling Groups, updating the module to Terraform 0.12+ syntax and adding multi-host handling capabilities.

  • Added new lambda/multihost/multihost.py for processing SNS events and managing round-robin DNS entries
  • Updated main.tf with new SNS topic and Lambda function for multi-host handling, using Terraform 0.12+ syntax
  • Modified README.md to include usage instructions for single DNS name configurations and round-robin DNS
  • Introduced use_public_ip variable and updated Python runtime for Lambda functions to 3.8
  • Added new output multihost_handling_sns_topic_arn in outputs.tf for the multi-host feature

5 file(s) reviewed, 5 comment(s)
Edit PR Review Bot Settings

Comment on lines +34 to +37
try:
ip_address = ec2_response['PublicIpAddress']
logger.info("Found public IP for instance-id %s: %s", instance_id, ip_address)
except:
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

style: Consider using a more specific exception type instead of a bare except clause. This will help in catching and handling specific errors.

Comment on lines +40 to +43
try:
ip_address = ec2_response['PrivateIpAddress']
logger.info("Found private IP for instance-id %s: %s", instance_id, ip_address)
except:
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

style: Similar to the previous comment, use a specific exception type here as well.

Comment on lines +52 to +57
ip_address = route53.list_resource_record_sets(
HostedZoneId=zone_id,
StartRecordName=hostname,
StartRecordType='A',
MaxItems='1'
)['ResourceRecordSets'][0]['ResourceRecords'][0]['Value']
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

logic: This API call assumes the record exists. Add error handling for cases where the record is not found.

Comment on lines +176 to +178
logger.info("Finishing ASG action")
message = json.loads(record['Sns']['Message'])
if LIFECYCLE_KEY in message and ASG_KEY in message :
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

logic: This code assumes 'record' is still in scope from the previous loop. Move it inside the loop to ensure it's always defined.


filename = data.archive_file.multihost.output_path
function_name = format("%s-%s-multi", var.vpc_name, var.autoscale_handler_unique_identifier)
role = aws_iam_role.autoscale_handling.arn
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

style: Reuse of autoscale_handling role for multihost. Consider creating a separate role for better separation of concerns

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants