Let's say I have a scheduled function declared in a SAM template.yaml
myScheduledFunction:
Type: AWS::Serverless::Function
Properties:
CodeUri: ./bin
Handler: myScheduledFunction
Policies:
- AWSLambdaBasicExecutionRole
Events:
CloudwatchEvents:
Type: Schedule
Properties:
Schedule: rate(1 minute)
Enabled: true
and then I have another function that enable/disable the scheduled rule
myFunction:
Type: AWS::Serverless::Function
Properties:
CodeUri: ./bin
Handler: myFunction
Environment:
Variables:
RULE_NAME: !Ref MyRuleName
Policies:
- AWSLambdaBasicExecutionRole
- EventBridgePutEventsPolicy:
EventBusName: default
Events:
SomeEvent: ...
Now, how can I reference the rule name in environment variable RULE_NAME: !Ref MyRuleName
?
It is possible to do it in SAM? Maybe using something like !GetAtt myScheduledFunction.RuleName
?
I couldn't find anything regarding this and I know that there is a way to do it in Cloudformation, but I would know if it is possible in SAM as well, thanks.