Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

s3: Transition Date doesn't follow the Cloudformation type #28124

Closed
wakeupmh opened this issue Nov 23, 2023 · 3 comments
Closed

s3: Transition Date doesn't follow the Cloudformation type #28124

wakeupmh opened this issue Nov 23, 2023 · 3 comments
Labels
@aws-cdk/aws-s3 Related to Amazon S3 bug This issue is a bug. duplicate This issue is a duplicate. effort/medium Medium work item – several days of effort p2

Comments

@wakeupmh
Copy link

wakeupmh commented Nov 23, 2023

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

@wakeupmh wakeupmh added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Nov 23, 2023
@github-actions github-actions bot added the @aws-cdk/aws-s3 Related to Amazon S3 label Nov 23, 2023
@wakeupmh wakeupmh changed the title (s3): (Transition Date doesn't follow the Cloudformation type) s3: Transition Date doesn't follow the Cloudformation type Nov 23, 2023
@msambol
Copy link
Contributor

msambol commented Nov 24, 2023

I'll take this. It's related to #28065.

@khushail
Copy link
Contributor

@wakeupmh ,thanks for reporting this.
@msambol , yes , you are right. Thanks for volunteering to work on this.

@khushail khushail added p2 duplicate This issue is a duplicate. effort/medium Medium work item – several days of effort and removed needs-triage This issue or PR still needs to be triaged. labels Nov 24, 2023
mergify bot pushed a commit that referenced this issue Nov 28, 2023
Copy link

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see.
If you need more assistance, please either tag a team member or open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@aws-cdk/aws-s3 Related to Amazon S3 bug This issue is a bug. duplicate This issue is a duplicate. effort/medium Medium work item – several days of effort p2
Projects
None yet
Development

No branches or pull requests

3 participants