I have a current lambda function called “appNotificationService” and I want to try experimenting deploying using SAM from my local machine.
Currently I have the following SAM template.yaml
<code>AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Description: An AWS Serverless Application Model template describing your function.
Resources:
appNotificationService:
Type: AWS::Serverless::Function
Properties:
FunctionName: appNotificationService
CodeUri: .
Description: Returns app status and notification messages for the Platform
MemorySize: 128
Timeout: 3
Handler: index.handler
Runtime: nodejs20.x
Architectures:
- x86_64
EphemeralStorage:
Size: 512
EventInvokeConfig:
MaximumEventAgeInSeconds: 21600
MaximumRetryAttempts: 2
FunctionUrlConfig:
AuthType: NONE
InvokeMode: BUFFERED
Cors:
AllowCredentials: false
AllowHeaders:
- '*'
AllowMethods:
- GET
AllowOrigins:
- '*'
ExposeHeaders: ["*"]
MaxAge: 60
PackageType: Zip
Policies:
- Statement:
- Effect: Allow
Action:
- logs:CreateLogGroup
Resource: arn:aws:logs:eu-west-2:123456:*
- Effect: Allow
Action:
- logs:CreateLogStream
- logs:PutLogEvents
Resource:
- >-
arn:aws:logs:eu-west-2:123456:log-group:/aws/lambda/appNotificationService:*
SnapStart:
ApplyOn: None
RuntimeManagementConfig:
UpdateRuntimeOn: Auto
</code>
<code>AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Description: An AWS Serverless Application Model template describing your function.
Resources:
appNotificationService:
Type: AWS::Serverless::Function
Properties:
FunctionName: appNotificationService
CodeUri: .
Description: Returns app status and notification messages for the Platform
MemorySize: 128
Timeout: 3
Handler: index.handler
Runtime: nodejs20.x
Architectures:
- x86_64
EphemeralStorage:
Size: 512
EventInvokeConfig:
MaximumEventAgeInSeconds: 21600
MaximumRetryAttempts: 2
FunctionUrlConfig:
AuthType: NONE
InvokeMode: BUFFERED
Cors:
AllowCredentials: false
AllowHeaders:
- '*'
AllowMethods:
- GET
AllowOrigins:
- '*'
ExposeHeaders: ["*"]
MaxAge: 60
PackageType: Zip
Policies:
- Statement:
- Effect: Allow
Action:
- logs:CreateLogGroup
Resource: arn:aws:logs:eu-west-2:123456:*
- Effect: Allow
Action:
- logs:CreateLogStream
- logs:PutLogEvents
Resource:
- >-
arn:aws:logs:eu-west-2:123456:log-group:/aws/lambda/appNotificationService:*
SnapStart:
ApplyOn: None
RuntimeManagementConfig:
UpdateRuntimeOn: Auto
</code>
AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Description: An AWS Serverless Application Model template describing your function.
Resources:
appNotificationService:
Type: AWS::Serverless::Function
Properties:
FunctionName: appNotificationService
CodeUri: .
Description: Returns app status and notification messages for the Platform
MemorySize: 128
Timeout: 3
Handler: index.handler
Runtime: nodejs20.x
Architectures:
- x86_64
EphemeralStorage:
Size: 512
EventInvokeConfig:
MaximumEventAgeInSeconds: 21600
MaximumRetryAttempts: 2
FunctionUrlConfig:
AuthType: NONE
InvokeMode: BUFFERED
Cors:
AllowCredentials: false
AllowHeaders:
- '*'
AllowMethods:
- GET
AllowOrigins:
- '*'
ExposeHeaders: ["*"]
MaxAge: 60
PackageType: Zip
Policies:
- Statement:
- Effect: Allow
Action:
- logs:CreateLogGroup
Resource: arn:aws:logs:eu-west-2:123456:*
- Effect: Allow
Action:
- logs:CreateLogStream
- logs:PutLogEvents
Resource:
- >-
arn:aws:logs:eu-west-2:123456:log-group:/aws/lambda/appNotificationService:*
SnapStart:
ApplyOn: None
RuntimeManagementConfig:
UpdateRuntimeOn: Auto
when I deploy this I get the following error:
“Resource handler returned message: “Function creation failed because the function already exists”
my aim is to be able to make code changes etc and then deploy to the same function to update it.
Any help would be apprecitated.
Thanks