Skip to content

Instantly share code, notes, and snippets.

@favio41
Created September 19, 2018 11:00
Show Gist options
  • Save favio41/149c0d069db7695b660f8385abeaa0f3 to your computer and use it in GitHub Desktop.
Save favio41/149c0d069db7695b660f8385abeaa0f3 to your computer and use it in GitHub Desktop.
AWS cloudformation user creation with programmatic access and s3 policy
AWSTemplateFormatVersion: '2010-09-09'
Resources:
# Setup an user
user:
Type: AWS::IAM::User
Properties:
UserName: !Join
- '-'
- - 'changeme'
- !Ref 'AWS::Region'
Policies:
- PolicyName: bucket-access
PolicyDocument:
Version: '2012-10-17'
Statement:
- Effect: Allow
Action:
- s3:GetObject
Resource: arn:aws:s3:::/*
userAccesskey:
Type: AWS::IAM::AccessKey
Properties:
UserName:
!Ref user
Outputs:
AccessKeyUser:
Value:
!Ref userAccesskey
# will print first time on output variables the password.
SecretKeyUser:
Value: !GetAtt userAccesskey.SecretAccessKey
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment