Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
simsong opened this issue Feb 7, 2024 · 7 comments
Closed
Labels
auto-closed [Bot] Closed, details in comments no-activity [Bot] Closing soon if no new activity

Comments

@simsong
Copy link

simsong commented Feb 7, 2024

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
{
    "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
Copy link
Author

simsong commented Feb 7, 2024

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
Copy link
Author

simsong commented Feb 7, 2024

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

@simsong
Copy link
Author

simsong commented Feb 13, 2024

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.

@monkut
Copy link
Collaborator

monkut commented Feb 15, 2024

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

@simsong
Copy link
Author

simsong commented Feb 15, 2024

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 simsong mentioned this issue Feb 19, 2024
Copy link

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 github-actions bot added the no-activity [Bot] Closing soon if no new activity label May 15, 2024
Copy link

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 github-actions bot added the auto-closed [Bot] Closed, details in comments label May 25, 2024
@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale May 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
auto-closed [Bot] Closed, details in comments no-activity [Bot] Closing soon if no new activity
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants