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. ...