Zappa icon indicating copy to clipboard operation
Zappa copied to clipboard

zappa certify → AttributeError: 'NoneType' object has no attribute 'split'

Open simsong opened this issue 2 years ago • 6 comments

I'm trying to set up zappa to use a private domain (aws-lambda.digitalcorpora.org). My zappa_settings.json file (below) specifies us-west-2 as the region, although I have put the certificate in both us-west-2 and in us-east-1 (since Zappa didn't like the cert in the us-west-2 region). zappa certify produces a stack trace.

zappa_settings.json:

Stack trace:

(venv) simsong@Simsons-MacBook-Pro digitalcorpora_app % zappa certify                                          (bottle-dev)digitalcorpora_app
Calling certify for stage production..
Are you sure you want to certify? [y/n] y
Certifying domain aws-lambda.digitalcorpora.org..
Oh no! An error occurred! :(

==============

Traceback (most recent call last):
  File "/Users/simsong/gits/digitalcorpora_app/venv/lib/python3.9/site-packages/zappa/cli.py", line 3046, in handle
    sys.exit(cli.handle())
  File "/Users/simsong/gits/digitalcorpora_app/venv/lib/python3.9/site-packages/zappa/cli.py", line 520, in handle
    self.dispatch_command(self.command, stage)
  File "/Users/simsong/gits/digitalcorpora_app/venv/lib/python3.9/site-packages/zappa/cli.py", line 631, in dispatch_command
    self.certify(no_confirm=self.vargs["yes"], manual=self.vargs["manual"])
  File "/Users/simsong/gits/digitalcorpora_app/venv/lib/python3.9/site-packages/zappa/cli.py", line 2069, in certify
    self.zappa.update_route53_records(self.domain, dns_name)
  File "/Users/simsong/gits/digitalcorpora_app/venv/lib/python3.9/site-packages/zappa/core.py", line 2509, in update_route53_records
    is_apex = self.route53.get_hosted_zone(Id=zone_id)["HostedZone"]["Name"][:-1] == domain_name
  File "/Users/simsong/gits/digitalcorpora_app/venv/lib/python3.9/site-packages/botocore/client.py", line 553, in _api_call
    return self._make_api_call(operation_name, kwargs)
  File "/Users/simsong/gits/digitalcorpora_app/venv/lib/python3.9/site-packages/botocore/client.py", line 946, in _make_api_call
    api_params = self._emit_api_params(
  File "/Users/simsong/gits/digitalcorpora_app/venv/lib/python3.9/site-packages/botocore/client.py", line 1072, in _emit_api_params
    self.meta.events.emit(
  File "/Users/simsong/gits/digitalcorpora_app/venv/lib/python3.9/site-packages/botocore/hooks.py", line 412, in emit
    return self._emitter.emit(aliased_event_name, **kwargs)
  File "/Users/simsong/gits/digitalcorpora_app/venv/lib/python3.9/site-packages/botocore/hooks.py", line 256, in emit
    return self._emit(event_name, kwargs)
  File "/Users/simsong/gits/digitalcorpora_app/venv/lib/python3.9/site-packages/botocore/hooks.py", line 239, in _emit
    response = handler(**kwargs)
  File "/Users/simsong/gits/digitalcorpora_app/venv/lib/python3.9/site-packages/botocore/handlers.py", line 653, in fix_route53_ids
    params[name] = orig_value.split('/')[-1]
AttributeError: 'NoneType' object has no attribute 'split'

==============

Need help? Found a bug? Let us know! :D
File bug reports on GitHub here: https://github.com/Zappa/Zappa
And join our Slack channel here: https://zappateam.slack.com
Love!,
 ~ Team Zappa!
  • Using Python 3.9 in a virtual environment

Expected Behavior

It should certify.

Actual Behavior

Stack trace.

Possible Fix

Right now the aws-lambda.digitalcorpora.org doesn't exist. I just made this a CNAME to ck9qrzfy5l.execute-api.us-west-2.amazonaws.com which is my service address for the lambda (which is working). The instructions at https://github.com/zappa/Zappa don't mention what I should do regarding DNS, BTW.

Your Environment

  • Zappa version used: (oddly, there is now zappa version command.) 0.58.0
  • Operating System and Python version: MacOS 3.9.18
  • The output of pip freeze:
(venv) simsong@Simsons-MacBook-Pro digitalcorpora_app % pip freeze                                             (bottle-dev)digitalcorpora_app
argcomplete==3.2.2
astroid==3.0.3
beautifulsoup4==4.12.3
blinker==1.7.0
boddle==0.2.9
boto3==1.34.36
botocore==1.34.36
bottle==0.12.25
certifi==2024.2.2
cfn-flip==1.3.0
charset-normalizer==3.3.2
click==8.1.7
coverage==7.4.1
dill==0.3.8
durationpy==0.6
exceptiongroup==1.2.0
filetype==1.2.0
Flask==3.0.2
hjson==3.1.0
idna==3.6
importlib-metadata==7.0.1
iniconfig==2.0.0
isort==5.13.2
itsdangerous==2.1.2
Jinja2==3.1.3
jmespath==1.0.1
kappa==0.6.0
Markdown==3.5.2
MarkupSafe==2.1.5
mccabe==0.7.0
mistune==3.0.2
packaging==23.2
placebo==0.9.0
platformdirs==4.2.0
pluggy==1.4.0
pylint==3.0.3
PyMySQL==1.1.0
pytest==8.0.0
pytest-cov==4.1.0
pytest-env==1.1.3
pytest-flask==1.3.0
python-dateutil==2.8.2
python-magic==0.4.27
python-slugify==8.0.3
PyYAML==6.0.1
requests==2.31.0
s3transfer==0.10.0
six==1.16.0
soupsieve==2.5
text-unidecode==1.3
toml==0.10.2
tomli==2.0.1
tomlkit==0.12.3
tqdm==4.66.1
troposphere==4.6.0
typing_extensions==4.9.0
urllib3==1.26.18
waitress==3.0.0
WebOb==1.8.7
WebTest==3.0.0
Werkzeug==3.0.1
zappa==0.58.0
zipp==3.17.0
  • Link to your project (optional): https://github.com/digitalcorpora/digitalcorpora_app
  • Your zappa_settings.json:
{
    "production": {
        "app_function": "bottle_app.app",
        "aws_region": "us-west-2",
        "profile_name": "default",
        "project_name": "digitalcorpora-",
        "runtime": "python3.9",
        "timeout_seconds": 300,
        "domain":"aws-lambda.digitalcorpora.org",
        "certificate_arn": "arn:aws:acm:us-east-1:376778049323:certificate/f705638d-a61f-430d-b32e-3bf0d2cbcd5a",
        "s3_bucket": "zappa-a3nprn138"
        "environment_variables": {
            "AWS": "YES"
        }
    }
}

simsong avatar Feb 07 '24 12:02 simsong

I created the DNS name and I'm getting the same error:

(venv) simsong@Simsons-MacBook-Pro digitalcorpora_app % zappa certify                                          (bottle-dev)digitalcorpora_app
Calling certify for stage production..
Are you sure you want to certify? [y/n] y
Certifying domain aws-lambda.digitalcorpora.org..
Oh no! An error occurred! :(

==============

Traceback (most recent call last):
  File "/Users/simsong/gits/digitalcorpora_app/venv/lib/python3.9/site-packages/zappa/cli.py", line 3046, in handle
    sys.exit(cli.handle())
  File "/Users/simsong/gits/digitalcorpora_app/venv/lib/python3.9/site-packages/zappa/cli.py", line 520, in handle
    self.dispatch_command(self.command, stage)
  File "/Users/simsong/gits/digitalcorpora_app/venv/lib/python3.9/site-packages/zappa/cli.py", line 631, in dispatch_command
    self.certify(no_confirm=self.vargs["yes"], manual=self.vargs["manual"])
  File "/Users/simsong/gits/digitalcorpora_app/venv/lib/python3.9/site-packages/zappa/cli.py", line 2057, in certify
    dns_name = self.zappa.create_domain_name(
  File "/Users/simsong/gits/digitalcorpora_app/venv/lib/python3.9/site-packages/zappa/core.py", line 2484, in create_domain_name
    agw_response = self.apigateway_client.create_domain_name(
  File "/Users/simsong/gits/digitalcorpora_app/venv/lib/python3.9/site-packages/botocore/client.py", line 553, in _api_call
    return self._make_api_call(operation_name, kwargs)
  File "/Users/simsong/gits/digitalcorpora_app/venv/lib/python3.9/site-packages/botocore/client.py", line 1009, in _make_api_call
    raise error_class(parsed_response, operation_name)
botocore.errorfactory.BadRequestException: An error occurred (BadRequestException) when calling the CreateDomainName operation: The domain name you provided already exists.

==============

Need help? Found a bug? Let us know! :D
File bug reports on GitHub here: https://github.com/Zappa/Zappa
And join our Slack channel here: https://zappateam.slack.com
Love!,
 ~ Team Zappa!
(venv) simsong@Simsons-MacBook-Pro digitalcorpora_app % host aws-lambda.digitalcorpora.org                     (bottle-dev)digitalcorpora_app
aws-lambda.digitalcorpora.org is an alias for ck9qrzfy5l.execute-api.us-west-2.amazonaws.com.
ck9qrzfy5l.execute-api.us-west-2.amazonaws.com has address 18.161.34.81
ck9qrzfy5l.execute-api.us-west-2.amazonaws.com has address 18.161.34.11
ck9qrzfy5l.execute-api.us-west-2.amazonaws.com has address 18.161.34.107
ck9qrzfy5l.execute-api.us-west-2.amazonaws.com has address 18.161.34.70
(venv) simsong@Simsons-MacBook-Pro digitalcorpora_app %

simsong avatar Feb 07 '24 12:02 simsong

Curiously, even though I got an error, it works! https://aws-lambda.digitalcorpora.org/

simsong avatar Feb 07 '24 12:02 simsong

Update: if you are using AWS certificate manager but not using route53, this needs to be added to the json file:

        "route53_enabled" : false,

I added that, and now it works:

(venv) simsong@Simsons-MacBook-Pro digitalcorpora_app % zappa certify production                                                                                                         (bottle-dev)digitalcorpora_app
Calling certify for stage production..
Are you sure you want to certify? [y/n] y
Certifying domain app.digitalcorpora.org..
Created a new domain name with supplied certificate. Please note that it can take up to 40 minutes for this domain to be created and propagated through AWS, but it requires no further work on your part.
Certificate updated!
(venv) simsong@Simsons-MacBook-Pro digitalcorpora_app %                                                                                                                                  (bottle-dev)digitalcorpora_app

But another domain is giving this error:

(venv) simsong@Simsons-MacBook-Pro webapp % zappa certify demo                                                                         (dev-lambda)webapp
Calling certify for stage demo..
Are you sure you want to certify? [y/n] y
Certifying domain demo.planttracer.com..
Oh no! An error occurred! :(

==============

Traceback (most recent call last):
  File "/Users/simsong/gits/webapp/venv/lib/python3.11/site-packages/zappa/cli.py", line 3046, in handle
    sys.exit(cli.handle())
             ^^^^^^^^^^^^
  File "/Users/simsong/gits/webapp/venv/lib/python3.11/site-packages/zappa/cli.py", line 520, in handle
    self.dispatch_command(self.command, stage)
  File "/Users/simsong/gits/webapp/venv/lib/python3.11/site-packages/zappa/cli.py", line 631, in dispatch_command
    self.certify(no_confirm=self.vargs["yes"], manual=self.vargs["manual"])
  File "/Users/simsong/gits/webapp/venv/lib/python3.11/site-packages/zappa/cli.py", line 2057, in certify
    dns_name = self.zappa.create_domain_name(
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/simsong/gits/webapp/venv/lib/python3.11/site-packages/zappa/core.py", line 2484, in create_domain_name
    agw_response = self.apigateway_client.create_domain_name(
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/simsong/gits/webapp/venv/lib/python3.11/site-packages/botocore/client.py", line 553, in _api_call
    return self._make_api_call(operation_name, kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/simsong/gits/webapp/venv/lib/python3.11/site-packages/botocore/client.py", line 1009, in _make_api_call
    raise error_class(parsed_response, operation_name)
botocore.errorfactory.BadRequestException: An error occurred (BadRequestException) when calling the CreateDomainName operation: The domain name you provided already exists.

==============

Need help? Found a bug? Let us know! :D
File bug reports on GitHub here: https://github.com/Zappa/Zappa
And join our Slack channel here: https://zappateam.slack.com
Love!,
 ~ Team Zappa!
(venv) simsong@Simsons-MacBook-Pro webapp %                                                                                            (dev-lambda)webapp

However, even though I got the error, the system is now working.

simsong avatar Feb 13 '24 01:02 simsong

I haven't used the certify or domain features.
It appears that we need better documentation, and clearer error messages/handling around this.

monkut avatar Feb 15 '24 02:02 monkut

I will give you a PR with marginally improved documentation. I haven't figured out enough to understand why I'm sometimes getting errors and sometimes not getting errors. It's confusing.

simsong avatar Feb 15 '24 02:02 simsong

Hi there! Unfortunately, this Issue has not seen any activity for at least 90 days. If the Issue is still relevant to the latest version of Zappa, please comment within the next 10 days if you wish to keep it open. Otherwise, it will be automatically closed.

github-actions[bot] avatar May 15 '24 02:05 github-actions[bot]

Hi there! Unfortunately, this Issue was automatically closed as it had not seen any activity in at least 100 days. If the Issue is still relevant to the latest version of Zappa, please open a new Issue.

github-actions[bot] avatar May 25 '24 03:05 github-actions[bot]