Could you please provide information/link how can I create next via AWS SAM:
I've not found any information how I can describe this Event Source / Event Type (AWS API Call via CloudTrail) for lambda function (step 2) in AWS SAM template.yaml file
** I've already asked this question on StackOverflow, but nobody answers.
Hi @MaxVinogradov, we don't currently support CloudTrail+Lambda natively in SAM. You can create CloudTrail resources using CloudFormation https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-cloudtrail-trail.html. There are likely additional Resources you'll need to specify to link CloudTrail with Lambda.
I've tagged this as a feature request to add native support in SAM to make this much simpler (similar to our existing CloudWatchLogs support https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#cloudwatchlogs)
Got it, thanks! I think it will be a great feature, that can make our life simpler.
I've been able to get this type of event (AWS API Call via CloudTrail) to work as in this example:
Events:
CloudTrailScalerTrigger:
Properties:
Pattern:
detail:
eventName:
- CreateService
- UpdateService
eventSource:
- ecs.amazonaws.com
requestParameters:
cluster:
- Ref: EcsCluster
detail-type:
- AWS API Call via CloudTrail
source:
- aws.ecs
Type: CloudWatchEvent
Maybe this is a hack, I'm not sure. But it seems to work just fine.