@@ -71,6 +71,73 @@ export = {
71
71
test . done ( ) ;
72
72
} ,
73
73
74
+ 'LambdaRestApi supports function Alias' ( test : Test ) {
75
+ // GIVEN
76
+ const stack = new cdk . Stack ( ) ;
77
+
78
+ const handler = new lambda . Function ( stack , 'handler' , {
79
+ handler : 'index.handler' ,
80
+ code : lambda . Code . inline ( 'boom' ) ,
81
+ runtime : lambda . Runtime . NodeJS610 ,
82
+ } ) ;
83
+ const alias = new lambda . Alias ( stack , 'alias' , {
84
+ aliasName : 'my-alias' ,
85
+ version : new lambda . Version ( stack , 'version' , {
86
+ lambda : handler
87
+ } )
88
+ } ) ;
89
+
90
+ // WHEN
91
+ const api = new apigw . LambdaRestApi ( stack , 'lambda-rest-api' , { handler : alias } ) ;
92
+
93
+ // THEN -- can't customize further
94
+ test . throws ( ( ) => {
95
+ api . root . addResource ( 'cant-touch-this' ) ;
96
+ } ) ;
97
+
98
+ // THEN -- template proxies everything
99
+ expect ( stack ) . to ( haveResource ( 'AWS::ApiGateway::Resource' , {
100
+ "PathPart" : "{proxy+}"
101
+ } ) ) ;
102
+
103
+ expect ( stack ) . to ( haveResource ( 'AWS::ApiGateway::Method' , {
104
+ "HttpMethod" : "ANY" ,
105
+ "ResourceId" : {
106
+ "Ref" : "lambdarestapiproxyE3AE07E3"
107
+ } ,
108
+ "RestApiId" : {
109
+ "Ref" : "lambdarestapiAAD10924"
110
+ } ,
111
+ "AuthorizationType" : "NONE" ,
112
+ "Integration" : {
113
+ "IntegrationHttpMethod" : "POST" ,
114
+ "Type" : "AWS_PROXY" ,
115
+ "Uri" : {
116
+ "Fn::Join" : [
117
+ "" ,
118
+ [
119
+ "arn:" ,
120
+ {
121
+ "Ref" : "AWS::Partition"
122
+ } ,
123
+ ":apigateway:" ,
124
+ {
125
+ "Ref" : "AWS::Region"
126
+ } ,
127
+ ":lambda:path/2015-03-31/functions/" ,
128
+ {
129
+ "Ref" : "alias68BF17F5"
130
+ } ,
131
+ "/invocations"
132
+ ]
133
+ ]
134
+ }
135
+ }
136
+ } ) ) ;
137
+
138
+ test . done ( ) ;
139
+ } ,
140
+
74
141
'when "proxy" is set to false, users need to define the model' ( test : Test ) {
75
142
// GIVEN
76
143
const stack = new cdk . Stack ( ) ;
0 commit comments