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
1 change: 1 addition & 0 deletions examples/2016-10-31/http_api_cors/template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ Resources:
MyApi:
Type: AWS::Serverless::HttpApi
Properties:
FailOnWarnings: true
CorsConfiguration:
AllowHeaders:
- x-apigateway-header
Expand Down
5 changes: 5 additions & 0 deletions samtranslator/model/api/http_api_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ def __init__(
resource_attributes=None,
passthrough_resource_attributes=None,
domain=None,
fail_on_warnings=False,
):
"""Constructs an API Generator class that generates API Gateway resources

Expand Down Expand Up @@ -79,6 +80,7 @@ def __init__(
self.resource_attributes = resource_attributes
self.passthrough_resource_attributes = passthrough_resource_attributes
self.domain = domain
self.fail_on_warnings = fail_on_warnings

def _construct_http_api(self):
"""Constructs and returns the ApiGatewayV2 HttpApi.
Expand All @@ -99,6 +101,9 @@ def _construct_http_api(self):
self._add_auth()
self._add_tags()

if self.fail_on_warnings:
http_api.FailOnWarnings = self.fail_on_warnings

if self.definition_uri:
http_api.BodyS3Location = self._construct_body_s3_dict()
elif self.definition_body:
Expand Down
2 changes: 2 additions & 0 deletions samtranslator/model/sam_resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -878,6 +878,7 @@ class SamHttpApi(SamResourceMacro):
"Auth": PropertyType(False, is_type(dict)),
"RouteSettings": PropertyType(False, is_type(dict)),
"Domain": PropertyType(False, is_type(dict)),
"FailOnWarnings": PropertyType(False, is_type(bool)),
}

referable_properties = {
Expand Down Expand Up @@ -916,6 +917,7 @@ def to_cloudformation(self, **kwargs):
resource_attributes=self.resource_attributes,
passthrough_resource_attributes=self.get_passthrough_resource_attributes(),
domain=self.Domain,
fail_on_warnings=self.FailOnWarnings,
)

(http_api, stage, domain, basepath_mapping, route53,) = api_generator.to_cloudformation()
Expand Down
1 change: 1 addition & 0 deletions samtranslator/plugins/globals/globals.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ class Globals(object):
"DefaultRouteSettings",
"Domain",
"RouteSettings",
"FailOnWarnings",
],
SamResourceType.SimpleTable.value: ["SSESpecification"],
}
Expand Down
1 change: 1 addition & 0 deletions tests/translator/input/explicit_http_api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ Resources:
MyApi:
Type: AWS::Serverless::HttpApi
Properties:
FailOnWarnings: True
Auth:
Authorizers:
OAuth2:
Expand Down
1 change: 1 addition & 0 deletions tests/translator/input/http_api_explicit_stage.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ Globals:
"$default":
DataTraceEnabled: True
ThrottlingBurstLimit: 100
FailOnWarnings: true
Resources:
HttpApiFunction:
Type: AWS::Serverless::Function
Expand Down
1 change: 1 addition & 0 deletions tests/translator/output/aws-cn/explicit_http_api.json
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,7 @@
"MyApi": {
"Type": "AWS::ApiGatewayV2::Api",
"Properties": {
"FailOnWarnings": true,
"Body": {
"info": {
"version": "1.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@
"MyApi": {
"Type": "AWS::ApiGatewayV2::Api",
"Properties": {
"FailOnWarnings": true,
"Body": {
"info": {
"version": "1.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,7 @@
"MyApi": {
"Type": "AWS::ApiGatewayV2::Api",
"Properties": {
"FailOnWarnings": true,
"Body": {
"info": {
"version": "1.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@
"MyApi": {
"Type": "AWS::ApiGatewayV2::Api",
"Properties": {
"FailOnWarnings": true,
"Body": {
"info": {
"version": "1.0",
Expand Down
1 change: 1 addition & 0 deletions tests/translator/output/explicit_http_api.json
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,7 @@
"MyApi": {
"Type": "AWS::ApiGatewayV2::Api",
"Properties": {
"FailOnWarnings": true,
"Body": {
"info": {
"version": "1.0",
Expand Down
1 change: 1 addition & 0 deletions tests/translator/output/http_api_explicit_stage.json
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@
"MyApi": {
"Type": "AWS::ApiGatewayV2::Api",
"Properties": {
"FailOnWarnings": true,
"Body": {
"info": {
"version": "1.0",
Expand Down
1 change: 1 addition & 0 deletions versions/2016-10-31.md
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,7 @@ DefaultRouteSettings | [RouteSettings](https://docs.aws.amazon.com/AWSCloudForma
RouteSettings | [RouteSettings](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-apigatewayv2-stage-routesettings.html) | Per-route route settings for this HTTP API.
Domain | [Domain Configuration Object](#domain-configuration-object) | Configuration settings for custom domains on API. Must contain `DomainName` and `CertificateArn`
StageVariables | Map of `string` to `string` | A map that defines the stage variables for a Stage. Variable names can have alphanumeric and underscore characters, and the values must match [A-Za-z0-9-._~:/?#&=,]+.
FailOnWarnings | `boolean` | Specifies whether to rollback the API creation (true) or not (false) when a warning is encountered. The default value is false.

##### Return values

Expand Down