SAM Serverless implicit API vs AWS::Serverless::Api Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern) Data science time! April 2019 and salary with experience The Ask Question Wizard is Live!AWS SAM: The REST API doesn't contain any methodsAWS SAM Template Fails to Create Configurations for API GatewayAWS SAM Template Create APIAWS::Serverless::Api Resource Policy with Cloudformation SAMAWS SAM template/cloudformation No integration defined for method (Service: AmazonApiGatewayHow to get the auto generated RestApi from my AWS SAM template? To use in another SAM templateCan I “Ref” and “GetAtt” an implicit defined API in a AWS SAM template?AWS SAM Template - Define SQS queue triggered by API GatewayAWS SAM Template - Local TestingHow to assign IAM Role to implicit API Gateway in SAM template?How to add more details on a AWS SAM template for my apiCreate an API Gateway Proxy Resource using SAM

Meaning of 境 in その日を境に

Getting representations of the Lie group out of representations of its Lie algebra

How to name indistinguishable henchmen in a screenplay?

Inverse square law not accurate for non-point masses?

Fit odd number of triplets in a measure?

Is there a spell that can create a permanent fire?

Where and when has Thucydides been studied?

What did Turing mean when saying that "machines cannot give rise to surprises" is due to a fallacy?

Why do C and C++ allow the expression (int) + 4*5;

How to ask rejected full-time candidates to apply to teach individual courses?

3D Masyu - A Die

How to make an animal which can only breed for a certain number of generations?

How do you cope with tons of web fonts when copying and pasting from web pages?

The Nth Gryphon Number

What is "Lambda" in Heston's original paper on stochastic volatility models?

What are some likely causes to domain member PC losing contact to domain controller?

Noise in Eigenvalues plot

Pointing to problems without suggesting solutions

Diophantine equation 3^a+1=3^b+5^c

Was the pager message from Nick Fury to Captain Marvel unnecessary?

Keep at all times, the minus sign above aligned with minus sign below

Why not use the yoke to control yaw, as well as pitch and roll?

Simple Line in LaTeX Help!

How do I say "this must not happen"?



SAM Serverless implicit API vs AWS::Serverless::Api



Announcing the arrival of Valued Associate #679: Cesar Manara
Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern)
Data science time! April 2019 and salary with experience
The Ask Question Wizard is Live!AWS SAM: The REST API doesn't contain any methodsAWS SAM Template Fails to Create Configurations for API GatewayAWS SAM Template Create APIAWS::Serverless::Api Resource Policy with Cloudformation SAMAWS SAM template/cloudformation No integration defined for method (Service: AmazonApiGatewayHow to get the auto generated RestApi from my AWS SAM template? To use in another SAM templateCan I “Ref” and “GetAtt” an implicit defined API in a AWS SAM template?AWS SAM Template - Define SQS queue triggered by API GatewayAWS SAM Template - Local TestingHow to assign IAM Role to implicit API Gateway in SAM template?How to add more details on a AWS SAM template for my apiCreate an API Gateway Proxy Resource using SAM



.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








1















When configuring a SAM template and defining a AWS::Serverless::Function there is the Events param that accepts an Api type. Does this create an API Gateway resource? What is the difference between this event type and a standalone AWS::Serverless::Api resource?










share|improve this question






























    1















    When configuring a SAM template and defining a AWS::Serverless::Function there is the Events param that accepts an Api type. Does this create an API Gateway resource? What is the difference between this event type and a standalone AWS::Serverless::Api resource?










    share|improve this question


























      1












      1








      1








      When configuring a SAM template and defining a AWS::Serverless::Function there is the Events param that accepts an Api type. Does this create an API Gateway resource? What is the difference between this event type and a standalone AWS::Serverless::Api resource?










      share|improve this question
















      When configuring a SAM template and defining a AWS::Serverless::Function there is the Events param that accepts an Api type. Does this create an API Gateway resource? What is the difference between this event type and a standalone AWS::Serverless::Api resource?







      amazon-web-services aws-serverless aws-sam






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Mar 8 at 11:11









      Alex Harvey

      5,96011230




      5,96011230










      asked Dec 22 '18 at 19:05









      ProgrammaticProgrammatic

      318921




      318921






















          2 Answers
          2






          active

          oldest

          votes


















          2














          The question asks about the APIs referred to in the Event source block of a SAM AWS::Serverless::Function type, such as:



          MyFunction:
          Type: AWS::Serverless::Function
          Properties:
          ...
          Events:
          MyApi:
          Type: Api
          Properties:
          Path: /resource
          Method: GET


          As mentioned in the docs in various places, these are called "implicit APIs" in SAM.



          SAM creates resources of type AWS::Serverless::Api from the union of Api events defined on AWS::Serverless::Function resources - but only those that do not refer (via the RestApiId property) to AWS::Serverless::Api defined explicitly in the template.



          Behind the scenes, SAM collects all of these implicit APIs, generates a Swagger, and creates the implicit APIs using this Swagger. This API defaults to a StageName called "Prod" which cannot be configured.



          If you do need control over defining and documenting the API in Swagger, an AWS::Serverless::Api resource should be created explicitly. It would then be referred to this way:



          MyFunction:
          Type: AWS::Serverless::Function
          Properties:
          ...
          Events:
          MyApi:
          Type: Api
          Properties:
          Path: /resource
          Method: GET
          RestApiId: !Ref MyAPI # Add this line

          MyApi:
          Type: AWS::Serverless::Api
          Properties:
          StageName: Prod
          DefinitionBody:
          ...


          So the only difference between them is how much control you have over their configuration, and the key consideration is whether or not you need to define either:



          • StageName

          • a Swagger definition (via DefinitionBody)

          If you need control over either or both of these, then you need to define your API explicitly. Otherwise, you can probably use the implicit APIs.



          Note also that AWS::Serverless::Api resources in SAM are "transformed" into CloudFormation resources of type AWS::ApiGateway::RestApi, AWS::ApiGateway::Stage, and AWS::ApiGateway::Deployment.



          Note that this information is a summary of information found in these three source docs:



          • https://github.com/awslabs/serverless-application-model/blob/develop/versions/2016-10-31.md#awsserverlessapi

          • https://github.com/awslabs/serverless-application-model/blob/master/docs/internals/generated_resources.rst#api

          • https://github.com/awslabs/serverless-application-model/blob/master/docs/globals.rst#implicit-apis





          share|improve this answer

























          • You put some work into this, thank you. I've made yours the accepted answer for future people who stumble on this.

            – Programmatic
            Mar 8 at 17:25











          • It should be noted that you do not need to set a DefinitionBody. These resources can be used in conjunction. See here gist.github.com/joeythomaschaske/…

            – Programmatic
            Mar 8 at 17:31












          • Well I did mention that the key consideration when choosing to use implicit or explicit is whether you need to define your own Swagger, which goes in the DefinitionBody. Is that bit unclear?

            – Alex Harvey
            Mar 9 at 0:46






          • 1





            Ahhh, I believe I misread that statement. Good point.

            – Programmatic
            Mar 9 at 1:05


















          0














          Taken from the documentation:




          An AWS::Serverless::Api resource need not be explicitly added to a AWS Serverless Application Definition template. A resource of this type is implicitly created from the union of Api events defined on AWS::Serverless::Function resources defined in the template that do not refer to an AWS::Serverless::Api resource.







          share|improve this answer























            Your Answer






            StackExchange.ifUsing("editor", function ()
            StackExchange.using("externalEditor", function ()
            StackExchange.using("snippets", function ()
            StackExchange.snippets.init();
            );
            );
            , "code-snippets");

            StackExchange.ready(function()
            var channelOptions =
            tags: "".split(" "),
            id: "1"
            ;
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function()
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled)
            StackExchange.using("snippets", function()
            createEditor();
            );

            else
            createEditor();

            );

            function createEditor()
            StackExchange.prepareEditor(
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader:
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            ,
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            );



            );













            draft saved

            draft discarded


















            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53898543%2fsam-serverless-implicit-api-vs-awsserverlessapi%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown

























            2 Answers
            2






            active

            oldest

            votes








            2 Answers
            2






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            2














            The question asks about the APIs referred to in the Event source block of a SAM AWS::Serverless::Function type, such as:



            MyFunction:
            Type: AWS::Serverless::Function
            Properties:
            ...
            Events:
            MyApi:
            Type: Api
            Properties:
            Path: /resource
            Method: GET


            As mentioned in the docs in various places, these are called "implicit APIs" in SAM.



            SAM creates resources of type AWS::Serverless::Api from the union of Api events defined on AWS::Serverless::Function resources - but only those that do not refer (via the RestApiId property) to AWS::Serverless::Api defined explicitly in the template.



            Behind the scenes, SAM collects all of these implicit APIs, generates a Swagger, and creates the implicit APIs using this Swagger. This API defaults to a StageName called "Prod" which cannot be configured.



            If you do need control over defining and documenting the API in Swagger, an AWS::Serverless::Api resource should be created explicitly. It would then be referred to this way:



            MyFunction:
            Type: AWS::Serverless::Function
            Properties:
            ...
            Events:
            MyApi:
            Type: Api
            Properties:
            Path: /resource
            Method: GET
            RestApiId: !Ref MyAPI # Add this line

            MyApi:
            Type: AWS::Serverless::Api
            Properties:
            StageName: Prod
            DefinitionBody:
            ...


            So the only difference between them is how much control you have over their configuration, and the key consideration is whether or not you need to define either:



            • StageName

            • a Swagger definition (via DefinitionBody)

            If you need control over either or both of these, then you need to define your API explicitly. Otherwise, you can probably use the implicit APIs.



            Note also that AWS::Serverless::Api resources in SAM are "transformed" into CloudFormation resources of type AWS::ApiGateway::RestApi, AWS::ApiGateway::Stage, and AWS::ApiGateway::Deployment.



            Note that this information is a summary of information found in these three source docs:



            • https://github.com/awslabs/serverless-application-model/blob/develop/versions/2016-10-31.md#awsserverlessapi

            • https://github.com/awslabs/serverless-application-model/blob/master/docs/internals/generated_resources.rst#api

            • https://github.com/awslabs/serverless-application-model/blob/master/docs/globals.rst#implicit-apis





            share|improve this answer

























            • You put some work into this, thank you. I've made yours the accepted answer for future people who stumble on this.

              – Programmatic
              Mar 8 at 17:25











            • It should be noted that you do not need to set a DefinitionBody. These resources can be used in conjunction. See here gist.github.com/joeythomaschaske/…

              – Programmatic
              Mar 8 at 17:31












            • Well I did mention that the key consideration when choosing to use implicit or explicit is whether you need to define your own Swagger, which goes in the DefinitionBody. Is that bit unclear?

              – Alex Harvey
              Mar 9 at 0:46






            • 1





              Ahhh, I believe I misread that statement. Good point.

              – Programmatic
              Mar 9 at 1:05















            2














            The question asks about the APIs referred to in the Event source block of a SAM AWS::Serverless::Function type, such as:



            MyFunction:
            Type: AWS::Serverless::Function
            Properties:
            ...
            Events:
            MyApi:
            Type: Api
            Properties:
            Path: /resource
            Method: GET


            As mentioned in the docs in various places, these are called "implicit APIs" in SAM.



            SAM creates resources of type AWS::Serverless::Api from the union of Api events defined on AWS::Serverless::Function resources - but only those that do not refer (via the RestApiId property) to AWS::Serverless::Api defined explicitly in the template.



            Behind the scenes, SAM collects all of these implicit APIs, generates a Swagger, and creates the implicit APIs using this Swagger. This API defaults to a StageName called "Prod" which cannot be configured.



            If you do need control over defining and documenting the API in Swagger, an AWS::Serverless::Api resource should be created explicitly. It would then be referred to this way:



            MyFunction:
            Type: AWS::Serverless::Function
            Properties:
            ...
            Events:
            MyApi:
            Type: Api
            Properties:
            Path: /resource
            Method: GET
            RestApiId: !Ref MyAPI # Add this line

            MyApi:
            Type: AWS::Serverless::Api
            Properties:
            StageName: Prod
            DefinitionBody:
            ...


            So the only difference between them is how much control you have over their configuration, and the key consideration is whether or not you need to define either:



            • StageName

            • a Swagger definition (via DefinitionBody)

            If you need control over either or both of these, then you need to define your API explicitly. Otherwise, you can probably use the implicit APIs.



            Note also that AWS::Serverless::Api resources in SAM are "transformed" into CloudFormation resources of type AWS::ApiGateway::RestApi, AWS::ApiGateway::Stage, and AWS::ApiGateway::Deployment.



            Note that this information is a summary of information found in these three source docs:



            • https://github.com/awslabs/serverless-application-model/blob/develop/versions/2016-10-31.md#awsserverlessapi

            • https://github.com/awslabs/serverless-application-model/blob/master/docs/internals/generated_resources.rst#api

            • https://github.com/awslabs/serverless-application-model/blob/master/docs/globals.rst#implicit-apis





            share|improve this answer

























            • You put some work into this, thank you. I've made yours the accepted answer for future people who stumble on this.

              – Programmatic
              Mar 8 at 17:25











            • It should be noted that you do not need to set a DefinitionBody. These resources can be used in conjunction. See here gist.github.com/joeythomaschaske/…

              – Programmatic
              Mar 8 at 17:31












            • Well I did mention that the key consideration when choosing to use implicit or explicit is whether you need to define your own Swagger, which goes in the DefinitionBody. Is that bit unclear?

              – Alex Harvey
              Mar 9 at 0:46






            • 1





              Ahhh, I believe I misread that statement. Good point.

              – Programmatic
              Mar 9 at 1:05













            2












            2








            2







            The question asks about the APIs referred to in the Event source block of a SAM AWS::Serverless::Function type, such as:



            MyFunction:
            Type: AWS::Serverless::Function
            Properties:
            ...
            Events:
            MyApi:
            Type: Api
            Properties:
            Path: /resource
            Method: GET


            As mentioned in the docs in various places, these are called "implicit APIs" in SAM.



            SAM creates resources of type AWS::Serverless::Api from the union of Api events defined on AWS::Serverless::Function resources - but only those that do not refer (via the RestApiId property) to AWS::Serverless::Api defined explicitly in the template.



            Behind the scenes, SAM collects all of these implicit APIs, generates a Swagger, and creates the implicit APIs using this Swagger. This API defaults to a StageName called "Prod" which cannot be configured.



            If you do need control over defining and documenting the API in Swagger, an AWS::Serverless::Api resource should be created explicitly. It would then be referred to this way:



            MyFunction:
            Type: AWS::Serverless::Function
            Properties:
            ...
            Events:
            MyApi:
            Type: Api
            Properties:
            Path: /resource
            Method: GET
            RestApiId: !Ref MyAPI # Add this line

            MyApi:
            Type: AWS::Serverless::Api
            Properties:
            StageName: Prod
            DefinitionBody:
            ...


            So the only difference between them is how much control you have over their configuration, and the key consideration is whether or not you need to define either:



            • StageName

            • a Swagger definition (via DefinitionBody)

            If you need control over either or both of these, then you need to define your API explicitly. Otherwise, you can probably use the implicit APIs.



            Note also that AWS::Serverless::Api resources in SAM are "transformed" into CloudFormation resources of type AWS::ApiGateway::RestApi, AWS::ApiGateway::Stage, and AWS::ApiGateway::Deployment.



            Note that this information is a summary of information found in these three source docs:



            • https://github.com/awslabs/serverless-application-model/blob/develop/versions/2016-10-31.md#awsserverlessapi

            • https://github.com/awslabs/serverless-application-model/blob/master/docs/internals/generated_resources.rst#api

            • https://github.com/awslabs/serverless-application-model/blob/master/docs/globals.rst#implicit-apis





            share|improve this answer















            The question asks about the APIs referred to in the Event source block of a SAM AWS::Serverless::Function type, such as:



            MyFunction:
            Type: AWS::Serverless::Function
            Properties:
            ...
            Events:
            MyApi:
            Type: Api
            Properties:
            Path: /resource
            Method: GET


            As mentioned in the docs in various places, these are called "implicit APIs" in SAM.



            SAM creates resources of type AWS::Serverless::Api from the union of Api events defined on AWS::Serverless::Function resources - but only those that do not refer (via the RestApiId property) to AWS::Serverless::Api defined explicitly in the template.



            Behind the scenes, SAM collects all of these implicit APIs, generates a Swagger, and creates the implicit APIs using this Swagger. This API defaults to a StageName called "Prod" which cannot be configured.



            If you do need control over defining and documenting the API in Swagger, an AWS::Serverless::Api resource should be created explicitly. It would then be referred to this way:



            MyFunction:
            Type: AWS::Serverless::Function
            Properties:
            ...
            Events:
            MyApi:
            Type: Api
            Properties:
            Path: /resource
            Method: GET
            RestApiId: !Ref MyAPI # Add this line

            MyApi:
            Type: AWS::Serverless::Api
            Properties:
            StageName: Prod
            DefinitionBody:
            ...


            So the only difference between them is how much control you have over their configuration, and the key consideration is whether or not you need to define either:



            • StageName

            • a Swagger definition (via DefinitionBody)

            If you need control over either or both of these, then you need to define your API explicitly. Otherwise, you can probably use the implicit APIs.



            Note also that AWS::Serverless::Api resources in SAM are "transformed" into CloudFormation resources of type AWS::ApiGateway::RestApi, AWS::ApiGateway::Stage, and AWS::ApiGateway::Deployment.



            Note that this information is a summary of information found in these three source docs:



            • https://github.com/awslabs/serverless-application-model/blob/develop/versions/2016-10-31.md#awsserverlessapi

            • https://github.com/awslabs/serverless-application-model/blob/master/docs/internals/generated_resources.rst#api

            • https://github.com/awslabs/serverless-application-model/blob/master/docs/globals.rst#implicit-apis






            share|improve this answer














            share|improve this answer



            share|improve this answer








            edited Mar 9 at 2:12

























            answered Mar 8 at 12:02









            Alex HarveyAlex Harvey

            5,96011230




            5,96011230












            • You put some work into this, thank you. I've made yours the accepted answer for future people who stumble on this.

              – Programmatic
              Mar 8 at 17:25











            • It should be noted that you do not need to set a DefinitionBody. These resources can be used in conjunction. See here gist.github.com/joeythomaschaske/…

              – Programmatic
              Mar 8 at 17:31












            • Well I did mention that the key consideration when choosing to use implicit or explicit is whether you need to define your own Swagger, which goes in the DefinitionBody. Is that bit unclear?

              – Alex Harvey
              Mar 9 at 0:46






            • 1





              Ahhh, I believe I misread that statement. Good point.

              – Programmatic
              Mar 9 at 1:05

















            • You put some work into this, thank you. I've made yours the accepted answer for future people who stumble on this.

              – Programmatic
              Mar 8 at 17:25











            • It should be noted that you do not need to set a DefinitionBody. These resources can be used in conjunction. See here gist.github.com/joeythomaschaske/…

              – Programmatic
              Mar 8 at 17:31












            • Well I did mention that the key consideration when choosing to use implicit or explicit is whether you need to define your own Swagger, which goes in the DefinitionBody. Is that bit unclear?

              – Alex Harvey
              Mar 9 at 0:46






            • 1





              Ahhh, I believe I misread that statement. Good point.

              – Programmatic
              Mar 9 at 1:05
















            You put some work into this, thank you. I've made yours the accepted answer for future people who stumble on this.

            – Programmatic
            Mar 8 at 17:25





            You put some work into this, thank you. I've made yours the accepted answer for future people who stumble on this.

            – Programmatic
            Mar 8 at 17:25













            It should be noted that you do not need to set a DefinitionBody. These resources can be used in conjunction. See here gist.github.com/joeythomaschaske/…

            – Programmatic
            Mar 8 at 17:31






            It should be noted that you do not need to set a DefinitionBody. These resources can be used in conjunction. See here gist.github.com/joeythomaschaske/…

            – Programmatic
            Mar 8 at 17:31














            Well I did mention that the key consideration when choosing to use implicit or explicit is whether you need to define your own Swagger, which goes in the DefinitionBody. Is that bit unclear?

            – Alex Harvey
            Mar 9 at 0:46





            Well I did mention that the key consideration when choosing to use implicit or explicit is whether you need to define your own Swagger, which goes in the DefinitionBody. Is that bit unclear?

            – Alex Harvey
            Mar 9 at 0:46




            1




            1





            Ahhh, I believe I misread that statement. Good point.

            – Programmatic
            Mar 9 at 1:05





            Ahhh, I believe I misread that statement. Good point.

            – Programmatic
            Mar 9 at 1:05













            0














            Taken from the documentation:




            An AWS::Serverless::Api resource need not be explicitly added to a AWS Serverless Application Definition template. A resource of this type is implicitly created from the union of Api events defined on AWS::Serverless::Function resources defined in the template that do not refer to an AWS::Serverless::Api resource.







            share|improve this answer



























              0














              Taken from the documentation:




              An AWS::Serverless::Api resource need not be explicitly added to a AWS Serverless Application Definition template. A resource of this type is implicitly created from the union of Api events defined on AWS::Serverless::Function resources defined in the template that do not refer to an AWS::Serverless::Api resource.







              share|improve this answer

























                0












                0








                0







                Taken from the documentation:




                An AWS::Serverless::Api resource need not be explicitly added to a AWS Serverless Application Definition template. A resource of this type is implicitly created from the union of Api events defined on AWS::Serverless::Function resources defined in the template that do not refer to an AWS::Serverless::Api resource.







                share|improve this answer













                Taken from the documentation:




                An AWS::Serverless::Api resource need not be explicitly added to a AWS Serverless Application Definition template. A resource of this type is implicitly created from the union of Api events defined on AWS::Serverless::Function resources defined in the template that do not refer to an AWS::Serverless::Api resource.








                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Dec 22 '18 at 19:32









                ProgrammaticProgrammatic

                318921




                318921



























                    draft saved

                    draft discarded
















































                    Thanks for contributing an answer to Stack Overflow!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid


                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.

                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53898543%2fsam-serverless-implicit-api-vs-awsserverlessapi%23new-answer', 'question_page');

                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    1928 у кіно

                    Захаров Федір Захарович

                    Ель Греко