Advertisement
Guest User

Untitled

a guest
Jul 21st, 2019
230
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.14 KB | None | 0 0
  1. ---
  2. AWSTemplateFormatVersion: '2010-09-09'
  3. Description: some-sftp-server
  4.  
  5. Parameters:
  6. HostedZoneIdParam:
  7. Type: String
  8. Description: Hosted Zone ID
  9. SFTPHostnameParam:
  10. Type: String
  11. Description: Hostname for the SFTP Server
  12.  
  13. Resources:
  14. SFTPServer:
  15. Type: AWS::Transfer::Server
  16. Properties:
  17. EndpointType: PUBLIC
  18. Tags:
  19. - Key: Application
  20. Value: some-sftp-servver
  21.  
  22. SFTPServerDNSRecord:
  23. Type: AWS::Route53::RecordSet
  24. Properties:
  25. Name: !Ref SFTPHostnameParam
  26. HostedZoneId: !Ref HostedZoneIdParam
  27. Type: CNAME
  28. Comment: SFTP Transfer custom hostname
  29. TTL: 300
  30. ResourceRecords:
  31. - !Sub ${SFTPServer.ServerId}.server.transfer.${AWS::Region}.amazonaws.com
  32.  
  33. SFTPServerS3Bucket:
  34. Type: AWS::S3::Bucket
  35. DeletionPolicy: Retain
  36. Properties:
  37. BucketName: some-sftp-bucket
  38. PublicAccessBlockConfiguration:
  39. BlockPublicAcls: true
  40. BlockPublicPolicy: true
  41. IgnorePublicAcls: true
  42. RestrictPublicBuckets: true
  43. Tags:
  44. - Key: Application
  45. Value: some-sftp-servver
  46.  
  47. SFTPUserRole:
  48. Type: AWS::IAM::Role
  49. Properties:
  50. AssumeRolePolicyDocument:
  51. Version: '2012-10-17'
  52. Statement:
  53. - Effect: Allow
  54. Principal:
  55. Service:
  56. - transfer.amazonaws.com
  57. Action:
  58. - sts:AssumeRole
  59. Path: /
  60. Policies:
  61. - PolicyName: S3FullAccess
  62. PolicyDocument:
  63. Version: '2012-10-17'
  64. Statement:
  65. - Effect: Allow
  66. Action:
  67. - s3:ListAllMyBuckets
  68. - s3:GetBucketLocation
  69. Resource: "*"
  70. - PolicyName: AllowListingOfUserFolder
  71. PolicyDocument:
  72. Version: '2012-10-17'
  73. Statement:
  74. - Effect: Allow
  75. Action:
  76. - s3:ListBucket
  77. Resource: !GetAtt SFTPServerS3Bucket.Arn
  78. - PolicyName: HomeDirObjectAccess
  79. PolicyDocument:
  80. Version: '2012-10-17'
  81. Statement:
  82. - Effect: Allow
  83. Action:
  84. - s3:PutObject
  85. - s3:GetObject
  86. - s3:GetObjectVersion
  87. - s3:DeleteObject
  88. - s3:DeleteObjectVersion
  89. Resource: !Sub "${SFTPServerS3Bucket.Arn}/*"
  90.  
  91. TestUser:
  92. Type: AWS::Transfer::User
  93. Properties:
  94. ServerId: !GetAtt SFTPServer.ServerId
  95. UserName: john
  96. HomeDirectory: !Sub "/${SFTPServerS3Bucket}/home/john"
  97. Policy: >
  98. {
  99. "Version": "2012-10-17",
  100. "Statement": [
  101. {
  102. "Sid": "AllowListingOfUserFolder",
  103. "Effect": "Allow",
  104. "Action": "s3:ListBucket",
  105. "Resource": "arn:aws:s3:::${transfer:HomeBucket}",
  106. "Condition": {
  107. "StringLike": {
  108. "s3:prefix": [
  109. "home/${transfer:UserName}/*",
  110. "home/${transfer:UserName}"
  111. ]
  112. }
  113. }
  114. },
  115. {
  116. "Sid": "HomeDirObjectAccess",
  117. "Effect": "Allow",
  118. "Action": [
  119. "s3:PutObject",
  120. "s3:GetObject",
  121. "s3:GetObjectVersion",
  122. "s3:DeleteObject",
  123. "s3:DeleteObjectVersion"
  124. ],
  125. "Resource": "arn:aws:s3:::${transfer:HomeDirectory}*"
  126. }
  127. ]
  128. }
  129. Role: !GetAtt SFTPUserRole.Arn
  130. SshPublicKeys:
  131. - ssh-rsa AAAAB3NzaC1********************************cMNTZKrQTDjrpvCJ83w== john.doe@gmail.com
  132. Tags:
  133. - Key: Application
  134. Value: some-sftp-server
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement