aws-samples / hostname-as-target-for-elastic-load-balancer Goto Github PK
View Code? Open in Web Editor NEWLicense: MIT No Attribution
License: MIT No Attribution
Hello, I followed the guide at https://aws.amazon.com/blogs/networking-and-content-delivery/hostname-as-target-for-network-load-balancers/ but have not been able to get this working successfully inside a VPC. When the function runs, it always reaches timeout. I've made sure to add an open security group for the lambda, as well as adding the lambda to the vpc and placing it in the same subnets as my vpc private endpoint resource.
Any suggestions on what I am doing wrong? Thanks
There is a race condition in the Cloudformation template. Adding a depends on for the lambda function solves the issue. PR to follow
If you are trying to use the lamda with non-vpc IP address the AWS api/boto3 will fail with the following error
[ERROR] 2022-11-19T18:50:05.007Z 75a3e5b4-4302-4493-9824-539647241114 The Availability Zone is required for IP address '172.25.18.11' because it is not in the VPC
To resolve you need to specify the AZ in the render_list
function. This should prob be added as an option param in the formation template
def render_list(ip_list):
"""
Render a list of targets for registration/deregistration
"""
target_list = []
for ip in ip_list:
target = {
'Id': ip,
'AvailabilityZone': 'all'
}
target_list.append(target)
return target_list
Have anyone run into this error...
[ERROR] 2022-09-22T13:53:11.531Z 173750ff-4fb7-4f2e-a757-316995010d32 ERROR: 'str' object has no attribute 'labels'
Traceback (most recent call last):
File "/var/task/elb_hostname_as_target.py", line 123, in lambda_handler
dns_lookup_result = utils.dns_lookup(DNS_SERVER, TARGET_FQDN, "A")
File "/var/task/lambda_utils.py", line 225, in dns_lookup
lookupAnswer = myResolver.query(domainname, record_type)
File "/var/task/dns/resolver.py", line 916, in query
qnames_to_try.append(qname.concatenate(self.domain))
File "/var/task/dns/name.py", line 682, in concatenate
labels.extend(list(other.labels))
AttributeError: 'str' object has no attribute 'labels'
[ERROR] 2022-09-22T13:53:11.532Z 173750ff-4fb7-4f2e-a757-316995010d32 ERROR: Invocation Failed
The lambda includes the following code:
except Exception as e:
logger.error("ERROR:", e)
This causing a python error if triggered
[ERROR] TypeError: not all arguments converted during string formattingTraceback (most recent call last): File "/var/task/elb_hostname_as_target.py", line 191, in lambda_handler logger.error("ERROR:", e) File "/var/lang/lib/python3.7/logging/__init__.py", line 1407, in error self._log(ERROR, msg, args, **kwargs) File "/var/lang/lib/python3.7/logging/__init__.py", line 1514, in _log self.handle(record) File "/var/lang/lib/python3.7/logging/__init__.py", line 1524, in handle self.callHandlers(record) File "/var/lang/lib/python3.7/logging/__init__.py", line 1586, in callHandlers hdlr.handle(record) File "/var/lang/lib/python3.7/logging/__init__.py", line 894, in handle self.emit(record) File "/var/runtime/bootstrap.py", line 243, in emit msg = self.format(record) File "/var/lang/lib/python3.7/logging/__init__.py", line 869, in format return fmt.format(record) File "/var/lang/lib/python3.7/logging/__init__.py", line 608, in format record.message = record.getMessage() File "/var/lang/lib/python3.7/logging/__init__.py", line 369, in getMessage msg = msg % self.args
I think you want to use this instead
logger.exception("error")
Project currently uses dnspython-1.15.0.dist-info which relies on some soon to be deprecated python cryptography libraries. The project sample should be upgraded to latest DNSpython package 2.10.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.