-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Closed
Labels
Description
Description:
Let's take as an example the following template.yml:
AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Parameters:
Timeout:
Type: Number
Default: 40
MemorySize:
Type: Number
Default: 2048
Environment:
Type: String
Default: staging
Globals:
Function:
Timeout: !Ref Timeout
MemorySize: !Ref MemorySize
Resources:
ExampleOfHttpApi:
Type: AWS::Serverless::HttpApi
Properties:
StageName: prod
Description: "Some description"
DisableExecuteApiEndpoint: True
LambdaFunctionExample:
Type: AWS::Serverless::Function
Properties:
Policies:
- Version: "2012-10-17"
Statement:
- Effect: "Allow"
Action:
- "ec2:CreateNetworkInterface"
- "ec2:DeleteNetworkInterface"
- "ec2:DescribeNetworkInterfaces"
- "ec2:DetachNetworkInterface"
Resource: "*"
VpcConfig:
SecurityGroupIds:
- "sg-0022f72578ac5b373"
SubnetIds:
- "subnet-09e403ca9d13578df"
- "subnet-00eb630443da8fc42"
- "subnet-0833fa017fa879075"
FunctionName: !Sub "LambdaFunctionExample-${Environment}"
PackageType: Image
Events:
HttpProxyEvent:
Type: HttpApi
Properties:
ApiId: !Ref ExampleOfHttpApi
Path: /{proxy+}
Method: ANY
Metadata:
DockerTag: v1
DockerContext: .
Dockerfile: DockerfileThis is perfectly valid template. What I found surprising is that the following properties are ignored:
- HttpApi::Description
- HttpApi::StageName
- HttpApi::DisableExecuteApiEndpoint
Hovewer after adding CorsConfiguration the above specified properties works.
Steps to reproduce:
- Modify the template
AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Parameters:
Timeout:
Type: Number
Default: 40
MemorySize:
Type: Number
Default: 2048
Environment:
Type: String
Default: staging
Globals:
Function:
Timeout: !Ref Timeout
MemorySize: !Ref MemorySize
Resources:
ExampleOfHttpApi:
Type: AWS::Serverless::HttpApi
Properties:
StageName: prod
Description: "Some description"
DisableExecuteApiEndpoint: True
LambdaFunctionExample:
Type: AWS::Serverless::Function
Properties:
Policies:
- Version: "2012-10-17"
Statement:
- Effect: "Allow"
Action:
- "ec2:CreateNetworkInterface"
- "ec2:DeleteNetworkInterface"
- "ec2:DescribeNetworkInterfaces"
- "ec2:DetachNetworkInterface"
Resource: "*"
VpcConfig:
SecurityGroupIds:
- "sg-0022f72578ac5b373"
SubnetIds:
- "subnet-09e403ca9d13578df"
- "subnet-00eb630443da8fc42"
- "subnet-0833fa017fa879075"
FunctionName: !Sub "LambdaFunctionExample-${Environment}"
PackageType: Image
Events:
HttpProxyEvent:
Type: HttpApi
Properties:
ApiId: !Ref ExampleOfHttpApi
Path: /{proxy+}
Method: ANY
Metadata:
DockerTag: v1
DockerContext: .
Dockerfile: Dockerfile- Run
sam build - Run
sam deploy --guided
Expected result:
I would expect that CorsConfiguration would not be required as it's specified in the documentation.
https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/sam-resource-httpapi.html#sam-httpapi-corsconfiguration
Additional environment details (Ex: Windows, Mac, Amazon Linux etc)
- OS: Linux
sam --version: 1.31.0- AWS region: eu-central-1
Reactions are currently unavailable