File tree Expand file tree Collapse file tree 2 files changed +46
-6
lines changed
lib/plugins/aws/package/compile/events/api-gateway/lib
test/unit/lib/plugins/aws/package/compile/events/api-gateway/lib Expand file tree Collapse file tree 2 files changed +46
-6
lines changed Original file line number Diff line number Diff line change @@ -47,15 +47,27 @@ module.exports = {
4747 const DisableExecuteApiEndpoint =
4848 apiGateway . disableDefaultEndpoint == null ? undefined : apiGateway . disableDefaultEndpoint ;
4949
50+ const properties = {
51+ Name : this . provider . naming . getApiGatewayName ( ) ,
52+ BinaryMediaTypes,
53+ DisableExecuteApiEndpoint,
54+ EndpointConfiguration,
55+ } ;
56+
57+ // Tags
58+ if ( this . serverless . service . provider . tags ) {
59+ properties . Tags = Object . entries ( this . serverless . service . provider . tags ) . map (
60+ ( [ Key , Value ] ) => ( {
61+ Key,
62+ Value,
63+ } )
64+ ) ;
65+ }
66+
5067 _ . merge ( this . serverless . service . provider . compiledCloudFormationTemplate . Resources , {
5168 [ this . apiGatewayRestApiLogicalId ] : {
5269 Type : 'AWS::ApiGateway::RestApi' ,
53- Properties : {
54- Name : this . provider . naming . getApiGatewayName ( ) ,
55- BinaryMediaTypes,
56- DisableExecuteApiEndpoint,
57- EndpointConfiguration,
58- } ,
70+ Properties : properties ,
5971 } ,
6072 } ) ;
6173
Original file line number Diff line number Diff line change @@ -56,6 +56,34 @@ describe('#compileRestApi()', () => {
5656 } ) ;
5757 } ) ;
5858
59+ it ( 'should create a REST API resource with tags' , ( ) => {
60+ awsCompileApigEvents . serverless . service . provider . tags = {
61+ tagKey1 : 'tagValue1' ,
62+ tagKey2 : 'tagValue2' ,
63+ } ;
64+
65+ awsCompileApigEvents . compileRestApi ( ) ;
66+ const resources =
67+ awsCompileApigEvents . serverless . service . provider . compiledCloudFormationTemplate . Resources ;
68+
69+ expect ( resources . ApiGatewayRestApi ) . to . deep . equal ( {
70+ Type : 'AWS::ApiGateway::RestApi' ,
71+ Properties : {
72+ BinaryMediaTypes : undefined ,
73+ DisableExecuteApiEndpoint : undefined ,
74+ Name : 'dev-new-service' ,
75+ EndpointConfiguration : {
76+ Types : [ 'EDGE' ] ,
77+ } ,
78+ Policy : '' ,
79+ Tags : [
80+ { Key : 'tagKey1' , Value : 'tagValue1' } ,
81+ { Key : 'tagKey2' , Value : 'tagValue2' } ,
82+ ] ,
83+ } ,
84+ } ) ;
85+ } ) ;
86+
5987 it ( 'should create a REST API resource with resource policy' , ( ) => {
6088 awsCompileApigEvents . serverless . service . provider . apiGateway = {
6189 resourcePolicy : [
You can’t perform that action at this time.
0 commit comments