Skip to content

Commit

Permalink
fix: overwrite preset when standard or basic chosen
Browse files Browse the repository at this point in the history
  • Loading branch information
mazyu36 committed May 22, 2024
1 parent 4536c74 commit 275b495
Show file tree
Hide file tree
Showing 9 changed files with 220 additions and 15 deletions.
9 changes: 7 additions & 2 deletions packages/@aws-cdk/aws-ivs-alpha/lib/channel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ export interface ChannelProps {

/**
* An optional transcode preset for the channel. Can be used for ADVANCED_HD and ADVANCED_SD channel types.
* When LOW or STANDARD is used, the preset will be overridden and set to none regardless of the value provided.
*
* @default - Preset.HIGHER_BANDWIDTH_DELIVERY if channelType is ADVANCED_SD or ADVANCED_HD, none otherwise
*/
Expand Down Expand Up @@ -200,16 +201,20 @@ export class Channel extends ChannelBase {
throw new Error(`channelName must contain only numbers, letters, hyphens and underscores, got: '${this.physicalName}'`);
}

let preset;

if (props.type && [ChannelType.STANDARD, ChannelType.BASIC].includes(props.type) && props.preset) {
throw new Error('preset cannot be used when STANDARD or BASIC channel type');
preset = '';
} else {
preset = props.preset;
}

const resource = new CfnChannel(this, 'Resource', {
authorized: props.authorized,
latencyMode: props.latencyMode,
name: this.physicalName,
type: props.type,
preset: props.preset,
preset,
});

this.channelArn = resource.attrArn;
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,14 @@
"Preset": "CONSTRAINED_BANDWIDTH_DELIVERY",
"Type": "ADVANCED_HD"
}
},
"StandardChannelWithPresetSetting45FDEBBB": {
"Type": "AWS::IVS::Channel",
"Properties": {
"Name": "aws-cdk-ivsStandardChannelWithPresetSetting2553AADD",
"Preset": "",
"Type": "STANDARD"
}
}
},
"Outputs": {
Expand All @@ -38,6 +46,17 @@
"Export": {
"Name": "aws-cdk-ivs:ExportsOutputFnGetAttAdvancedChannelWithPresetSetting5981FCA9Arn6ED27899"
}
},
"ExportsOutputFnGetAttStandardChannelWithPresetSetting45FDEBBBArn94DAE976": {
"Value": {
"Fn::GetAtt": [
"StandardChannelWithPresetSetting45FDEBBB",
"Arn"
]
},
"Export": {
"Name": "aws-cdk-ivs:ExportsOutputFnGetAttStandardChannelWithPresetSetting45FDEBBBArn94DAE976"
}
}
},
"Parameters": {
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 15 additions & 0 deletions packages/@aws-cdk/aws-ivs-alpha/test/integ.ivs-channel-advanced.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ const advancedChannelWithPresetSetting = new ivs.Channel(stack, 'AdvancedChannel
preset: ivs.Preset.CONSTRAINED_BANDWIDTH_DELIVERY,
});

const standardChannelWithPresetSetting = new ivs.Channel(stack, 'StandardChannelWithPresetSetting', {
type: ivs.ChannelType.STANDARD,
preset: ivs.Preset.CONSTRAINED_BANDWIDTH_DELIVERY,
});

const test = new integ.IntegTest(app, 'ivs-test', {
testCases: [stack],
});
Expand All @@ -39,4 +44,14 @@ test.assertions.awsApiCall('IVS', 'GetChannel', {
},
}));

test.assertions.awsApiCall('IVS', 'GetChannel', {
arn: standardChannelWithPresetSetting.channelArn,
})
.expect(integ.ExpectedResult.objectLike({
channel: {
preset: '',
type: 'STANDARD',
},
}));

app.synth();
Loading

0 comments on commit 275b495

Please sign in to comment.