Skip to content

Commit

Permalink
add validations and tests
Browse files Browse the repository at this point in the history
  • Loading branch information
go-to-k committed Sep 7, 2023
1 parent 877d5f2 commit 2a11dc4
Show file tree
Hide file tree
Showing 2 changed files with 497 additions and 9 deletions.
29 changes: 27 additions & 2 deletions packages/@aws-cdk/aws-apprunner-alpha/lib/service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1147,8 +1147,33 @@ export class Service extends cdk.Resource implements iam.IGrantable {
throw new Error('configurationValues cannot be provided if the ConfigurationSource is Repository');
}

if (this.props.healthCheckConfiguration?.path && this.props.healthCheckConfiguration?.protocol !== HealthCheckProtocolType.HTTP) {
throw new Error('Path is only applicable when you set Protocol to HTTP');
if (this.props.healthCheckConfiguration?.path !== undefined) {
if (this.props.healthCheckConfiguration?.protocol !== HealthCheckProtocolType.HTTP) {
throw new Error('path is only applicable when you set Protocol to HTTP');
}
if (this.props.healthCheckConfiguration?.path.length === 0) {
throw new Error('path length must be greater than 0');
}
}
if (this.props.healthCheckConfiguration?.healthyThreshold !== undefined) {
if (this.props.healthCheckConfiguration?.healthyThreshold < 1 || this.props.healthCheckConfiguration?.healthyThreshold > 20) {
throw new Error('healthyThreshold must be greater than or equal to 1 and less than or equal to 20');
}
}
if (this.props.healthCheckConfiguration?.unhealthyThreshold !== undefined) {
if (this.props.healthCheckConfiguration?.unhealthyThreshold < 1 || this.props.healthCheckConfiguration?.unhealthyThreshold > 20) {
throw new Error('unhealthyThreshold must be greater than or equal to 1 and less than or equal to 20');
}
}
if (this.props.healthCheckConfiguration?.interval !== undefined) {
if (this.props.healthCheckConfiguration?.interval.toSeconds() < 1 || this.props.healthCheckConfiguration?.interval.toSeconds() > 20) {
throw new Error('interval must be greater than or equal to 1 and less than or equal to 20');
}
}
if (this.props.healthCheckConfiguration?.timeout !== undefined) {
if (this.props.healthCheckConfiguration?.timeout.toSeconds() < 1 || this.props.healthCheckConfiguration?.timeout.toSeconds() > 20) {
throw new Error('timeout must be greater than or equal to 1 and less than or equal to 20');
}
}

const resource = new CfnService(this, 'Resource', {
Expand Down
Loading

0 comments on commit 2a11dc4

Please sign in to comment.