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

API mappings not generated for custom domain #565

Open
prizos opened this issue Dec 22, 2016 · 11 comments
Open

API mappings not generated for custom domain #565

prizos opened this issue Dec 22, 2016 · 11 comments

Comments

@prizos
Copy link

prizos commented Dec 22, 2016

I am having issues with the API mappings for a custom domain, it appears that it is not generating them after a undeploy / deploy cycle.

I haven't dug too deeply into the details as I am a relatively new user, here is the configuration, I will update if I dig more.

{
"dev": {
"app_function": "example.app",
"s3_bucket": "zappa-example",
"lets_encrypt_key": "s3://zappa-example/account.key",
"domain": "api.example.io",
"timeout_seconds": 120,
"delete_local_zip": false,
"lets_encrypt_expression": "rate(15 days)",
"remote_env": "s3://zappa-example/secret-config.json"
}
}

@Miserlou
Copy link
Owner

Can you be more specific about what the problem is?

@prizos
Copy link
Author

prizos commented Dec 22, 2016

API Mappings under API gateway custom domain do not get generated at all, resulting in forbidden results when trying to use the service via the custom domain.

@prizos
Copy link
Author

prizos commented Dec 22, 2016

A bit more detail, now the stack thinks it is still deployed, however no resources of it exist after the last deploy.

First undeploy succeeded, I didn't retain the logs, after that this happens, perhaps boto caching? :

Calling undeploy for environment dev..
Are you sure you want to undeploy? [y/n] y
Deleting API Gateway..
ERROR:Could not get API ID.
Traceback (most recent call last):
File "/home/prizos/PycharmProjects/example/venv/local/lib/python2.7/site-packages/zappa/zappa.py", line 1328, in get_api_id
LogicalResourceId='Api')
File "/home/prizos/PycharmProjects/example/venv/local/lib/python2.7/site-packages/botocore/client.py", line 251, in _api_call
return self._make_api_call(operation_name, kwargs)
File "/home/prizos/PycharmProjects/example/venv/local/lib/python2.7/site-packages/botocore/client.py", line 537, in _make_api_call
raise ClientError(parsed_response, operation_name)
ClientError: An error occurred (ValidationError) when calling the DescribeStackResource operation: Stack 'example-dev' does not exist
No Zappa stack named example-dev
Error: Function does not exist, you should deploy first. Ex: zappa deploy dev. Proceeding to unschedule CloudWatch based events.
(venv) prizos@prizos-desktop:~/PycharmProjects/example$ zappa deploy
Calling deploy for environment dev..
Error: This application is already deployed - did you mean to call update?

@nowyasimi
Copy link

I've also run into this issue and my workaround has been to manually create a base path mapping in the AWS console every time I deploy. Is this because the base path mapping is only created when zappa certify stage_name is called? In my case, I don't use zappa certify because my custom domain does not use Let's Encrypt.

Can we create the base path mapping during deployment if the custom domain name has already been added to API Gateway?

@evivares
Copy link

We have the same challenge. We'd like to be able to deploy with an endpoint that looks something like https://api.example.io/stage_name/service_name/version_number or https://api.example.io/dev/register/v1

@Miserlou
Copy link
Owner

Honestly Zappa really isn't intended to be used that way - you should do https://dev.example.io/register/ and https://prod.example.io/register/ , etc. Unless there's something I'm missing here.

@gricey432
Copy link
Contributor

I just spent some time wondering why my thing wasn't working and I think it's the same issue.
I want my API to be on api.example.com/dev, api.example.com/v1 etc
If I map my custom domain with a base path, it doesn't work at all, but it works fine with the root path mapping.

@gricey432
Copy link
Contributor

gricey432 commented Jun 19, 2017

I think a workaround for this is changing https://github.com/Miserlou/Zappa/blob/master/zappa/wsgi.py#L75 to

path = urls.url_unquote("/" + params['proxy'])

However I'm not sure enough this will work in all cases to put in a PR. Thoughts?

@madeddie
Copy link
Contributor

#1543 might fix some of the problems in this issue

@tbjornli
Copy link

So we have a similar problem that maybe someone can help us resolve.

We want to be able to use a custom domain that persists after redeploying in order to avoid having to manually update the domain wherever it's in use.

Everything works fine if we start from scratch by running zappa deploy and then zappa certify.
A custom domain is added and we are provided with a Target Domain Name (let's say somerandomstring.cloudfront.net for the sake of this example).

We can then point our CNAME custom.domain.tld to somerandomstring.cloudfront.net and voilá the world is a beautiful place.
However, if we want to redeploy by running zappa undeploy and then zappa deploy the custom domain persists, which is nice, but the Base Path Mappings has been removed. We then have to manually edit the mappings to point to the newly deployed application.

Is there way to solve this?
In short, we want to be able to redeploy without having to update the CNAME.

@mberledgylabs
Copy link

@tbjornli I had a similar issue. I believe you need to deploy to custom domain with zappa to make it persist after redeploy (see here). If your domain wasn't created through AWS, the easiest way would be to create an intermediate domain which is managed by AWS.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants