To create a CloudFormation template for S3, you can follow these steps:
Open a text editor and create a new file for your CloudFormation template.
Start by defining the CloudFormation template version at the top of the file, for example:
AWSTemplateFormatVersion: '2010-09-09'
Resources:
MyS3Bucket:
Type: AWS::S3::Bucket
Properties:
BucketName: my-example-bucket
Resources:
MyS3Bucket:
Type: AWS::S3::Bucket
Properties:
BucketName: my-example-bucket
VersioningConfiguration:
Status: Enabled
BucketEncryption:
ServerSideEncryptionConfiguration:
- ServerSideEncryptionByDefault:
SSEAlgorithm: AES256
Save the file with a .yaml
or .json
extension, depending on the format you prefer to use.
Upload the template to the AWS CloudFormation console or use the AWS CLI to create a stack using your template.
After the stack creation is complete, you should see your S3 bucket created with the specified configuration.
This is a basic example to get you started with creating a CloudFormation template for an S3 bucket. You can further customize and add more resources to your template as needed.