Prevent unauthorized access to cloud storage services configured with CloudFormation
Resources:
InsecureStorage:
Type: AWS::S3::Bucket
Properties:
BucketName: my-insecure-storage
AccessControl: PublicRead
# No restrictions on public access
InsecureFS:
Type: AWS::EFS::FileSystem
Properties:
FileSystemPolicy:
Statement:
- Effect: Allow
Principal: "*"
Action: "elasticfilesystem:*"
Resource: "*"
The following CloudFormation template creates a cloud storage resource
(an Amazon S3 bucket) without enforcing any access restrictions.
Without explicit security configurations, the storage may allow public
or unauthenticated access.
This can lead to unauthorized users being able to list, read, modify,
or delete files, potentially exposing sensitive data or enabling data
tampering.
Resources:
SecureStorage:
Type: AWS::S3::Bucket
Properties:
BucketName: my-secure-storage
PublicAccessBlockConfiguration:
BlockPublicAcls: true
IgnorePublicAcls: true
BlockPublicPolicy: true
RestrictPublicBuckets: true
SecureFS:
Type: AWS::EFS::FileSystem
Properties:
FileSystemPolicy:
Statement:
- Effect: Allow
Principal:
AWS: "arn:aws:iam::123456789012:role/SecureAccessRole"
Action: "elasticfilesystem:*"
Resource: "*"
The following CloudFormation template configures cloud storage services
with strict access control to prevent unauthorized access.
- S3: Blocks public access entirely and does not use permissive ACLs.
- EFS: Restricts access using IAM policies instead of open permissions.