Skip to content

Commit

Permalink
chore: fix examples so lambdas have permissions for s3 buckets (#632)
Browse files Browse the repository at this point in the history
s3 Buckets and lambdas were being generated but lambda didn't have
permissions for s3 buckets. Started using prefix and Sub to
intrinsically tie them together to circumvent circular dependency
issues.
  • Loading branch information
tryantwit authored and keetonian committed Oct 26, 2018
1 parent 28236ef commit c61d17e
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 10 deletions.
7 changes: 5 additions & 2 deletions examples/apps/rekognition-python/template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@ AWSTemplateFormatVersion: '2010-09-09'
Transform: 'AWS::Serverless-2016-10-31'
Description: An Amazon S3 trigger that uses rekognition APIs to detect faces
Parameters:
BucketNameParameter:
BucketNamePrefix:
Type: String
Default: sam-example
CollectionIdParameter:
Type: String
Resources:
Expand All @@ -18,7 +19,7 @@ Resources:
Timeout: 3
Policies:
- S3CrudPolicy:
BucketName: !Ref BucketNameParameter
BucketName: !Sub "${BucketNamePrefix}-rekognition"
- RekognitionNoDataAccessPolicy:
CollectionId: !Ref CollectionIdParameter
- RekognitionWriteOnlyAccessPolicy:
Expand All @@ -33,3 +34,5 @@ Resources:
- 's3:ObjectCreated:*'
Bucket1:
Type: 'AWS::S3::Bucket'
Properties:
BucketName: !Sub "${BucketNamePrefix}-rekognition"
7 changes: 5 additions & 2 deletions examples/apps/s3-get-object-python/template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ Description: >-
An Amazon S3 trigger that retrieves metadata for the object that has been
updated.
Parameters:
BucketNameParameter:
BucketNamePrefix:
Type: String
Default: sam-example
Resources:
s3getobjectpython:
Type: 'AWS::Serverless::Function'
Expand All @@ -20,7 +21,7 @@ Resources:
Timeout: 3
Policies:
- S3CrudPolicy:
BucketName: !Ref BucketNameParameter
BucketName: !Sub "${BucketNamePrefix}-get-object-python"
Events:
BucketEvent1:
Type: S3
Expand All @@ -31,3 +32,5 @@ Resources:
- 's3:ObjectCreated:*'
Bucket1:
Type: 'AWS::S3::Bucket'
Properties:
BucketName: !Sub "${BucketNamePrefix}-get-object-python"
7 changes: 5 additions & 2 deletions examples/apps/s3-get-object-python3/template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ Description: >-
An Amazon S3 trigger that retrieves metadata for the object that has been
updated.
Parameters:
BucketNameParameter:
BucketNamePrefix:
Type: String
Default: sam-example
Resources:
s3getobjectpython3:
Type: 'AWS::Serverless::Function'
Expand All @@ -20,7 +21,7 @@ Resources:
Timeout: 3
Policies:
- S3CrudPolicy:
BucketName: !Ref BucketNameParameter
BucketName: !Sub "${BucketNamePrefix}-get-object-python3"
Events:
BucketEvent1:
Type: S3
Expand All @@ -31,3 +32,5 @@ Resources:
- 's3:ObjectCreated:*'
Bucket1:
Type: 'AWS::S3::Bucket'
Properties:
BucketName: !Sub "${BucketNamePrefix}-get-object-python3"
10 changes: 6 additions & 4 deletions examples/apps/s3-get-object/template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ Description: >-
An Amazon S3 trigger that retrieves metadata for the object that has been
updated.
Parameters:
BucketNameParameter:
BucketNamePrefix:
Type: String
Default: sam-example
Resources:
s3getobject:
Type: 'AWS::Serverless::Function'
Expand All @@ -20,14 +21,15 @@ Resources:
Timeout: 3
Policies:
- S3CrudPolicy:
BucketName: !Ref BucketNameParameter
BucketName: !Sub "${BucketNamePrefix}-get-object"
Events:
BucketEvent1:
Type: S3
Properties:
Bucket:
Ref: Bucket1
Bucket: !Ref Bucket1
Events:
- 's3:ObjectCreated:*'
Bucket1:
Type: 'AWS::S3::Bucket'
Properties:
BucketName: !Sub "${BucketNamePrefix}-get-object"

0 comments on commit c61d17e

Please sign in to comment.