Tous les labs

Secure a CloudFormation template

Intermediate ~30 mincfn

Analyze and repair a template so its S3 bucket has encryption, public-access blocking, versioning, and retention controls.

Template CloudFormation (YAML)
Objectifs
  • Preserve a valid `Resources` section.
  • Add bucket encryption and all public-access-block flags.
  • Enable versioning.
  • Add deletion and replacement retention policies.
Indices
Voir la solution
AWSTemplateFormatVersion: '2010-09-09'
Description: Repair this result bucket
Resources:
  ResultsBucket:
    Type: AWS::S3::Bucket
    DeletionPolicy: Retain
    UpdateReplacePolicy: Retain
    Properties:
      Tags:
        - Key: Project
          Value: academy
      BucketEncryption:
        ServerSideEncryptionConfiguration:
          - ServerSideEncryptionByDefault:
              SSEAlgorithm: AES256
      PublicAccessBlockConfiguration:
        BlockPublicAcls: true
        IgnorePublicAcls: true
        BlockPublicPolicy: true
        RestrictPublicBuckets: true
      VersioningConfiguration:
        Status: Enabled