File tree Expand file tree Collapse file tree 5 files changed +60
-2
lines changed
Expand file tree Collapse file tree 5 files changed +60
-2
lines changed Original file line number Diff line number Diff line change @@ -84,6 +84,21 @@ supported.
8484` version ` defines the version of the specified database engine to use. If not
8585provided, the latest supported version will be used.
8686
87+ ## ` docs `
88+
89+ ` docs ` defines configuration for the application's documentation, if any.
90+
91+ ### ` docs.enabled `
92+
93+ ` enabled ` defines whether the documentation is enabled for the application. If
94+ not provided, defaults to ` true ` when other attributes a present in ` docs.* ` ,
95+ otherwise defaults to ` false ` .
96+
97+ ### ` docs.private `
98+
99+ ` private ` defines whether the documentation is private to the organization,
100+ requiring authentication to access. Defaults to ` false ` if not provided.
101+
87102## ` secrets `
88103
89104` secrets ` defines any secrets that the application requires. This is a map of
Original file line number Diff line number Diff line change @@ -16,3 +16,13 @@ data "aws_vpc_endpoint" "s3" {
1616data "aws_cloudfront_cache_policy" "endpoint" {
1717 name = " Managed-CachingOptimized"
1818}
19+
20+ # Find the lambda function for the Datadog forwarder so that we can use it as a
21+ # destination for CloudWatch log subscriptions.
22+ data "aws_lambda_functions" "all" {}
23+
24+ data "aws_lambda_function" "datadog" {
25+ for_each = length (local. datadog_lambda ) > 0 ? toset ([" this" ]) : toset ([])
26+
27+ function_name = local. datadog_lambda [0 ]
28+ }
Original file line number Diff line number Diff line change @@ -47,5 +47,5 @@ resource "aws_lambda_function" "oidc" {
4747
4848 runtime = " nodejs22.x"
4949
50- tags = local. tags
50+ tags = merge ( local. tags , { use = " edge-function " })
5151}
Original file line number Diff line number Diff line change 11locals {
22 apps = { for k , v in var . apps : k => v if v . docs . enabled }
3+ aws_logs_path = " /AWSLogs/${ data . aws_caller_identity . identity . account_id } "
34 build_dir = " ${ path . module } /dist"
5+ datadog_lambda = [
6+ for lambda in data . aws_lambda_functions . all . function_names :
7+ lambda if length (regexall (" ^DatadogIntegration-ForwarderStack-" , lambda)) > 0
8+ ]
49 file_dir = " ${ path . module } /files"
510 fqdn = " ${ var . subdomain } .${ var . domain } "
611 lambda_dir = " ${ path . module } /lambda"
12+ log_groups = [
13+ aws_lambda_function . oidc . logging_config [0 ]. log_group
14+ ]
715 prefix = " cfa-documentation-${ var . environment } "
816 protected_prefixes = [for k , v in local . apps : k if v . docs . private ]
917 tags_base = {
Original file line number Diff line number Diff line change @@ -60,7 +60,22 @@ module "bucket" {
6060 cloudfront_distribution_arn : aws_cloudfront_distribution.endpoint.arn,
6161 })))
6262
63- tags = local. tags
63+ s3_logging = {
64+ target_bucket = var.logging_bucket
65+ target_prefix = " ${ local . aws_logs_path } /s3accesslogs/${ var . bucket_name } "
66+ }
67+
68+ lifecycle_configuration = [{
69+ id = " static-site"
70+ status = " Enabled"
71+ prefix = " "
72+ abort_incomplete_multipart_upload_days = 7
73+ noncurrent_version_expiration = {
74+ noncurrent_days = 30
75+ }
76+ }]
77+
78+ tags = merge (local. tags , { use = " static-site" })
6479}
6580
6681resource "aws_s3_object" "robots" {
@@ -77,3 +92,13 @@ resource "aws_s3_object" "index" {
7792 content_type = " text/html"
7893 force_destroy = var. force_delete
7994}
95+
96+ resource "aws_cloudwatch_log_subscription_filter" "datadog" {
97+ depends_on = [aws_lambda_function . oidc ]
98+ for_each = length (local. datadog_lambda ) > 0 ? local. log_groups : toset ([])
99+
100+ name = " datadog"
101+ log_group_name = each. value
102+ filter_pattern = " "
103+ destination_arn = data. aws_lambda_function . datadog [" this" ]. arn
104+ }
You can’t perform that action at this time.
0 commit comments