-
Notifications
You must be signed in to change notification settings - Fork 4.5k
s3: Transition Date doesn't follow the Cloudformation type #28124
Description
Describe the bug
Our application encountered an error during deployment, which occurred suddenly, and when I sought more information about it I saw that cloud formation requires a string following this pattern:
TransitionDate
Indicates when objects are transitioned to the specified storage class. The date value must be in ISO 8601 format. The time is always midnight UTC.Required: Conditional
Type: String
Pattern: ^([0-2]\d{3})-(0[0-9]|1[0-2])-([0-2]\d|3[01])T([01]\d|2[0-4]):([0-5]\d):([0-6]\d)((.\d{3})?)Z$
We were following the CDK 2.11.0 docs for creating Lifecycle Rule as follow:
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import * as cdk from 'aws-cdk-lib';
import { aws_s3 as s3 } from 'aws-cdk-lib';declare const storageClass: s3.StorageClass;
const transition: s3.Transition = {
storageClass: storageClass,// the properties below are optional
transitionAfter: cdk.Duration.minutes(30),
transitionDate: new Date(),
};
Error:
2023-11-22T00:28:19.0029491Z ❌ infrastructure/root-infra (infrastructure) failed: Error: The stack named infrastructure failed to deploy: UPDATE_ROLLBACK_COMPLETE: Properties validation failed for resource rootinfraarchiveassetsbucketarchiveassetsE1767254 with message:
2023-11-22T00:28:19.0033070Z #/LifecycleConfiguration/Rules/0/Transitions/0/TransitionDate: failed validation constraint for keyword [pattern]
2023-11-22T00:28:19.0035318Z #/LifecycleConfiguration/Rules/0/Transitions/1/TransitionDate: failed validation constraint for keyword [pattern]
Expected Behavior
Create a Lifecycle Rule following what cloud formation expects
Current Behavior
When I try to use the type suggested by cloud formation doc I get this error:
2023-11-22T19:09:59.7241797Z lib/infra-resources/storage/archive-assets.bkt.ts(30,15): error TS2322: Type 'string' is not assignable to type 'Date'.
2023-11-22T19:09:59.7245125Z lib/infra-resources/storage/archive-assets.bkt.ts(32,13): error TS2322: Type '{ storageClass: StorageClass; transitionDate: string; }' is not assignable to type 'Transition'.
2023-11-22T19:09:59.7247493Z Types of property 'transitionDate' are incompatible.
2023-11-22T19:09:59.7248423Z Type 'string' is not assignable to type 'Date'.
Reproduction Steps
Create a transition and try to set the Transition Date as the lib requires or following cloud formation doc
Possible Solution
Adjust the type for transitionDate on lifeCycleRules under transitions for aws-cdk-lib/aws-s3
Additional Information/Context
No response
CDK CLI Version
2.110.0
Framework Version
No response
Node.js Version
18.12.0
OS
MacOS
Language
TypeScript
Language Version
No response
Other information
No response