Skip to main content

Component: datadog-logs-archive

This component is responsible for provisioning Datadog Log Archives. It creates a single log archive pipeline for each AWS account. If the catchall flag is set, it creates a catchall archive within the same S3 bucket.

Each log archive filters for the tag env:$env where $env is the environment/account name (ie sbx, prd, tools, etc), as well as any tags identified in the additional_tags key. The catchall archive, as the name implies, filters for '*'.

A second bucket is created for cloudtrail, and a cloudtrail is configured to monitor the log archive bucket and log activity to the cloudtrail bucket. To forward these cloudtrail logs to datadog, the cloudtrail bucket's id must be added to the s3_buckets key for our datadog-lambda-forwarder component.

Both buckets support object lock, with overrideable defaults of COMPLIANCE mode with a duration of 7 days.


  • Datadog integration set up in target environment
    • We rely on the datadog api and app keys added by our datadog integration component

Issues, Gotchas, Good-to-Knows

Destroy/reprovision process

Because of the protections for S3 buckets, if we want to destroy/replace our bucket, we need to do so in two passes or destroy the bucket manually and then use terraform to clean up the rest. If reprovisioning a recently provisioned bucket, the two-pass process works well. If the bucket has a full day or more of logs, though, deleting it manually first will avoid terraform timeouts, and then the terraform process can be used to clean up everything else.

Two step process to destroy via terraform

  • first set s3_force_destroy var to true and apply
  • next set enabled to false and apply or use tf destroy


Stack Level: Global

Here's an example snippet for how to use this component. It's suggested to apply this component to all accounts from which Datadog receives logs.

workspace_enabled: true
enabled: true
# additional_query_tags:
# - "forwardername:*-dev-datadog-lambda-forwarder-logs"
# - "account:123456789012"


terraform>= 0.13.0
aws>= 2.0
datadog>= 3.3.0
local>= 1.3


aws>= 2.0
datadog>= 3.7.0
http>= 2.1.0




aws_caller_identity.currentdata source
aws_partition.currentdata source
aws_ssm_parameter.datadog_api_keydata source
aws_ssm_parameter.datadog_app_keydata source
aws_ssm_parameter.datadog_aws_role_namedata source
aws_ssm_parameter.datadog_external_iddata source
http.current_orderdata source


additional_query_tagsAdditional tags to include in query for logs for this archivelist[]no
catchallSet to true to enable a catchall for logs unmatched by any queries. This should only be used in one environment/accountboolfalseno
datadog_aws_account_idThe AWS account ID Datadog's integration servers use for all integrationsstring464622532012no
enable_glacier_transitionEnable/disable transition to glacier. Has no effect unless lifecycle_rules_enabled set to truebooltrueno
glacier_transition_daysNumber of days after which to transition objects to glacier storagenumber365no
lifecycle_rules_enabledEnable/disable lifecycle management rules for s3 objectsbooltrueno
object_lock_days_archiveSet duration of archive bucket object locknumber7yes
object_lock_days_cloudtrailSet duration of cloudtrail bucket object locknumber7yes
object_lock_mode_archiveSet mode of archive bucket object lockstringCOMPLIANCEyes
object_lock_mode_cloudtrailSet mode of cloudtrail bucket object lockstringCOMPLIANCEyes
s3_force_destroySet to true to delete non-empty buckets when enabled is set to falseboolfalsefor destroy only


archive_idThe ID of the environment-specific log archive
bucket_arnThe ARN of the bucket used for log archive storage
bucket_domain_nameThe FQDN of the bucket used for log archive storage
bucket_idThe ID (name) of the bucket used for log archive storage
bucket_regionThe region of the bucket used for log archive storage
cloudtrail_bucket_arnThe ARN of the bucket used for cloudtrail log storage
cloudtrail_bucket_domain_nameThe FQDN of the bucket used for cloudtrail log storage
cloudtrail_bucket_idThe ID (name) of the bucket used for cloudtrail log storage
catchall_idThe ID of the catchall log archive