Deploying node.js lambda with AWS CDK python - node.js

I try to deploy node.js lambda function with CDK python. Unfortunately, I cannot find any tutorials for this combination. Here is what I did.
mkdir hello
cd hello
cdk init app --language python
virtualenv -p python3.7 env
source env/bin/activate
pip install -r requirements.txt
(edit ./app.py and ./code/hello.js)
cdk diff
Then I got the following error. How can I solve this problem?
File "app.py", line 24, in <module>
HelloStack(app, "HelloStack")
File "/home/bitnami/hello/env/lib/python3.7/site-packages/jsii/_runtime.py", line 86, in __call__
inst = super().__call__(*args, **kwargs)
File "app.py", line 20, in __init__
entry="./code/hello.js"
File "/home/bitnami/hello/env/lib/python3.7/site-packages/jsii/_runtime.py", line 86, in __call__
inst = super().__call__(*args, **kwargs)
File "/home/bitnami/hello/env/lib/python3.7/site-packages/aws_cdk/aws_lambda_nodejs/__init__.py", line 1307, in __init__
jsii.create(self.__class__, self, [scope, id, props])
File "/home/bitnami/hello/env/lib/python3.7/site-packages/jsii/_kernel/__init__.py", line 297, in create
for iface in getattr(klass, "__jsii_ifaces__", [])
File "/home/bitnami/hello/env/lib/python3.7/site-packages/jsii/_kernel/providers/process.py", line 344, in create
return self._process.send(request, CreateResponse)
File "/home/bitnami/hello/env/lib/python3.7/site-packages/jsii/_kernel/providers/process.py", line 326, in send
raise JSIIError(resp.error) from JavaScriptError(resp.stack)
jsii.errors.JSIIError: Cannot find a package lock file (`pnpm-lock.yaml`, `yarn.lock` or `package-lock.json`). Please specify it with `depsLockFilePath`.
Here are the files.
app.py
#!/usr/bin/env python3
import os
import aws_cdk as cdk
from aws_cdk import (
# Duration,
Stack,
aws_lambda_nodejs as lamjs,
)
from constructs import Construct
class HelloStack(Stack):
def __init__(self, scope: Construct, construct_id: str, **kwargs) -> None:
super().__init__(scope, construct_id, **kwargs)
helloFn = lamjs.NodejsFunction(
self,"hello",
entry="./code/hello.js"
);
app = cdk.App()
HelloStack(app, "HelloStack")
app.synth()
code/hello.js
exports.handler = async(event, context) => {
return 1;
};
Here is my environment.
cdk --version
2.24.1 (build 585f9ca)
npm --version
6.14.15
--- Update on May 25, 2022 ---
I added the following package.json in the hello directory and ran "npm install".
package.json
{
"name": "hello",
"version": "0.1.0",
"bin": {
"hello": "code/hello.js"
},
"scripts": {
"build": "tsc",
"watch": "tsc -w",
"test": "jest",
"cdk": "cdk"
},
"devDependencies": {
"#types/jest": "^27.5.0",
"#types/node": "10.17.27",
"#types/prettier": "2.6.0",
"jest": "^27.5.1",
"ts-jest": "^27.1.4",
"aws-cdk": "2.24.1",
"ts-node": "^10.7.0",
"typescript": "~3.9.7"
},
"dependencies": {
"aws-cdk-lib": "2.24.1",
"constructs": "^10.0.0",
"source-map-support": "^0.5.21"
}
}
This makes package-lock.json and then I ran "cdk diff". Then I got the following error.
jsii.errors.JavaScriptError:
Error: spawnSync docker ENOMEM
at Object.spawnSync (internal/child_process.js:1077:20)
at Object.spawnSync (child_process.js:776:24)
at dockerExec (/tmp/jsii-kernel-LhoMqm/node_modules/aws-cdk-lib/core/lib/bundling.js:1:4968)
at Function.fromBuild (/tmp/jsii-kernel-LhoMqm/node_modules/aws-cdk-lib/core/lib/bundling.js:1:3553)
at new Bundling (/tmp/jsii-kernel-LhoMqm/node_modules/aws-cdk-lib/aws-lambda-nodejs/lib/bundling.js:1:2057)
at Function.bundle (/tmp/jsii-kernel-LhoMqm/node_modules/aws-cdk-lib/aws-lambda-nodejs/lib/bundling.js:1:2947)
at new NodejsFunction (/tmp/jsii-kernel-LhoMqm/node_modules/aws-cdk-lib/aws-lambda-nodejs/lib/function.js:1:1361)
at /tmp/tmp5utwlvy5/lib/program.js:8420:58
at Kernel._wrapSandboxCode (/tmp/tmp5utwlvy5/lib/program.js:8848:24)
at Kernel._create (/tmp/tmp5utwlvy5/lib/program.js:8420:34)
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "app.py", line 24, in <module>
HelloStack(app, "HelloStack")
File "/home/bitnami/hello/env/lib/python3.7/site-packages/jsii/_runtime.py", line 86, in __call__
inst = super().__call__(*args, **kwargs)
File "app.py", line 20, in __init__
entry="./code/hello.js"
File "/home/bitnami/hello/env/lib/python3.7/site-packages/jsii/_runtime.py", line 86, in __call__
inst = super().__call__(*args, **kwargs)
File "/home/bitnami/hello/env/lib/python3.7/site-packages/aws_cdk/aws_lambda_nodejs/__init__.py", line 1307, in __init__
jsii.create(self.__class__, self, [scope, id, props])
File "/home/bitnami/hello/env/lib/python3.7/site-packages/jsii/_kernel/__init__.py", line 297, in create
for iface in getattr(klass, "__jsii_ifaces__", [])
File "/home/bitnami/hello/env/lib/python3.7/site-packages/jsii/_kernel/providers/process.py", line 344, in create
return self._process.send(request, CreateResponse)
File "/home/bitnami/hello/env/lib/python3.7/site-packages/jsii/_kernel/providers/process.py", line 326, in send
raise JSIIError(resp.error) from JavaScriptError(resp.stack)
jsii.errors.JSIIError: spawnSync docker ENOMEM
How can I solve this issue?

From the docs:
The NodejsFunction requires a dependencies lock file (yarn.lock, pnpm-lock.yaml or package-lock.json). When bundling in a Docker container, the path containing this lock file is used as the source (/asset-input) for the volume mounted in the container.
So you would need your lambda folder to have a lock file in one of the supported formats.

Related

Python Debugger in VS Code: ImportError: /usr/lib/python3.8/lib-dynload/_ctypes.cpython-38-x86_64-linux-gnu.so: undefined symbol: ffi_closure_alloc

While trying to run python debugger in VS Code I run into following error:
(explore) kaykay#kaykay:~/AutoML$ cd /home/kaykay/AutoML ; /usr/bin/env /bin/python3 /home/kaykay/.vscode/extensions/ms-python.python-2022.20.1/pythonFiles/lib/python/debugpy/adapter/../../debugpy/launcher 45431 -- /home/kaykay/AutoML/.vscode/launch.json
/usr/lib/python3/dist-packages/requests/__init__.py:89: RequestsDependencyWarning: urllib3 (1.26.13) or chardet (3.0.4) doesn't match a supported version!
warnings.warn("urllib3 ({}) or chardet ({}) doesn't match a supported "
Traceback (most recent call last):
File "/usr/lib/python3.8/runpy.py", line 194, in _run_module_as_main
return _run_code(code, main_globals, None,
File "/usr/lib/python3.8/runpy.py", line 87, in _run_code
exec(code, run_globals)
File "/home/kaykay/.vscode/extensions/ms-python.python-2022.20.1/pythonFiles/lib/python/debugpy/adapter/../../debugpy/launcher/__main__.py", line 91, in <module>
main()
File "/home/kaykay/.vscode/extensions/ms-python.python-2022.20.1/pythonFiles/lib/python/debugpy/adapter/../../debugpy/launcher/__main__.py", line 18, in main
from debugpy.launcher import debuggee
File "/home/kaykay/.vscode/extensions/ms-python.python-2022.20.1/pythonFiles/lib/python/debugpy/adapter/../../debugpy/launcher/../../debugpy/launcher/debuggee.py", line 6, in <module>
import ctypes
File "/usr/lib/python3.8/ctypes/__init__.py", line 7, in <module>
from _ctypes import Union, Structure, Array
ImportError: /usr/lib/python3.8/lib-dynload/_ctypes.cpython-38-x86_64-linux-gnu.so: undefined symbol: ffi_closure_alloc, version LIBFFI_CLOSURE_7.0
My launch.json looks like this:
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{"name":"Python: Current File","type":"python","request":"launch","program":"${file}","console":"integratedTerminal","justMyCode":true},
{
"name": "Python: Current File",
"type": "python",
"request": "launch",
"program": "${file}",
"console": "integratedTerminal",
"justMyCode": true
}
]
}
I tried updating urllib and chardet to no success. I also tried updating torch and torchvision as suggested here which though looks like a different issue.

InvalidClientTokenId error when trying to access SQS from Celery

When I try to connect to SQS using Celery, I'm not able to. The worker crashes with the following message:
[2022-10-28 14:05:39,237: CRITICAL/MainProcess] Unrecoverable error: ClientError('An error occurred (InvalidClientTokenId) when calling the GetQueueAttributes operation: The security token included in the request is invalid.')
Traceback (most recent call last):
File "/home/aditya/.local/lib/python3.10/site-packages/celery/worker/worker.py", line 203, in start
self.blueprint.start(self)
File "/home/aditya/.local/lib/python3.10/site-packages/celery/bootsteps.py", line 116, in start
step.start(parent)
File "/home/aditya/.local/lib/python3.10/site-packages/celery/bootsteps.py", line 365, in start
return self.obj.start()
File "/home/aditya/.local/lib/python3.10/site-packages/celery/worker/consumer/consumer.py", line 332, in start
blueprint.start(self)
File "/home/aditya/.local/lib/python3.10/site-packages/celery/bootsteps.py", line 116, in start
step.start(parent)
File "/home/aditya/.local/lib/python3.10/site-packages/celery/worker/consumer/tasks.py", line 38, in start
c.task_consumer = c.app.amqp.TaskConsumer(
File "/home/aditya/.local/lib/python3.10/site-packages/celery/app/amqp.py", line 274, in TaskConsumer
return self.Consumer(
File "/home/aditya/.local/lib/python3.10/site-packages/kombu/messaging.py", line 387, in __init__
self.revive(self.channel)
File "/home/aditya/.local/lib/python3.10/site-packages/kombu/messaging.py", line 409, in revive
self.declare()
File "/home/aditya/.local/lib/python3.10/site-packages/kombu/messaging.py", line 422, in declare
queue.declare()
File "/home/aditya/.local/lib/python3.10/site-packages/kombu/entity.py", line 606, in declare
self._create_queue(nowait=nowait, channel=channel)
File "/home/aditya/.local/lib/python3.10/site-packages/kombu/entity.py", line 615, in _create_queue
self.queue_declare(nowait=nowait, passive=False, channel=channel)
File "/home/aditya/.local/lib/python3.10/site-packages/kombu/entity.py", line 643, in queue_declare
ret = channel.queue_declare(
File "/home/aditya/.local/lib/python3.10/site-packages/kombu/transport/virtual/base.py", line 523, in queue_declare
return queue_declare_ok_t(queue, self._size(queue), 0)
File "/home/aditya/.local/lib/python3.10/site-packages/kombu/transport/SQS.py", line 633, in _size
resp = c.get_queue_attributes(
File "/home/aditya/.local/lib/python3.10/site-packages/botocore/client.py", line 514, in _api_call
return self._make_api_call(operation_name, kwargs)
File "/home/aditya/.local/lib/python3.10/site-packages/botocore/client.py", line 938, in _make_api_call
raise error_class(parsed_response, operation_name)
botocore.exceptions.ClientError: An error occurred (InvalidClientTokenId) when calling the GetQueueAttributes operation: The security token included in the request is invalid.
The credentials are correct, and my Cloud Admin insists that my credentials have these permissions.
If it helps, these are in my settings.py :
from urllib.parse import quote
CELERY_BROKER_URL = 'sqs://{access_key}:{secret_key}#'.format(
access_key=quote(env.str("AWS_ACCESS_KEY_ID"), safe=''),
secret_key=quote(env.str("AWS_SECRET_ACCESS_KEY"), safe=''),
)
CELERY_BROKER_TRANSPORT_OPTIONS = {
"region": "us-east-2",
"polling_interval": 60,
'sdb_persistence': False,
"predefined_queues":{
'myq': {
'url': 'https://sqs.us-east-2.amazonaws.com/164782647287/myq',
'access_key_id': env.str("AWS_ACCESS_KEY_ID"),
'secret_access_key': env.str("AWS_SECRET_ACCESS_KEY"),
},
}
}
CELERY_TASK_DEFAULT_QUEUE = 'myq'
I'm using the latest version of Celery and associated dependencies:
celery[sqs]==5.2.7

MongoDB with Django: TypeError: Model instances without primary key value are unhashable

I'm trying to connect MongoDB with Django.
settings.py
DATABASES = {
'default': {
'ENGINE': 'djongo',
'NAME': '<name>',
'ENFORCE_SCHEMA': False,
'CLIENT': {
'host': f'mongodb+srv://{mongodb_username}:{mongodb_password}#{mongodb_cluster}/?retryWrites=true',
'uuidRepresentation': 'standard',
'waitQueueTimeoutMS': 30000
}
}
}
models.py
import uuid
from django.db import models
# Create your models here.
class ModernConnectUsers(models.Model):
user_id = models.UUIDField(primary_key=True, default=uuid.uuid4())
user_name = models.CharField(max_length=30, null=False)
The model has not been used anywhere for now.
python manage.py makemigrations && python manage.py migrate
outputs:
Migrations for 'modern_connect':
modern_connect/migrations/0003_alter_modernconnectusers_user_id.py
- Alter field user_id on modernconnectusers
Operations to perform:
Apply all migrations: admin, auth, contenttypes, modern_connect, sessions
Running migrations:
No migrations to apply.
Your models in app(s): 'modern_connect' have changes that are not yet reflected in a migration, and so won't be applied.
Run 'manage.py makemigrations' to make new migrations, and then re-run 'manage.py migrate' to apply them.
Traceback (most recent call last):
File "manage.py", line 22, in <module>
main()
File "manage.py", line 18, in main
execute_from_command_line(sys.argv)
File "/home/sarvesh/PycharmProjects/modernConnect/venv/lib/python3.8/site-packages/django/core/management/__init__.py", line 446, in execute_from_command_line
utility.execute()
File "/home/sarvesh/PycharmProjects/modernConnect/venv/lib/python3.8/site-packages/django/core/management/__init__.py", line 440, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/home/sarvesh/PycharmProjects/modernConnect/venv/lib/python3.8/site-packages/django/core/management/base.py", line 414, in run_from_argv
self.execute(*args, **cmd_options)
File "/home/sarvesh/PycharmProjects/modernConnect/venv/lib/python3.8/site-packages/django/core/management/base.py", line 460, in execute
output = self.handle(*args, **options)
File "/home/sarvesh/PycharmProjects/modernConnect/venv/lib/python3.8/site-packages/django/core/management/base.py", line 98, in wrapped
res = handle_func(*args, **kwargs)
File "/home/sarvesh/PycharmProjects/modernConnect/venv/lib/python3.8/site-packages/django/core/management/commands/migrate.py", line 317, in handle
emit_post_migrate_signal(
File "/home/sarvesh/PycharmProjects/modernConnect/venv/lib/python3.8/site-packages/django/core/management/sql.py", line 52, in emit_post_migrate_signal
models.signals.post_migrate.send(
File "/home/sarvesh/PycharmProjects/modernConnect/venv/lib/python3.8/site-packages/django/dispatch/dispatcher.py", line 176, in send
return [
File "/home/sarvesh/PycharmProjects/modernConnect/venv/lib/python3.8/site-packages/django/dispatch/dispatcher.py", line 177, in <listcomp>
(receiver, receiver(signal=self, sender=sender, **named))
File "/home/sarvesh/PycharmProjects/modernConnect/venv/lib/python3.8/site-packages/django/contrib/auth/management/__init__.py", line 83, in create_permissions
ctypes.add(ctype)
File "/home/sarvesh/PycharmProjects/modernConnect/venv/lib/python3.8/site-packages/django/db/models/base.py", line 597, in __hash__
raise TypeError("Model instances without primary key value are unhashable")
TypeError: Model instances without primary key value are unhashable
The only collection I'm currently using has a Primary Key, but for some reason - The program is falling for self.pk == None in Base.py which is raising this error. Solutions under other questions didn't help, so starting another question.
In your models.py, try importing the models from djongo.
from djongo import models
And for primary key I use
class User(models.Model):
_id = models.ObjectIdField()
But you can play around with uuid() and see if it works or not.

Error in deploying django app on Google cloud "google.api_core.exceptions.PermissionDenied: 403 Permission denied on resource project "

I am trying to deploy my own django app on google cloud.
I'm following this documentation
by Google Cloud to deploy the app.
I have changed the settings.py file of my app according to the settings.py file of settings.py file of the sample app provided by google and I think this issue is due to some mistake in that setting file or maybe something else. I'm not able to solve the error after lots of attempts.
please help me thank you
Settings.py file
from pathlib import Path
import os
import io
from urllib.parse import urlparse
import environ
from google.cloud import secretmanager
# Build paths inside the project like this: BASE_DIR / 'subdir'.
BASE_DIR = Path(__file__).resolve().parent.parent
# [START gaestd_py_django_secret_config]
env = environ.Env(DEBUG=(bool, False))
env_file = os.path.join(BASE_DIR, ".env")
if os.path.isfile(env_file):
# Use a local secret file, if provided
env.read_env(env_file)
# [START_EXCLUDE]
elif os.getenv("TRAMPOLINE_CI", None):
# Create local settings if running with CI, for unit testing
placeholder = (
f"SECRET_KEY=a\n"
f"DATABASE_URL=sqlite://{os.path.join(BASE_DIR, 'db.sqlite3')}"
)
env.read_env(io.StringIO(placeholder))
# [END_EXCLUDE]
elif os.environ.get("GOOGLE_CLOUD_PROJECT", None):
# Pull secrets from Secret Manager
project_id = os.environ.get("GOOGLE_CLOUD_PROJECT")
client = secretmanager.SecretManagerServiceClient()
settings_name = os.environ.get("SETTINGS_NAME", "django_settings")
name = f"projects/{project_id}/secrets/{settings_name}/versions/latest"
payload = client.access_secret_version(name=name).payload.data.decode("UTF-8")
env.read_env(io.StringIO(payload))
else:
raise Exception("No local .env or GOOGLE_CLOUD_PROJECT detected. No secrets found.")
# [END gaestd_py_django_secret_config]
SECRET_KEY = env("SECRET_KEY")
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = env("DEBUG")
# [START gaestd_py_django_csrf]
# SECURITY WARNING: It's recommended that you use this when
# running in production. The URL will be known once you first deploy
# to App Engine. This code takes the URL and converts it to both these settings formats.
APPENGINE_URL = env("APPENGINE_URL", default=None)
if APPENGINE_URL:
# Ensure a scheme is present in the URL before it's processed.
if not urlparse(APPENGINE_URL).scheme:
APPENGINE_URL = f"https://{APPENGINE_URL}"
ALLOWED_HOSTS = [urlparse(APPENGINE_URL).netloc]
CSRF_TRUSTED_ORIGINS = [APPENGINE_URL]
SECURE_SSL_REDIRECT = True
else:
ALLOWED_HOSTS = ["*"]
# [END gaestd_py_django_csrf]
# Application definition
INSTALLED_APPS = [
'portpolio.apps.PortpolioConfig',
'CRblogs.apps.CrblogsConfig',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'django_social_share',
]
MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
]
ROOT_URLCONF = 'crrathod.urls'
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
],
},
},
]
WSGI_APPLICATION = 'crrathod.wsgi.application'
# Database
# [START db_setup]
# [START gaestd_py_django_database_config]
# Use django-environ to parse the connection string
DATABASES = {"default": env.db()}
# If the flag as been set, configure to use proxy
if os.getenv("USE_CLOUD_SQL_AUTH_PROXY", None):
DATABASES["default"]["HOST"] = "127.0.0.1"
DATABASES["default"]["PORT"] = 8088
# [END gaestd_py_django_database_config]
# [END db_setup]
# Use a in-memory sqlite3 database when testing in CI systems
# TODO(glasnt) CHECK IF THIS IS REQUIRED because we're setting a val above
if os.getenv("TRAMPOLINE_CI", None):
DATABASES = {
"default": {
"ENGINE": "django.db.backends.sqlite3",
"NAME": os.path.join(BASE_DIR, "db.sqlite3"),
}
}
# Password validation
# https://docs.djangoproject.com/en/4.0/ref/settings/#auth-password-validators
AUTH_PASSWORD_VALIDATORS = [
{
'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
},
]
# Internationalization
# https://docs.djangoproject.com/en/4.0/topics/i18n/
LANGUAGE_CODE = 'en-us'
TIME_ZONE = 'UTC'
USE_I18N = True
USE_TZ = True
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/4.0/howto/static-files/
# STATICFILES_DIRS =[
# os.path.join(BASE_DIR, 'static')
# ]
# STATIC_ROOT = os.path.join(BASE_DIR,'assets')
STATIC_URL = 'static/'
MEDIA_URL = '/media/'
if DEBUG:
STATICFILES_DIRS = [os.path.join(BASE_DIR, 'static')]
else:
STATIC_ROOT = os.path.join(BASE_DIR, 'static')
MEDIA_ROOT = os.path.join(BASE_DIR,'media')
# Default primary key field type
# https://docs.djangoproject.com/en/4.0/ref/settings/#default-auto-field
DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
Log file
Traceback (most recent call last):
File "C:\Program Files (x86)\Google\Cloud SDK\Portfolio-blog\env\lib\site-packages\google\api_core\grpc_helpers.py", line 72, in error_remapped_callable
return callable_(*args, **kwargs)
File "C:\Program Files (x86)\Google\Cloud SDK\Portfolio-blog\env\lib\site-packages\grpc\_channel.py", line 946, in __call__
return _end_unary_response_blocking(state, call, False, None)
File "C:\Program Files (x86)\Google\Cloud SDK\Portfolio-blog\env\lib\site-packages\grpc\_channel.py", line 849, in _end_unary_response_blocking
raise _InactiveRpcError(state)
grpc._channel._InactiveRpcError: <_InactiveRpcError of RPC that terminated with:
status = StatusCode.PERMISSION_DENIED
details = "Permission denied on resource project my-portfolio-361305."
debug_error_string = "{"created":"#1662731782.139000000","description":"Error received from peer ipv6:[2404:6800:4009:825::200a]:443","file":"src/core/lib/surface/call.cc","file_line":967,"grpc_message":"Permission denied on resource project my-portfolio-361305.","grpc_status":7}"
>
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "manage.py", line 22, in <module>
main()
File "manage.py", line 18, in main
execute_from_command_line(sys.argv)
File "C:\Program Files (x86)\Google\Cloud SDK\Portfolio-blog\env\lib\site-packages\django\core\management\__init__.py", line 446, in execute_from_command_line
utility.execute()
File "C:\Program Files (x86)\Google\Cloud SDK\Portfolio-blog\env\lib\site-packages\django\core\management\__init__.py", line 386, in execute
settings.INSTALLED_APPS
File "C:\Program Files (x86)\Google\Cloud SDK\Portfolio-blog\env\lib\site-packages\django\conf\__init__.py", line 87, in __getattr__
self._setup(name)
File "C:\Program Files (x86)\Google\Cloud SDK\Portfolio-blog\env\lib\site-packages\django\conf\__init__.py", line 74, in _setup
self._wrapped = Settings(settings_module)
File "C:\Program Files (x86)\Google\Cloud SDK\Portfolio-blog\env\lib\site-packages\django\conf\__init__.py", line 183, in __init__
mod = importlib.import_module(self.SETTINGS_MODULE)
File "C:\Users\LONAR\AppData\Local\Programs\Python\Python38\lib\importlib\__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
File "<frozen importlib._bootstrap>", line 991, in _find_and_load
File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 848, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "C:\Program Files (x86)\Google\Cloud SDK\Portfolio-blog\crrathod\settings.py", line 50, in <module>
payload = client.access_secret_version(name=name).payload.data.decode("UTF-8")
File "C:\Program Files (x86)\Google\Cloud SDK\Portfolio-blog\env\lib\site-packages\google\cloud\secretmanager_v1\services\secret_manager_service\client.py", line 1440, in access_secret_version
response = rpc(
File "C:\Program Files (x86)\Google\Cloud SDK\Portfolio-blog\env\lib\site-packages\google\api_core\gapic_v1\method.py", line 154, in __call__
return wrapped_func(*args, **kwargs)
File "C:\Program Files (x86)\Google\Cloud SDK\Portfolio-blog\env\lib\site-packages\google\api_core\retry.py", line 283, in retry_wrapped_func
return retry_target(
File "C:\Program Files (x86)\Google\Cloud SDK\Portfolio-blog\env\lib\site-packages\google\api_core\retry.py", line 190, in retry_target
return target()
File "C:\Program Files (x86)\Google\Cloud SDK\Portfolio-blog\env\lib\site-packages\google\api_core\grpc_helpers.py", line 74, in error_remapped_callable
raise exceptions.from_grpc_error(exc) from exc
google.api_core.exceptions.PermissionDenied: 403 Permission denied on resource project my-portfolio-361305. [links {
description: "Google developer console API key"
url: "https://console.developers.google.com/project/ my-portfolio-361305/apiui/credential"
}
, reason: "CONSUMER_INVALID"
domain: "googleapis.com"
metadata {
key: "service"
value: "secretmanager.googleapis.com"
}
metadata {
key: "consumer"
value: "projects/ my-portfolio-361305"
}
]
I just shifted from one problem to another. I did some changes here. I have removed space after = from this cmd set GOOGLE_CLOUD_PROJECT=my-portfolio-361305 previously I was using set GOOGLE_CLOUD_PROJECT= my-portfolio-361305 this cmd. Now I have also removed space after = in secret manager file as I read that in some solutions for my new problem Error in deploying Django app on Google cloud using appengine "django.core.exceptions.ImproperlyConfigured: Set the SECRET_KEY environment variable".
I got a solution to that problem as well by running set SECRET_KEY=my_secret_key_value
But now got a new problem as after running python manage.py makemigrations
as
RuntimeWarning: Got an error checking a consistent migration history performed for >database connection 'default': connection to server at "127.0.0.1", port 5432>failed: FATAL: password authentication failed for user "CRRathod"
warnings.warn(
No changes detected
It seems here as I have entered the wrong password. But I check that as well
Thank You!

Azure Web app up giving 'No such file or directory error'

I'm trying to add my Node.js app to azure. I have logged in using the command az login. I ran the command
az webbapp up --name azuredemoapp
This is the error that I'm getting:-
The command failed with an unexpected error. Here is the traceback:
[Errno 2] No such file or directory: ''
Traceback (most recent call last):
File "C:\Users\VSSADM~1\AppData\Local\Temp\pip-install-p8t_6awn\knack\knack\cli.py", line 206, in invoke
File "C:\Users\VSSADM~1\AppData\Local\Temp\pip-install-p8t_6awn\azure-cli-core\azure\cli\core\commands\__init__.py", line 603, in execute
File "C:\Users\VSSADM~1\AppData\Local\Temp\pip-install-p8t_6awn\azure-cli-core\azure\cli\core\commands\__init__.py", line 661, in _run_jobs_serially
File "C:\Users\VSSADM~1\AppData\Local\Temp\pip-install-p8t_6awn\azure-cli-core\azure\cli\core\commands\__init__.py", line 652, in _run_job
File "C:\Users\VSSADM~1\AppData\Local\Temp\pip-install-p8t_6awn\azure-cli\azure\cli\command_modules\appservice\commands.py", line 55, in _polish_bad_errors
File "C:\Users\VSSADM~1\AppData\Local\Temp\pip-install-p8t_6awn\azure-cli-core\azure\cli\core\commands\__init__.py", line 631, in _run_job
File "C:\Users\VSSADM~1\AppData\Local\Temp\pip-install-p8t_6awn\azure-cli-core\azure\cli\core\commands\__init__.py", line 306, in __call__
File "C:\Users\VSSADM~1\AppData\Local\Temp\pip-install-p8t_6awn\azure-cli-core\azure\cli\core\__init__.py", line 485, in default_command_handler
File "C:\Users\VSSADM~1\AppData\Local\Temp\pip-install-p8t_6awn\azure-cli\azure\cli\command_modules\appservice\custom.py", line 2783, in webapp_up
File "C:\Users\VSSADM~1\AppData\Local\Temp\pip-install-p8t_6awn\azure-cli\azure\cli\command_modules\appservice\_create_util.py", line 59, in get_runtime_version_details
File "C:\Users\VSSADM~1\AppData\Local\Temp\pip-install-p8t_6awn\azure-cli\azure\cli\command_modules\appservice\_create_util.py", line 192, in parse_netcore_version
File "C:\Program Files (x86)\Microsoft SDKs\Azure\CLI2\lib\xml\etree\ElementTree.py", line 1196, in parse
tree.parse(source, parser)
File "C:\Program Files (x86)\Microsoft SDKs\Azure\CLI2\lib\xml\etree\ElementTree.py", line 586, in parse
source = open(source, "rb")
FileNotFoundError: [Errno 2] No such file or directory: ''
To open an issue, please run: 'az feedback'
This is My package.json file
{
"name": "azuredemodeploy",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "node index.js"
},
"author": "Rohan Shenoy",
"license": "ISC",
"dependencies": {
"express": "^4.17.1"
}
}
The problem is most likely the way you are deploying your application, or the structure of the files in your project.
Please ensure you have a server.js or app.js in your project root. You can also specify a custom startup script in packages.json. See here for more information:
https://learn.microsoft.com/en-us/azure/app-service/deploy-local-git#prepare-your-repository

Resources