Skip to content

Conversation

praneetap
Copy link
Contributor

@praneetap praneetap commented Jul 31, 2019

Issue #, if available:
#191
Description of changes:
If the template has OpenApiVersion flag defined, change the hash generated so the api gets redeployed.
Description of how you validated changes:
First I deployed a simple hello world template.

Globals:
  Function:
    Timeout: 3

Resources:
  HelloWorldFunction:
    Type: AWS::Serverless::Function
    Properties:
      InlineCode: |
        exports.handler = async (event) => {
          const response = {
            statusCode: 200,
            body: JSON.stringify('Hello from Lambda!'),
          };
          return response;
        };      
      Handler: index.handler
      Runtime: nodejs8.10
      Events:
        HelloWorld:
          Type: Api 
          Properties:
            Path: /hello
            Method: get

Outputs:
  HelloWorldApi:
    Description: "API Gateway endpoint URL for Prod stage for Hello World function"
    Value: !Sub "https://${ServerlessRestApi}.execute-api.${AWS::Region}.amazonaws.com/Prod/hello/"
  HelloWorldFunction:
    Description: "Hello World Lambda Function ARN"
    Value: !GetAtt HelloWorldFunction.Arn
  HelloWorldFunctionIamRole:
    Description: "Implicit IAM Role created for Hello World function"
    Value: !GetAtt HelloWorldFunctionRole.Arn

Then I added the OpenApiVersion flag to the template with version '2.0', which wouldnt change the swagger document from the template above.

Globals:
  Function:
    Timeout: 3
  Api:
    OpenApiVersion: "2.0"

Resources:
  HelloWorldFunction:
    Type: AWS::Serverless::Function
    Properties:
      InlineCode: |
        exports.handler = async (event) => {
          const response = {
            statusCode: 200,
            body: JSON.stringify('Hello from Lambda!'),
          };
          return response;
        };      
      Handler: index.handler
      Runtime: nodejs8.10
      Events:
        HelloWorld:
          Type: Api
          Properties:
            Path: /hello
            Method: get

Outputs:
  HelloWorldApi:
    Description: "API Gateway endpoint URL for Prod stage for Hello World function"
    Value: !Sub "https://${ServerlessRestApi}.execute-api.${AWS::Region}.amazonaws.com/Prod/hello/"
  HelloWorldFunction:
    Description: "Hello World Lambda Function ARN"
    Value: !GetAtt HelloWorldFunction.Arn
  HelloWorldFunctionIamRole:
    Description: "Implicit IAM Role created for Hello World function"
    Value: !GetAtt HelloWorldFunctionRole.Arn

I verified that the API got redeployed by looking at the deployment history on API GW console.
The API gateway Stage stage was on the older deployment version than Prod stage.

Checklist:

  • Write/update tests
  • make pr passes
  • Update documentation
  • Verify transformed template deploys and application functions as expected
  • Add/update example to examples/2016-10-31

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@codecov-io
Copy link

codecov-io commented Aug 1, 2019

Codecov Report

Merging #1056 into develop will increase coverage by <.01%.
The diff coverage is 100%.

Impacted file tree graph

@@             Coverage Diff             @@
##           develop    #1056      +/-   ##
===========================================
+ Coverage    94.92%   94.92%   +<.01%     
===========================================
  Files           69       69              
  Lines         3250     3253       +3     
  Branches       632      633       +1     
===========================================
+ Hits          3085     3088       +3     
  Misses          87       87              
  Partials        78       78
Impacted Files Coverage Δ
samtranslator/model/api/api_generator.py 96.64% <100%> (ø) ⬆️
samtranslator/model/apigateway.py 97.76% <100%> (+0.03%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 8804733...9b4c623. Read the comment docs.

@praneetap praneetap requested review from jlhood and keetonian August 1, 2019 00:24
Copy link
Contributor

@jlhood jlhood left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for fixing this!

@jlhood jlhood merged commit 4df24a3 into aws:develop Aug 1, 2019
praneetap added a commit to praneetap/serverless-application-model that referenced this pull request Aug 1, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants