Skip to content

Commit 6d64bda

Browse files
chore(iot): cannot set a value greater than 3650 days for deviceCertificateAgeCheckDuration (aws#35365)
### Issue # (if applicable) None ### Reason for this change `deviceCertificateAgeCheckDuration` has a upper bound value (3652 days) but we cannot deploy `AccountAuditConfiguration` construct when this duration is set 3651-3652 days. ```console 10:51:08 PM | UPDATE_FAILED | AWS::IoT::AccountAuditConfiguration | AuditConfiguration8C793652 Resource handler returned message: "Certificate age threshold is greater than the maximum supported threshold of 3650 days. (Service: Iot, Status Code: 400, Request ID: 20cddf20- f5a5-4f4b-8fee-140be1305778) (SDK Attempt Count: 1)" (RequestToken: 931fdbeb-f895-c970-b0a5-5e7a2f9a86be, HandlerErrorCode: InvalidRequest) ``` [AWS docs](https://docs.aws.amazon.com/iot-device-defender/latest/devguide/device-certificate-age-check.html) states that upper bound value is 3652 days but I think this statement is wrong. ### Description of changes - set update upper bound value to 3650 days from 3652 days ### Describe any new or updated permissions being added None ### Description of how you validated changes update unit test ### Checklist - [x] My code adheres to the [CONTRIBUTING GUIDE](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md) and [DESIGN GUIDELINES](https://github.com/aws/aws-cdk/blob/main/docs/DESIGN_GUIDELINES.md) ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
1 parent 382ff54 commit 6d64bda

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

packages/@aws-cdk/aws-iot-alpha/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ new iot.AccountAuditConfiguration(this, 'AuditConfiguration', {
150150
checkConfiguration: {
151151
deviceCertificateAgeCheck: true,
152152
// The default value is 365 days
153-
// Valid values range from 30 days (minimum) to 3652 days (10 years, maximum)
153+
// Valid values range from 30 days (minimum) to 3650 days (10 years, maximum)
154154
deviceCertificateAgeCheckDuration: Duration.days(365),
155155
},
156156
});

packages/@aws-cdk/aws-iot-alpha/lib/audit-configuration.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ export interface CheckConfiguration {
7171
* The duration used to check if a device certificate has been active
7272
* for a number of days greater than or equal to the number you specify.
7373
*
74-
* Valid values range from 30 days (minimum) to 3652 days (10 years, maximum).
74+
* Valid values range from 30 days (minimum) to 3650 days (10 years, maximum).
7575
*
7676
* You cannot specify a value for this check if `deviceCertificateAgeCheck` is set to `false`.
7777
*
@@ -231,8 +231,8 @@ export class AccountAuditConfiguration extends Resource implements IAccountAudit
231231
if (props?.checkConfiguration?.deviceCertificateAgeCheck === false) {
232232
throw new Error('You cannot specify a value for `deviceCertificateAgeCheckDuration` if `deviceCertificateAgeCheck` is set to `false`.');
233233
}
234-
if (!deviceAgeCheckThreshold.isUnresolved() && deviceAgeCheckThreshold.toDays() < 30 || deviceAgeCheckThreshold.toDays() > 3652) {
235-
throw new Error(`The device certificate age check threshold must be between 30 and 3652 days. got: ${deviceAgeCheckThreshold.toDays()} days.`);
234+
if (!deviceAgeCheckThreshold.isUnresolved() && deviceAgeCheckThreshold.toDays() < 30 || deviceAgeCheckThreshold.toDays() > 3650) {
235+
throw new Error(`The device certificate age check threshold must be between 30 and 3650 days. got: ${deviceAgeCheckThreshold.toDays()} days.`);
236236
}
237237
}
238238

packages/@aws-cdk/aws-iot-alpha/test/audit-configuration.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,15 +147,15 @@ test('throw error for configuring duration without enabling deviceCertificateAge
147147

148148
test.each([
149149
cdk.Duration.days(29),
150-
cdk.Duration.days(3653),
150+
cdk.Duration.days(3651),
151151
])('throw error for invalid duration %s', (duration) => {
152152
const stack = new cdk.Stack();
153153
expect(() => new iot.AccountAuditConfiguration(stack, 'AccountAuditConfiguration', {
154154
checkConfiguration: {
155155
deviceCertificateAgeCheck: true,
156156
deviceCertificateAgeCheckDuration: duration,
157157
},
158-
})).toThrow(`The device certificate age check threshold must be between 30 and 3652 days. got: ${duration.toDays()} days.`);
158+
})).toThrow(`The device certificate age check threshold must be between 30 and 3650 days. got: ${duration.toDays()} days.`);
159159
});
160160

161161
test('import by Account ID', () => {

0 commit comments

Comments
 (0)