Skip to content

Commit fbc216c

Browse files
authored
feat: add support for FailOnWarnings (#1509)
1 parent 354445c commit fbc216c

File tree

13 files changed

+18
-0
lines changed

13 files changed

+18
-0
lines changed

examples/2016-10-31/http_api_cors/template.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ Resources:
2626
MyApi:
2727
Type: AWS::Serverless::HttpApi
2828
Properties:
29+
FailOnWarnings: true
2930
CorsConfiguration:
3031
AllowHeaders:
3132
- x-apigateway-header

samtranslator/model/api/http_api_generator.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ def __init__(
4747
resource_attributes=None,
4848
passthrough_resource_attributes=None,
4949
domain=None,
50+
fail_on_warnings=False,
5051
):
5152
"""Constructs an API Generator class that generates API Gateway resources
5253
@@ -79,6 +80,7 @@ def __init__(
7980
self.resource_attributes = resource_attributes
8081
self.passthrough_resource_attributes = passthrough_resource_attributes
8182
self.domain = domain
83+
self.fail_on_warnings = fail_on_warnings
8284

8385
def _construct_http_api(self):
8486
"""Constructs and returns the ApiGatewayV2 HttpApi.
@@ -99,6 +101,9 @@ def _construct_http_api(self):
99101
self._add_auth()
100102
self._add_tags()
101103

104+
if self.fail_on_warnings:
105+
http_api.FailOnWarnings = self.fail_on_warnings
106+
102107
if self.definition_uri:
103108
http_api.BodyS3Location = self._construct_body_s3_dict()
104109
elif self.definition_body:

samtranslator/model/sam_resources.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -878,6 +878,7 @@ class SamHttpApi(SamResourceMacro):
878878
"Auth": PropertyType(False, is_type(dict)),
879879
"RouteSettings": PropertyType(False, is_type(dict)),
880880
"Domain": PropertyType(False, is_type(dict)),
881+
"FailOnWarnings": PropertyType(False, is_type(bool)),
881882
}
882883

883884
referable_properties = {
@@ -916,6 +917,7 @@ def to_cloudformation(self, **kwargs):
916917
resource_attributes=self.resource_attributes,
917918
passthrough_resource_attributes=self.get_passthrough_resource_attributes(),
918919
domain=self.Domain,
920+
fail_on_warnings=self.FailOnWarnings,
919921
)
920922

921923
(http_api, stage, domain, basepath_mapping, route53,) = api_generator.to_cloudformation()

samtranslator/plugins/globals/globals.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ class Globals(object):
7373
"DefaultRouteSettings",
7474
"Domain",
7575
"RouteSettings",
76+
"FailOnWarnings",
7677
],
7778
SamResourceType.SimpleTable.value: ["SSESpecification"],
7879
}

tests/translator/input/explicit_http_api.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ Resources:
1919
MyApi:
2020
Type: AWS::Serverless::HttpApi
2121
Properties:
22+
FailOnWarnings: True
2223
Auth:
2324
Authorizers:
2425
OAuth2:

tests/translator/input/http_api_explicit_stage.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ Globals:
88
"$default":
99
DataTraceEnabled: True
1010
ThrottlingBurstLimit: 100
11+
FailOnWarnings: true
1112
Resources:
1213
HttpApiFunction:
1314
Type: AWS::Serverless::Function

tests/translator/output/aws-cn/explicit_http_api.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,7 @@
196196
"MyApi": {
197197
"Type": "AWS::ApiGatewayV2::Api",
198198
"Properties": {
199+
"FailOnWarnings": true,
199200
"Body": {
200201
"info": {
201202
"version": "1.0",

tests/translator/output/aws-cn/http_api_explicit_stage.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@
111111
"MyApi": {
112112
"Type": "AWS::ApiGatewayV2::Api",
113113
"Properties": {
114+
"FailOnWarnings": true,
114115
"Body": {
115116
"info": {
116117
"version": "1.0",

tests/translator/output/aws-us-gov/explicit_http_api.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,7 @@
196196
"MyApi": {
197197
"Type": "AWS::ApiGatewayV2::Api",
198198
"Properties": {
199+
"FailOnWarnings": true,
199200
"Body": {
200201
"info": {
201202
"version": "1.0",

tests/translator/output/aws-us-gov/http_api_explicit_stage.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@
111111
"MyApi": {
112112
"Type": "AWS::ApiGatewayV2::Api",
113113
"Properties": {
114+
"FailOnWarnings": true,
114115
"Body": {
115116
"info": {
116117
"version": "1.0",

0 commit comments

Comments
 (0)