Search code examples
amazon-web-servicesboto3aws-glue

Not able to establish boto3 client from inside glue job


I have a python glueetl job where I am trying to call multiple AWS services. One of these services is appconfig. Per the boto3 docs, we are supposed to use the appconfigdata client to establish a session and poll for updated config. https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/appconfigdata.html

However, when I try to do this within my glue job, I get an error:

UnknownServiceError: Unknown service: 'appconfigdata'. Valid service names are: accessanalyzer, ...

The strangest part is that outside of the glue job, when I run the exact same code on my local machine, it works fine. The code is basically

def fetch_appconfig():
    client = boto3.client('appconfigdata', region_name='us-east-1')
    start_session_response = client.start_configuration_session(
        ApplicationIdentifier="myappname",
        EnvironmentIdentifier="myenvname",
        ConfigurationProfileIdentifier="config_name",
    )
    configuration_token = start_session_response["InitialConfigurationToken"]
    configuration_response = client.get_latest_configuration(
        ConfigurationToken=configuration_token
    )
    config_json = (
        json.loads(configuration_response["Configuration"].read().decode("utf-8"))
    )
    client.close()
    print(config_json)

Why does this code fail in my glue job with the strange error but not outside?


Solution

  • The issue here was that my boto3 version in my glue job was outdated - as pointed out by others in the comments. To fix this, I manually installed the version of boto3 I wanted using:

    '--additional-python-modules': 'boto3>=1.28',
    

    in the glue configuration.