77
88from . import AWSHelperFn , AWSObject , AWSProperty
99from .apigateway import AccessLogSetting , CanarySetting , MethodSetting
10+ from .apigatewayv2 import AccessLogSettings , RouteSettings
1011from .awslambda import (
1112 DestinationConfig ,
1213 Environment ,
2526 integer_range ,
2627 mutually_exclusive ,
2728 positive_integer ,
29+ boolean ,
2830)
2931
3032try :
@@ -335,6 +337,10 @@ def validate(self):
335337 )
336338
337339
340+ class ApiDefinition (AWSProperty ):
341+ props = {"Bucket" : (str , True ), "Key" : (str , True ), "Version" : (str , False )}
342+
343+
338344class Api (AWSObject ):
339345 resource_type = "AWS::Serverless::Api"
340346
@@ -347,7 +353,7 @@ class Api(AWSObject):
347353 "CanarySetting" : (CanarySetting , False ),
348354 "Cors" : ((str , Cors ), False ),
349355 "DefinitionBody" : (dict , False ),
350- "DefinitionUri" : (str , False ),
356+ "DefinitionUri" : (( str , ApiDefinition ) , False ),
351357 "Domain" : (Domain , False ),
352358 "EndpointConfiguration" : (EndpointConfiguration , False ),
353359 "MethodSettings" : ([MethodSetting ], False ),
@@ -367,6 +373,88 @@ def validate(self):
367373 mutually_exclusive (self .__class__ .__name__ , self .properties , conds )
368374
369375
376+ class OAuth2Authorizer (AWSProperty ):
377+ props = {
378+ "AuthorizationScopes" : (list , False ),
379+ "IdentitySource" : (str , False ),
380+ "JwtConfiguration" : (dict , False ),
381+ }
382+
383+
384+ class LambdaAuthorizationIdentity (AWSProperty ):
385+ props = {
386+ "Context" : (list , False ),
387+ "Headers" : (list , False ),
388+ "QueryStrings" : (list , False ),
389+ "ReauthorizeEvery" : (integer , False ),
390+ "StageVariables" : (list , False ),
391+ }
392+
393+
394+ class LambdaAuthorizer (AWSProperty ):
395+ props = {
396+ "AuthorizerPayloadFormatVersion" : (str , True ),
397+ "EnableSimpleResponses" : (boolean , False ),
398+ "FunctionArn" : (str , True ),
399+ "FunctionInvokeRole" : (str , False ),
400+ "Identity" : (LambdaAuthorizationIdentity , False ),
401+ }
402+
403+
404+ class HttpApiAuth (AWSProperty ):
405+ props = {
406+ "Authorizers" : ((OAuth2Authorizer , LambdaAuthorizer ), False ),
407+ "DefaultAuthorizer" : (str , False ),
408+ }
409+
410+
411+ class HttpApiCorsConfiguration (AWSProperty ):
412+ props = {
413+ "AllowCredentials" : (boolean , False ),
414+ "AllowHeaders" : (list , False ),
415+ "AllowMethods" : (list , False ),
416+ "AllowOrigins" : (list , False ),
417+ "ExposeHeaders" : (list , False ),
418+ "MaxAge" : (integer , False ),
419+ }
420+
421+
422+ class HttpApiDefinition (ApiDefinition ):
423+ pass
424+
425+
426+ class HttpApiDomainConfiguration (Domain ):
427+ pass
428+
429+
430+ class HttpApi (AWSObject ):
431+ resource_type = "AWS::Serverless::HttpApi"
432+
433+ props = {
434+ "AccessLogSettings" : (AccessLogSettings , False ),
435+ "Auth" : (HttpApiAuth , False ),
436+ "CorsConfiguration" : ((str , HttpApiCorsConfiguration ), False ),
437+ "DefaultRouteSettings" : (RouteSettings , False ),
438+ "DefinitionBody" : (dict , False ),
439+ "DefinitionUri" : ((str , HttpApiDefinition ), False ),
440+ "Description" : (str , False ),
441+ "DisableExecuteApiEndpoint" : (boolean , False ),
442+ "Domain" : (HttpApiDomainConfiguration , False ),
443+ "FailOnWarnings" : (boolean , False ),
444+ "RouteSettings" : (dict , False ),
445+ "StageName" : (str , False ),
446+ "StageVariables" : (dict , False ),
447+ "Tags" : (dict , False ),
448+ }
449+
450+ def validate (self ):
451+ conds = [
452+ "DefinitionBody" ,
453+ "DefinitionUri" ,
454+ ]
455+ mutually_exclusive (self .__class__ .__name__ , self .properties , conds )
456+
457+
370458class PrimaryKey (AWSProperty ):
371459 props = {"Name" : (str , False ), "Type" : (primary_key_type_validator , False )}
372460
0 commit comments