You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am calling a method in my startup_fn() that queries instance metadata to get the region. I use the region to create global environment variables for boto3 clients like ec2 and eks. When the code runs, I get an error that the region must be set. How should I handle this?
Here is the code I'm using in my startup_fn():
@kopf.on.startup()
async def startup_fn(logger, **kwarg):
global region, eks, ec2, iam, cluster_name
cluster_name, region = get_metadata()
eks = client('eks', region_name=region)
ec2 = client('ec2', region_name=region)
iam = resource('iam')
Checklist
[ x] I have read the documentation and searched there for the problem
[ x] I have searched in the GitHub Issues for similar questions
When I moved the variable declarations out of the handler, it worked. I wanted to do it as part of the setup handler; I'm using the HTTP request library to call ec2 metadata: get_metadata(). I didn't want the operator to start until the region was set.
nolar I will have to move the code back to the startup handler to get the trace. It basically said that the region was not set when it when I referenced the variables in the create handler.
The text was updated successfully, but these errors were encountered:
Question
I am calling a method in my startup_fn() that queries instance metadata to get the region. I use the region to create global environment variables for boto3 clients like ec2 and eks. When the code runs, I get an error that the region must be set. How should I handle this?
Here is the code I'm using in my startup_fn():
Checklist
Keywords
When I moved the variable declarations out of the handler, it worked. I wanted to do it as part of the setup handler; I'm using the HTTP request library to call ec2 metadata:
get_metadata()
. I didn't want the operator to start until the region was set.Can you please show the error and its stack trace?
nolar I will have to move the code back to the startup handler to get the trace. It basically said that the region was not set when it when I referenced the variables in the create handler.
The text was updated successfully, but these errors were encountered: