Skip to content

Instantly share code, notes, and snippets.

@dbazile
Created June 4, 2020 14: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 dbazile/cb26f9aa8c19cffd84a2bbda51abcf35 to your computer and use it in GitHub Desktop.
Save dbazile/cb26f9aa8c19cffd84a2bbda51abcf35 to your computer and use it in GitHub Desktop.
cloudformation IAM example
Resources:
Bucket:
Type: AWS::S3::Bucket
Properties:
BucketName: test-bucketname
BucketPolicy:
Type: AWS::S3::BucketPolicy
Properties:
Bucket: !Ref Bucket
PolicyDocument:
Version: 2012-10-17
Statement:
Action:
- s3:DeleteObject
- s3:GetObject
- s3:GetObjectAcl
- s3:ListBucket
- s3:PutObject
Effect: Allow
Principal:
AWS: !GetAtt 'ServiceAccount.Arn'
Resource:
- !Sub '${Bucket.Arn}/*'
- !Sub '${Bucket.Arn}'
ServiceAccount:
Type: AWS::IAM::User
Properties:
UserName: test-username
Policies:
- PolicyName: sqs-Read
PolicyDocument:
Version: 2012-10-17
Statement:
Action:
- sqs:ReceiveMessage
Effect: Allow
Resource:
- !Sub 'arn:${AWS::Partition}:sqs:${AWS::Region}:${AWS::AccountId}:test-*'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment