awslabs / route53-dynamic-dns-with-lambda

A Dynamic DNS system built with API Gateway, Lambda & Route 53.
Apache License 2.0
491 stars 166 forks source link

Placing an action within a variable that gets redefined #30

Closed BeardedBandit94 closed 5 years ago

BeardedBandit94 commented 5 years ago

When I used your cloud formation template, I was getting the client to hit the stack as intended, and I got back a success message, but when I checked, the route 53 entry remained unchanged, as well as the set IP in DDB. The only item updated was the last_accessed field.

I assumed the issue was in my implementation, and began to reverse engineer how you intended it to function. When I looked at how lambda interacts with DDB and R53 to check and change records, I found a bug.

Line 291 of the DDNS Lambda index.py sets the action as a variable, Line 301 redefines it. Executing the action instead of setting it within a variable corrects the issue I experienced.

`` return_status = route53_set( 'set_record', aws_region, route_53_zone_id, set_hostname, route_53_record_ttl, route_53_record_type, set_ip)

Update DynamoDB with IP and update timestamp

        ddb_config(set_hostname, route_53_record_type, set_ip, source_ip, 'write')
        return_status = 'success'
        return_message = 'Your hostname record ' + set_hostname +\
            ' has been set to ' + set_ip
        return {'return_status': return_status,
                'return_message': return_message}
seangreathouse commented 5 years ago

Thanks Mr. Bandit.

Something else is going on though. This template has worked solidly for quite a while. I was unable to replicate your issue by manually modifying the Lambda code in the console.
However, after re-deploying the stack I am able to repeat the error.
Removing the variable as you suggest does not seem to resolve the issue. I will continue to investigate, but am open to any more thoughts you have.

BeardedBandit94 commented 5 years ago

Oh, that's interesting. It corrected the issue for my deployment. It took a while for me to actually find it. If I'm reading the setup correctly, is that python staged in s3? Maybe making the edit there would work.

On Wed, Sep 11, 2019, 6:17 PM Sean Greathouse notifications@github.com wrote:

Thanks Mr. Bandit.

Something else is going on though. This template has worked solidly for quite a while. I was unable to replicate your issue by manually modifying the Lambda code in the console. However, after re-deploying the stack I am able to repeat the error. Removing the variable as you suggest does not seem to resolve the issue. I will continue to investigate, but am open to any more thoughts you have.

  • Sean

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/awslabs/route53-dynamic-dns-with-lambda/issues/30?email_source=notifications&email_token=AC7TUAP5TD2LIKIN45Y547TQJF377A5CNFSM4IVYTH3KYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD6QFNDI#issuecomment-530601613, or mute the thread https://github.com/notifications/unsubscribe-auth/AC7TUAMEYAIF3W7RYABEPM3QJF377ANCNFSM4IVYTH3A .