Skip to content

Commit

Permalink
feat(collection): add subscriber stack (#98)
Browse files Browse the repository at this point in the history
* feat: wire discovery to subscription

Still missing some tests, but this should close the loop with regards to
functionality.
  • Loading branch information
jta authored Nov 21, 2023
1 parent 7f716ec commit 3e33932
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 4 deletions.
59 changes: 57 additions & 2 deletions apps/collection/template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,14 @@ Metadata:
- DataAccessPointArn
- DestinationUri
- Label:
default: Components
default: Resources
Parameters:
- InstallConfig
- Label:
default: Logs
Parameters:
- LogGroupNamePatterns
- LogGroupNamePrefixes
- Label:
default: Forwarder Options
Parameters:
Expand Down Expand Up @@ -68,11 +73,32 @@ Parameters:
once per region. If you already have an existing AWS Config Recorder
installed, set this value to `false` and subscribe the S3 bucket
containing the configuration snapshots.
LogGroupNamePatterns:
Type: CommaDelimitedList
Description: >-
Comma separated list of patterns. If not empty, the lambda function will
only apply to log groups that have names that match one of the provided
strings based on a case-sensitive substring search.
Default: ''
LogGroupNamePrefixes:
Type: CommaDelimitedList
Description: >-
Comma separated list of prefixes. If not empty, the lambda function will
only apply to log groups that start with a provided string.
Default: ''

Conditions:
EnableConfig: !Equals
- !Ref InstallConfig
- "true"
EnableSubscriber: !Not
- !And
- !Equals
- !Join [",", !Ref LogGroupNamePatterns]
- ""
- !Equals
- !Join [",", !Ref LogGroupNamePrefixes]
- ""
UseStackName: !Equals
- !Ref NameOverride
- ""
Expand Down Expand Up @@ -185,7 +211,36 @@ Resources:
Parameters:
BucketName: !Ref Bucket
TopicARN: !Ref Topic

Firehose:
Type: AWS::Serverless::Application
Condition: EnableSubscriber
Properties:
Location: ../firehose/template.yaml
NotificationARNs:
- !Ref Topic
Parameters:
BucketARN: !GetAtt Bucket.Arn
Prefix: "cloudwatchlogs/"
WriterRoleService: "logs.amazonaws.com"
NameOverride: !Ref NameOverride
Subscriber:
Type: AWS::Serverless::Application
Condition: EnableSubscriber
Properties:
Location: ../subscriber/template.yaml
NotificationARNs:
- !Ref Topic
Parameters:
FilterName: 'observe-logs-subscription'
DestinationArn: !GetAtt
- Firehose
- Outputs.Firehose
RoleArn: !GetAtt
- Firehose
- Outputs.WriterRole
LogGroupNamePrefixes: !Join [",", !Ref LogGroupNamePrefixes]
LogGroupNamePatterns: !Join [",", !Ref LogGroupNamePatterns]
NameOverride: !Ref NameOverride
Outputs:
Bucket:
Description: "S3 Bucket Name"
Expand Down
5 changes: 3 additions & 2 deletions integration/tests/collection.tftest.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@ run "install_collection" {
name = "collection-stack-${run.setup.id}"
app = "collection"
parameters = {
DataAccessPointArn = run.setup.access_point.arn
DestinationUri = "s3://${run.setup.access_point.alias}"
DataAccessPointArn = run.setup.access_point.arn
DestinationUri = "s3://${run.setup.access_point.alias}"
LogGroupNamePatterns = "*"
}
capabilities = [
"CAPABILITY_NAMED_IAM",
Expand Down

0 comments on commit 3e33932

Please sign in to comment.