chalice icon indicating copy to clipboard operation
chalice copied to clipboard

ValueError: Resource does not exist: api_gateway_custom_domain

Open thedonut opened this issue 3 years ago • 4 comments

Hello,

I've got a fairly simple app/API going here but when trying to use the custom domain portion of Chalice I get the error noted in the subject of this post. My configuration is fairly simple, and I've tried literally copying the documented example on both the Chalice docs and the AWS doc examples and simply replacing the domain and the certificate ARN and have had absolutely no joy.

{
"app_name": "xxxxx",
    "environment_variables": {
      "ddb_table": "xxxx"
    },
    "api_gateway_stage": "api",
    "autogen_policy": true, 
    "stages": {
      "dev": {
        "tags": {
          "Stage":"DEV"
        }
      },
      "prod": {
        "api_gateway_custom_domain": {
          "domain_name": "xxxx",
          "certificate_arn": "xxxx"
        },
        "tags": {
          "Stage":"PRD"
        }        
      }
    }
  }

Any ideas what might be causing this? The domain and cert are configured correctly (and I've tested manually configuring them in the AWS console and all works fine). This is running on my local machine in a virtual env, deployments and deployed folder exist and working as normal.

thedonut avatar Dec 02 '21 08:12 thedonut

Can I get the full stack trace for the error? That message would suggest that we're trying to lookup the deployed values for the custom domain but that aren't in the .chalice/ directory. It's possible you might have gotten into a weird state if you had a previous deployment fail, but I wouldn't expect the error you're seeing to surface. Any additional details you can provide for a repro would be helpful.

jamesls avatar Dec 08 '21 21:12 jamesls

Sure.

Traceback (most recent call last):
  File "/home/thedonut/.local/lib/python3.8/site-packages/chalice/config.py", line 501, in resource_values
    return self._deployed_values_by_name[name]
KeyError: 'api_gateway_custom_domain'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/thedonut/.local/lib/python3.8/site-packages/chalice/deploy/planner.py", line 41, in resource_deployed_values
    return self._deployed_resources.resource_values(
  File "/home/thedonut/.local/lib/python3.8/site-packages/chalice/config.py", line 503, in resource_values
    raise ValueError("Resource does not exist: %s" % name)
ValueError: Resource does not exist: api_gateway_custom_domain

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/thedonut/.local/lib/python3.8/site-packages/chalice/cli/__init__.py", line 636, in main
    return cli(obj={})
  File "/usr/lib/python3/dist-packages/click/core.py", line 764, in __call__
    return self.main(*args, **kwargs)
  File "/usr/lib/python3/dist-packages/click/core.py", line 717, in main
    rv = self.invoke(ctx)
  File "/usr/lib/python3/dist-packages/click/core.py", line 1137, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/lib/python3/dist-packages/click/core.py", line 956, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/lib/python3/dist-packages/click/core.py", line 555, in invoke
    return callback(*args, **kwargs)
  File "/usr/lib/python3/dist-packages/click/decorators.py", line 17, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/home/thedonut/.local/lib/python3.8/site-packages/chalice/cli/__init__.py", line 189, in deploy
    deployed_values = d.deploy(config, chalice_stage_name=stage)
  File "/home/thedonut/.local/lib/python3.8/site-packages/chalice/deploy/deployer.py", line 376, in deploy
    return self._deploy(config, chalice_stage_name)
  File "/home/thedonut/.local/lib/python3.8/site-packages/chalice/deploy/deployer.py", line 390, in _deploy
    plan = self._plan_stage.execute(resources)
  File "/home/thedonut/.local/lib/python3.8/site-packages/chalice/deploy/planner.py", line 206, in execute
    result = handler(resource)
  File "/home/thedonut/.local/lib/python3.8/site-packages/chalice/deploy/planner.py", line 1307, in _plan_restapi
    custom_domain_plan = self._add_custom_domain_plan(
  File "/home/thedonut/.local/lib/python3.8/site-packages/chalice/deploy/planner.py", line 1320, in _add_custom_domain_plan
    api_mapping_plan = self._add_apimapping_plan(
  File "/home/thedonut/.local/lib/python3.8/site-packages/chalice/deploy/planner.py", line 278, in _add_apimapping_plan
    deployed = self._remote_state.resource_deployed_values(
  File "/home/thedonut/.local/lib/python3.8/site-packages/chalice/deploy/planner.py", line 44, in resource_deployed_values
    return self._dynamically_lookup_values(resource)
  File "/home/thedonut/.local/lib/python3.8/site-packages/chalice/deploy/planner.py", line 56, in _dynamically_lookup_values
    raise ValueError("Deployed values for resource does not exist: %s"
ValueError: Deployed values for resource does not exist: api_gateway_custom_domain

thedonut avatar Dec 14 '21 11:12 thedonut

I'm having the same issue using chalice 1.27.1 and a custom domain: ValueError: Deployed values for resource does not exist: api_gateway_custom_domain. I deployed the initial function using an older version and if I remove the api_gateway_custom_domain from config.json deploy is successful. However, with the tag in config.json no deployment.

ccascante87 avatar Jun 23 '22 15:06 ccascante87

happens to me also, same exact configuration in 'dev' instead of 'prod' stage manages to deploy successfully

eliyaba avatar Jul 04 '22 10:07 eliyaba

I think I am having the same problem, though I've tried to use a custom domain for both dev and prod stages, with a different "dev" and "prod" url_prefix. everything works fine for the dev stage but when I try to 'chalice deploy --stage prod' I get the "ValueError: Deployed values for resource does not exist: api_gateway_custom_domain" error. I am running both deploys from the same place (my dev environment) so this isn't the CI/CD, missing deployments folder issue

aimlessadam avatar Mar 01 '23 17:03 aimlessadam