Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AWS Lambda CloudTrail Events as SAM Event Source #550

Closed
MaxVynohradov opened this issue Aug 16, 2018 · 4 comments
Closed

AWS Lambda CloudTrail Events as SAM Event Source #550

MaxVynohradov opened this issue Aug 16, 2018 · 4 comments

Comments

@MaxVynohradov
Copy link

Could you please provide information/link how can I create next via AWS SAM:

  1. Go to services → CloudWatch → Rules → click on Create rule .
  2. Event Source → choose Event Pattern → select CloudWatch Logs in Service Name , AWS API Call via CloudTrail in Event Type (If you don’t have Trail setup in CloudTrail, do first. To get help refer this document), CreateLogGroup in Specific operation(s)→ Targets → select Lambda function → select previously created lambda function → click on Configure details .
  3. Give Name, Description, State should be enabled → click on Create rule .
    (taken from https://medium.com/tensult/manage-aws-cloudwatch-log-group-retention-using-automation-26add478b0c5 article.)

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.

@brettstack
Copy link
Contributor

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)

@MaxVynohradov
Copy link
Author

Got it, thanks! I think it will be a great feature, that can make our life simpler.

@jniedrauer
Copy link

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.

@jfuss
Copy link
Contributor

jfuss commented Mar 1, 2022

Pinging to clear maintainer/need-response

We do look at prioritizing feature requests based on "+1" reactions.

@jfuss jfuss changed the title AWS Lambda CloudTrail Events SAM Mapping AWS Lambda CloudTrail Events as SAM Event Source Feb 7, 2024
@aws aws locked and limited conversation to collaborators Feb 7, 2024
@jfuss jfuss converted this issue into discussion #3526 Feb 7, 2024

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Projects
None yet
Development

No branches or pull requests

5 participants