Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Support "Name" for AWS::Serverless::HttpApi #2492

Merged
merged 3 commits into from
Nov 17, 2022
Merged

Conversation

aahung
Copy link
Contributor

@aahung aahung commented Sep 7, 2022

Issue #, if available:

#1617

Description of changes:

Allow customer to specify Name for `AWS::Serverless::HttpApi, like the rest of serverless resource types:

  • AWS::Serverless::Api
  • AWS::Serverless::Function
  • AWS::Serverless::LayerVersion
  • AWS::Serverless::SimpleTable
  • AWS::Serverless::StateMachine

Why it is implemented like that?

A: AWS::ApiGatewayV2::Api cannot have Body and Name at the same time. As SAM-T will add Body to the AWS::ApiGatewayV2::Api, we can only set Name by updating the openapi definition (info -> title). Right now the info -> title is by default !Ref: AWS::StackName.

Proposed documentation change:

Name
A name of the API Gateway V2 Api resource.
Note: The default name is the name of the stack. This property requires AWS SAM to modify the HttpApi resource's OpenAPI definition, to set the name field. The following two scenarios result in an error: 1) The DefinitionBody property is specified with the name field set in the OpenAPI definition (since this is a conflict that AWS SAM won't resolve), or 2) The DefinitionUri property is specified (since AWS SAM won't modify an OpenAPI definition that it retrieves from Amazon S3).
Type: String
Required: No
AWS CloudFormation compatibility: This property is unique to AWS SAM and doesn't have an AWS CloudFormation equivalent.
https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/sam-resource-httpapi.html

Description of how you validated changes:

I took the translated template and deployed to my account (with stack name http-api-test-3):

  MyApi:
    Type: AWS::Serverless::HttpApi
    Properties:
      Name: MyHttpApi

  MyApiWithIntrinsicName:
    Type: AWS::Serverless::HttpApi
    Properties:
      Name: !Sub "${HttpApiFunction}-HttpApi"

image

Checklist:

  • Add/update unit tests using:
  • Add/update integration tests
  • make pr passes
  • Update documentation
  • Verify transformed template deploys and application functions as expected
  • Do these changes include any template validations?
    • Did the newly validated properties support intrinsics prior to adding the validations? (If unsure, please review Intrinsic Functions before proceeding).
      • Does the pull request ensure that intrinsics remain functional with the new validations?

Examples?

Please reach out in the comments, if you want to add an example. Examples will be
added to sam init through https://github.com/awslabs/aws-sam-cli-app-templates/

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

@aahung aahung marked this pull request as ready for review September 7, 2022 23:47
@codecov-commenter
Copy link

codecov-commenter commented Sep 7, 2022

Codecov Report

Merging #2492 (7f4d616) into develop (e7a1496) will increase coverage by 0.85%.
The diff coverage is n/a.

@@             Coverage Diff             @@
##           develop    #2492      +/-   ##
===========================================
+ Coverage    93.58%   94.43%   +0.85%     
===========================================
  Files           90       97       +7     
  Lines         6124     7318    +1194     
  Branches      1260     1527     +267     
===========================================
+ Hits          5731     6911    +1180     
- Misses         183      196      +13     
- Partials       210      211       +1     
Impacted Files Coverage Δ
samtranslator/region_configuration.py 77.77% <0.00%> (-22.23%) ⬇️
samtranslator/model/codedeploy.py 90.90% <0.00%> (-9.10%) ⬇️
samtranslator/validator/validator.py 91.80% <0.00%> (-3.85%) ⬇️
samtranslator/model/exceptions.py 97.67% <0.00%> (-2.33%) ⬇️
samtranslator/open_api/open_api.py 89.67% <0.00%> (-2.30%) ⬇️
samtranslator/model/s3_utils/uri_parser.py 68.42% <0.00%> (-0.81%) ⬇️
samtranslator/model/api/http_api_generator.py 90.56% <0.00%> (-0.63%) ⬇️
samtranslator/yaml_helper.py 89.47% <0.00%> (-0.53%) ⬇️
samtranslator/translator/logical_id_generator.py 90.62% <0.00%> (-0.29%) ⬇️
samtranslator/model/apigateway.py 96.98% <0.00%> (-0.18%) ⬇️
... and 49 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@aahung aahung requested a review from a team as a code owner November 16, 2022 22:30
@aahung aahung requested a review from hoffa November 17, 2022 00:04
@aahung aahung changed the title Support "Name" for AWS::Serverless::HttpApi feat: Support "Name" for AWS::Serverless::HttpApi Nov 17, 2022
@aahung aahung merged commit d4d8f44 into aws:develop Nov 17, 2022
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