aws / aws/chalice

Base Path Mapping: Invalid stage identifier specified when packaging as terraform

Open
#1,557 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
11.1k
Forks
1k
Avg merge
1d 22h
Merged PRs (30d)
2

Description

I'm packaging my chalice app up as terraform config. When I create a new api stage (aws_api_gateway_deployment) and package this up the base path mapping (aws_api_gateway_base_path_mapping) complains that the api stage doesn't exist. The error is `BadRequestException: Invalid stage identifier specified`. It doesn't seem to always do this, the order of import doesn't seem to be consistent. The following is the terraform config generated by the package script:
```
"aws_api_gateway_rest_api": {
"rest_api": {...}
}
"aws_api_gateway_deployment": {
"rest_api": {...}
},
"aws_api_gateway_base_path_mapping": {
"api_gateway_custom_domain_mapping": {
"stage_name": "new_stage_name",
"domain_name": "${var.app_domain}",
"api_id": "${aws_api_gateway_rest_api.rest_api.id}"
}
}
```

I had to add a dependency to make this work, this isn't added by the chalice packaging script but it seems like it should be. The base path mapping does apparently depend on the api stage existing...
```
"aws_api_gateway_base_path_mapping": {
"api_gateway_custom_domain_mapping": {
"stage_name": "new_stage_name",
"domain_name": "${var.app_domain}",
"api_id": "${aws_api_gateway_rest_api.rest_api.id}",
"depends_on": ["aws_api_gateway_deployment.rest_api"]
}
}
```

Contributor guide

Open the contributing guide

Research direction

Start at the Chalice package script that generates the Terraform resources shown in the issue, and inspect how aws_api_gateway_base_path_mapping is emitted relative to aws_api_gateway_deployment. Reproduce packaging with a new API stage and verify that the generated mapping includes the deployment dependency and applies without the invalid stage identifier error.

Written by the indexing model from the issue text.

Assessment

Tech stack
aws, python, terraform
Domain
api, cloud, infrastructure
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.