AWS lambda Gcp Sdk 사용시 import 에러
aws lambda에서 GCP SDK를 사용 할 때
위 사진과 같은 에러가 발생 할 수 있다.
file_cache is unavailable when using oauth2client >= 4.0.0 or google-auth
Traceback (most recent call last):
File "/opt/python/googleapiclient/discovery_cache/__init__.py", line 36, in autodetect
from google.appengine.api import memcache
ModuleNotFoundError: No module named 'google.appengine'
Traceback (most recent call last):
File "/opt/python/googleapiclient/discovery_cache/file_cache.py", line 33, in
from oauth2client.contrib.locked_file import LockedFile
ModuleNotFoundError: No module named 'oauth2client.contrib.locked_file'
Traceback (most recent call last):
File "/opt/python/googleapiclient/discovery_cache/file_cache.py", line 37, in
from oauth2client.locked_file import LockedFile
ModuleNotFoundError: No module named 'oauth2client.locked_file'
등에러가 발생할 수 있는데 이 에러는 GCP SDK를 쓰는 과정에서
discovery.build ('dns', 'v1', credentials=credentials)
이 부분에서 발생하는 문제인데
다음과 같이 수정해주면 된다
discovery.build ('dns', 'v1', credentials=credentials, cache_discovery=False)