Reputation: 21
I'm using a yaml AWS SAM file for CI/CD purposes.I need to add a new tag with the functionName as a value for that tag in each lambda function in that file.
Is it possible to do this without the need to define that tag separately in each function, knowing that I already have a functionName property already set for each lambda?
So Instead of this
Resources:
Function1:
Type: AWS::Serverless::Function
Properties:
FunctionName: function1
Tags:
MyTag: function1 # << check this
Function2:
Type: AWS::Serverless::Function
Properties:
FunctionName: function2
Tags:
MyTag: function2 # << check this
Im wondering if I can do this:
Globals:
Function:
Tags:
MyTag: <FunctionName> # << reference to function name
Resources:
Function1:
Type: AWS::Serverless::Function
Properties:
FunctionName: function1
Function2:
Type: AWS::Serverless::Function
Properties:
FunctionName: function2
Upvotes: 0
Views: 911
Reputation: 765
Two ways to do this, check which one works for you
Using reference for instance in your case if you want to refer "Function1" you should use Ref: "Function1" or Ref: "Function1LambdaFunction" (incase its defined using function tag)
Get Attribute function - for instance in your case it would be (you can replace "Function1" to "Function1LambdaFunction" if you are using a direct function tag
- Fn::GetAtt: [Function1, FunctionName]
Upvotes: 0