Enabling CloudTrail using CloudFormation

We will create a new script in our EffectiveDevOpsTemplates repository and call it cloudtrail-cf-template.py.

We will start with our script with our usual boilerplate:

"""Generating CloudFormation template.""" 
 
from troposphere import Join 
from troposphere import ( 
    Ref, 
    Template 
) 
from troposphere.s3 import Bucket 
from troposphere.s3 import BucketPolicy 
from troposphere.cloudtrail import Trail
t = Template() 
 
t.add_description("Effective DevOps in AWS: Turn on CloudTrail and log to S3") 

Out of the box, CloudTrail will retain 7 days' worth  of activity. In order to keep the data for longer, we will configure the service to log any activity to S3. In order to do that, we will first create an S3 bucket. ...

Get Effective DevOps with AWS now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.