Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions samtranslator/model/api/api_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -515,6 +515,12 @@ def _construct_api_domain(self, rest_api):
record_set_group = None
if self.domain.get("Route53") is not None:
route53 = self.domain.get("Route53")
if not isinstance(route53, dict):
raise InvalidResourceException(
self.logical_id,
"Invalid property type '{}' for Route53. "
"Expected a map defines an Amazon Route 53 configuration'.".format(type(route53).__name__),
)
if route53.get("HostedZoneId") is None and route53.get("HostedZoneName") is None:
raise InvalidResourceException(
self.logical_id,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
Resources:
MyFunction:
Type: AWS::Serverless::Function
Properties:
InlineCode: |
exports.handler = async (event) => {
const response = {
statusCode: 200,
body: JSON.stringify('Hello from Lambda!'),
};
return response;
};
Handler: index.handler
Runtime: nodejs12.x
Events:
Api:
Type: Api
Properties:
RestApiId: !Ref MyApi
Method: Put
Path: /get

MyApi:
Type: AWS::Serverless::Api
Properties:
OpenApiVersion: 3.0.1
StageName: Prod
Domain:
DomainName: 'api-example.com'
CertificateArn: 'my-api-cert-arn'
EndpointConfiguration: 'EDGE'
BasePath: [ "/get"]
Route53: 'InvalidString'
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"errors": [
{
"errorMessage": "Resource with id [MyApi] is invalid. Invalid property type 'Py27UniStr' for Route53. Expected a map defines an Amazon Route 53 configuration'."
}
],
"errorMessage": "Invalid Serverless Application Specification document. Number of errors found: 1. Resource with id [MyApi] is invalid. Invalid property type 'Py27UniStr' for Route53. Expected a map defines an Amazon Route 53 configuration'."
}