Skip to content

Instantly share code, notes, and snippets.

@cldellow
Created April 11, 2020 20:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cldellow/6f5cc94e1931378affe6f35ddd3a525f to your computer and use it in GitHub Desktop.
Save cldellow/6f5cc94e1931378affe6f35ddd3a525f to your computer and use it in GitHub Desktop.
A sta
AWSTemplateFormatVersion: 2010-09-09
Description: Create an S3 bucket and IAM user with access to that bucket.
Resources:
S3Bucket:
Type: AWS::S3::Bucket
Properties:
BucketName: !Sub ${AWS::StackName}-${AWS::AccountId}
BucketEncryption:
ServerSideEncryptionConfiguration:
- ServerSideEncryptionByDefault:
SSEAlgorithm: AES256
S3User:
Type: AWS::IAM::User
Properties:
Policies:
- PolicyName: bucket-access
PolicyDocument:
Version: '2012-10-17'
Statement:
- Effect: Allow
Action:
- s3:*
Resource:
- !Sub arn:aws:s3:::${S3Bucket}
- !Sub arn:aws:s3:::${S3Bucket}/*
S3UserAccessKey:
Type: AWS::IAM::AccessKey
Properties:
UserName: !Ref S3User
Outputs:
AccessKeyID:
Value: !Ref S3UserAccessKey
SecretAccessKey:
Value: !GetAtt S3UserAccessKey.SecretAccessKey
BucketName:
Value: !Ref S3Bucket
User:
Value: !Ref S3User
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment