Code Monkey home page Code Monkey logo

s3-lifecycle-rules-cdk's Introduction

s3-lifecycle-rules-cdk

Simple project on s3 buckets lifecycle rules for quick reference.

CDK

    const bucket = new s3.Bucket(this, 'MyFirstBucket', {
      versioned: true,
      lifecycleRules: [
        {
          id: "delete-old-objects", 
          enabled: true,
          prefix: 'persist-aws/BD/',
          abortIncompleteMultipartUploadAfter: cdk.Duration.days(30),
          noncurrentVersionsToRetain: 10,
          noncurrentVersionExpiration: cdk.Duration.days(60),
          expiration: cdk.Duration.days(60),
        },
        {
          id: "change-objects-to-new-class", 
          enabled: true,
          transitions: [
            {
              storageClass: s3.StorageClass.INFREQUENT_ACCESS,
              transitionAfter: cdk.Duration.days(30),
            },
            {
              storageClass: s3.StorageClass.INTELLIGENT_TIERING,
              transitionAfter: cdk.Duration.days(60),
            },
            {
              storageClass: s3.StorageClass.GLACIER,
              transitionAfter: cdk.Duration.days(90),
            },
            {
              storageClass: s3.StorageClass.DEEP_ARCHIVE,
              transitionAfter: cdk.Duration.days(180),
            },
          ],
        }
      ]
    });

Cloud Formation

Voici quelques exemples de règles de cicle de vie:

  MyFirstBucketB8884501:
    Type: AWS::S3::Bucket
    Properties:
      LifecycleConfiguration:
        Rules:
        
          # Supprimer versions actuels and anciennes copies:
          - Id: delete-old-objects
            AbortIncompleteMultipartUpload:
              DaysAfterInitiation: 30
            ExpirationInDays: 60
            NoncurrentVersionExpiration:
              NewerNoncurrentVersions: 10
              NoncurrentDays: 60
            Prefix: persist-aws/BD/ # (optionel) s'applique seulement a un prefix
            Status: Enabled

          # Changer la classe des objects après un moment pour payer moins par heure:
          - Id: change-objects-to-new-class
            Status: Enabled
            Transitions:
              - StorageClass: STANDARD_IA
                TransitionInDays: 30
              - StorageClass: INTELLIGENT_TIERING
                TransitionInDays: 60
              - StorageClass: GLACIER
                TransitionInDays: 90
              - StorageClass: DEEP_ARCHIVE
                TransitionInDays: 180

Reference

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.