Skip to content

Commit

Permalink
Update integration test
Browse files Browse the repository at this point in the history
  • Loading branch information
msambol committed Jun 26, 2024
1 parent 9030025 commit c6957ed
Show file tree
Hide file tree
Showing 11 changed files with 33,259 additions and 19 deletions.
25 changes: 14 additions & 11 deletions packages/@aws-cdk/aws-pipes-targets-alpha/lib/cloudwatch-logs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,23 +10,23 @@ export interface CloudWatchLogsTargetParameters {
* The input transformation to apply to the message before sending it to the target.
*
* @see https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-pipes-pipe-pipetargetparameters.html#cfn-pipes-pipe-pipetargetparameters-inputtemplate
* @default none
* @default - none
*/
readonly inputTransformation?: IInputTransformation;

/**
* The name of the log stream.
*
* @see https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-pipes-pipe-pipetargetcloudwatchlogsparameters.html#cfn-pipes-pipe-pipetargetcloudwatchlogsparameters-logstreamname
* @default none
* @default - none
*/
readonly logStreamName?: string;

/**
* The time the event occurred, expressed as the number of milliseconds after Jan 1, 1970 00:00:00 UTC.
*
* @see https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-pipes-pipe-pipetargetcloudwatchlogsparameters.html#cfn-pipes-pipe-pipetargetcloudwatchlogsparameters-timestamp
* @default none
* @default - none
*/
readonly timestamp?: string;
}
Expand All @@ -42,10 +42,13 @@ export class CloudWatchLogsTarget implements ITarget {
constructor(logGroup: ILogGroup, parameters?: CloudWatchLogsTargetParameters) {
this.logGroup = logGroup;
this.targetArn = logGroup.logGroupArn;
this.cloudWatchLogsParameters = parameters;

validateLogStreamName(this.cloudWatchLogsParameters?.logStreamName);
validateTimestamp(this.cloudWatchLogsParameters?.timestamp);
if (parameters) {
this.cloudWatchLogsParameters = parameters;
for (const validate of [validateLogStreamName, validateTimestamp]) {
validate(parameters);
}
}
}

grantPush(grantee: IRole): void {
Expand All @@ -68,15 +71,15 @@ export class CloudWatchLogsTarget implements ITarget {
}
}

function validateLogStreamName(name?: string) {
if (name !== undefined) {
if (name.length < 1 || name.length > 256) {
throw new Error(`Log stream name must be between 1 and 256 characters, received ${name.length}`);
function validateLogStreamName({ logStreamName }: CloudWatchLogsTargetParameters) {
if (logStreamName !== undefined) {
if (logStreamName.length < 1 || logStreamName.length > 256) {
throw new Error(`Log stream name must be between 1 and 256 characters, received ${logStreamName.length}`);
}
}
}

function validateTimestamp(timestamp?: string) {
function validateTimestamp({ timestamp }: CloudWatchLogsTargetParameters) {
if (timestamp !== undefined) {
if (timestamp.length < 1 || timestamp.length > 256) {
throw new Error(`Timestamp must be between 1 and 256 characters, received ${timestamp.length}`);
Expand Down
Loading

0 comments on commit c6957ed

Please sign in to comment.