Reputation: 61
I am working with the following AWS SAM Template.
Resources:
PaymentFunction:
Type: 'AWS::Serverless::Function'
Properties:
FunctionName: payment_function
CodeUri: PaymentFunction/
Description: 'A lambda function to do a payment'
...
...
...
FunctionUrlConfig:
AuthType: NONE
Cors:
AllowOrigins:
- "*"
AllowHeaders:
- "*"
AllowMethods:
- "*"
Outputs:
PaymentFunctionUrl:
Value:
Fn::GetAtt: PaymentFunctionUrl.FunctionUrl
When I deploy this function with aws deploy command. I get the following function url
https://{random_string}.lambda-url.{aws_region}.on.aws/
whenever I change the LogicalResourceId i.e. PaymentFunction or actual function name i.e. payment_function, it creates a new {random_string}. that means a new function URL. Is it possible to change the function_name without changing function URL?
Upvotes: 1
Views: 1421
Reputation: 3544
I don't think it is possible. The CFN docs for the FunctionName property of an AWS Lambda function clearly states that the updating of the name requires Replacement
of the resource. This means that the old resource will be deleted and a new resource will be created with a new function URL.
Changing the LogicalResourceId
of any cfn resource will automatically create a new resource in your AWS account and delete the old one. For Lambda functions, this always results in a different function URL.
If you want to invoke lambdas using URLs that you have more control over (and can easily change the lambda function that gets executed for each path), have a look at the REST API of the Amazon API Gateway service.
Upvotes: 1