Skip to content

Instantly share code, notes, and snippets.

@mpgxc
Last active September 30, 2024 18:17
Show Gist options
  • Save mpgxc/c7e93e17854e90a77363bd92fcea243e to your computer and use it in GitHub Desktop.
Save mpgxc/c7e93e17854e90a77363bd92fcea243e to your computer and use it in GitHub Desktop.
Provisionar Bucket S3 Standard com regra de LifeCycle com S3 Glacier
service: backup-reports
provider:
  name: aws
  runtime: nodejs20.x
  region: us-east-1
  stage: ${opt:stage, 'dev'}
  iam:
    role:
      statements:
        - Effect: "Allow"
          Action:
            - "s3:PutObject"
            - "s3:GetObject"
            - "s3:ListBucket"
          Resource:
            - arn:aws:s3:::${self:service}-bucket/*
            - arn:aws:s3:::${self:service}-bucket
resources:
  Resources:
    BackupReportsBucket:
      Type: AWS::S3::Bucket
      Properties:
        BucketName: '${self:service}-bucket'
        BucketEncryption:
          ServerSideEncryptionConfiguration:
            - ServerSideEncryptionByDefault:
                SSEAlgorithm: AES256
        PublicAccessBlockConfiguration:
          BlockPublicAcls: true
          IgnorePublicAcls: true
          BlockPublicPolicy: true
          RestrictPublicBuckets: true
        LifecycleConfiguration:
          Rules:
            - Id: "MoveToGlacierAfter30DaysProduction"
              Status: Enabled
              Prefix: "production/"
              Transitions:
                - TransitionInDays: 30
                  StorageClass: GLACIER
            - Id: "MoveToGlacierAfter30DaysHomolog"
              Status: Enabled
              Prefix: "homolog/"
              Transitions:
                - TransitionInDays: 30
                  StorageClass: GLACIER
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment