Skip to content

Comments

feat(mixins-preview): add recordFields and outputFormat to Vended Logs Mixin#37042

Open
ShadowCat567 wants to merge 3 commits intomainfrom
vended-logs/output-record
Open

feat(mixins-preview): add recordFields and outputFormat to Vended Logs Mixin#37042
ShadowCat567 wants to merge 3 commits intomainfrom
vended-logs/output-record

Conversation

@ShadowCat567
Copy link
Contributor

@ShadowCat567 ShadowCat567 commented Feb 20, 2026

Reason for this change

We want to support passing in outputFormat and recordFields to the VendedLogsMixin.

Description of changes

Added support for outputFormat and recordFields in the VendedLogsMixin. There are some important design decisions that happened here:

  1. toDestination() and toXRay() do not support outputFormat. This is because outputFormat is something that is set in the destination and toDestination() does not actually have direct access to the destination resource that was passed into it. If the user wants to set an outputFormat in their destination resource, we assume they already did so. toXRay does not support outputFormat because the XRay destination does not support setting an outputFormat.
  2. When we pass recordFields vs when we rely on default implementation. The default implementation of recordFields (RecordFields: undefined in the delivery) includes all possible recordFields for a delivery. I did not want to mess with this default implementation and have something that may be unexpected happen if a delivery has both optional and mandatory fields and the user does not pass in any optional fields. So when a delivery only has mandatory fields or it has mandatory fields but can take optional ones, in the case no optional fields are passed in, we use the default implementation. When optional fields are present we set RecordFields to the optional fields or if a delivery has mandatory fields we set RecordFields to the optional fields we got + the delivery's mandatory fields.

When we don't get an outputFormat for S3, Firehose, and Cloudwatch destinations, we also fall back to whatever the default is by providing undefined.
I have done my own manual testing to verify that providing undefined to OutputFormat and RecordFields works as I have described here.

Describe any new or updated permissions being added

N/A

Description of how you validated changes

Update integration and unit test coverage

Checklist


By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license

@github-actions github-actions bot added p2 valued-contributor [Pilot] contributed between 6-12 PRs to the CDK labels Feb 20, 2026
@mergify mergify bot added the contribution/core This is a PR that came from AWS. label Feb 20, 2026
@github-actions
Copy link
Contributor

github-actions bot commented Feb 20, 2026

⚠️ Experimental Feature: This security report is currently in experimental phase. Results may include false positives and the rules are being actively refined.
Please try merge from main to avoid findings unrelated to the PR.


TestsPassed ✅SkippedFailed
Security Guardian Results24 ran24 passed
TestResult
No test annotations available

@github-actions
Copy link
Contributor

github-actions bot commented Feb 20, 2026

⚠️ Experimental Feature: This security report is currently in experimental phase. Results may include false positives and the rules are being actively refined.
Please try merge from main to avoid findings unrelated to the PR.


TestsPassed ✅SkippedFailed
Security Guardian Results with resolved templates24 ran24 passed
TestResult
No test annotations available

@ShadowCat567 ShadowCat567 marked this pull request as ready for review February 20, 2026 20:02
@ShadowCat567 ShadowCat567 changed the title chore(mixins-preview): add recordFields and outputFormat to Vended Logs Mixin feat(mixins-preview): add recordFields and outputFormat to Vended Logs Mixin Feb 20, 2026
@aws-cdk-automation aws-cdk-automation added the pr/needs-maintainer-review This PR needs a review from a Core Team Member label Feb 23, 2026
Copy link
Collaborator

@aws-cdk-automation aws-cdk-automation left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The pull request linter fails with the following errors:

❌ Features must contain a change to a README file.

If you believe this pull request should receive an exemption, please comment and provide a justification. A comment requesting an exemption should contain the text Exemption Request. Additionally, if clarification is needed, add Clarification Request to a comment.

@aws-cdk-automation aws-cdk-automation removed the pr/needs-maintainer-review This PR needs a review from a Core Team Member label Feb 23, 2026
@@ -24,7 +24,10 @@ const logGroup = new logs.LogGroup(stack, 'DeliveryLogGroup', {
});

// Setup delivery
eventBus.with(CfnEventBusLogsMixin.ERROR_LOGS.toLogGroup(logGroup));
eventBus.with(CfnEventBusLogsMixin.ERROR_LOGS.toLogGroup(logGroup, {
outputFormat: CfnEventBusErrorLogsLogGroupOutputFormat.JSON,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yikes!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Allegedly you can pass strings into a string enum (like this), however typescript does not like it - gives me an error

}

/**
* Props for S3LogsDelivery
*/
export interface S3LogsDeliveryProps {
export interface IS3LogsDeliveryProps extends IDeliveryProps {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Props shouldn't be a behavioural interface.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think I understand, how should this be restructured? Since S3 has some unique things (mostly encryptionKey) that I think should be a part of props

Comment on lines +48 to 62
export interface IRecordFieldDeliveryProps {
/**
* V1
* Optional RecordFields that are not required for log delivery
* These may or may not be passed in by the user
*
* @defualt - no optional fields
*/
V1 = 'V1',
readonly optionalFields?: string[];
/**
* V2
* Required RecordFields are mandatory to be included in a log delivery
*
* @default - no mandatory fields
*/
V2 = 'V2',
readonly mandatoryFields?: string[];
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The distinction here between optionalFields and mandatoryFields seems unnecessary.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we do need both in here, I think these were just the wrong names. optionalFields is now providedFields, it represents the fields the user provided us. mandatoryFields remains pretty much the same, it's an array of a delivery's mandatory fields.

Comment on lines +105 to +106
optionalFields: props?.additionalFields,
mandatoryFields: ["resource-id","body"]
Copy link
Contributor

@mrgrain mrgrain Feb 24, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we can combine these in the code gen

Copy link
Contributor Author

@ShadowCat567 ShadowCat567 Feb 24, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is a little confusing, since optionalFields/additionalFields is public facing, while mandatoryFields is not. Yes, we can add the mandatoryFields to the additionalFields enum type, but I think we should still have the mandatoryFields passed into the LogDelivery class for the logic surrounding what we set recordFields to in there.

readonly additionalFields?: Array<CfnThingApplicationLogsAdditionalFields>;
}

export enum CfnThingApplicationLogsLogGroupOutputFormat {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

okay i see how this is getting ridiculous. maybe we do a single output format for everything and do docs and runtime validation?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what do you mean? Not all destinations share the same outputFormats?

@@ -157,5 +201,149 @@ export class CfnThingLogsMixin extends core.Mixin implements core.IMixin {
const sourceArn = service.CfnThing.arnForThing(resource);
this.logDelivery.bind(resource, this.logType, sourceArn);
}
}

export enum CfnThingApplicationLogsAdditionalFields {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm. I wonder if the enum should have all fields. We can do the adding of mandatory fields and deduplication in code.

Copy link
Contributor

@mrgrain mrgrain left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

some ideas.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

contribution/core This is a PR that came from AWS. p2 valued-contributor [Pilot] contributed between 6-12 PRs to the CDK

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants