AWSTemplateFormatVersion: '2010-09-09' Transform: AWS::Serverless-2016-10-31 Description: Serverless S3 Uploader - upload files to S3 buckets from your web applications using pre-signed URLs. # More info about Globals: https://github.com/awslabs/serverless-application-model/blob/master/docs/globals.rst Globals: Api: # Allows any site to call these APIs (can restrict by replacing asterisk with site name) # Automatically adds AllowMethods with a list of methods for this API EndpointConfiguration: EDGE Cors: AllowMethods: "'OPTIONS,GET'" AllowHeaders: "'Content-Type'" AllowOrigin: "'*'" Function: Timeout: 5 Resources: S3Bucket: Type: AWS::S3::Bucket Properties: CorsConfiguration: CorsRules: - AllowedHeaders: - "*" AllowedMethods: - GET - PUT - POST - DELETE - HEAD AllowedOrigins: - "*" S3UploaderFunction: # More info about Function Resource: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#awsserverlessfunction Type: AWS::Serverless::Function Properties: CodeUri: s3UploaderFunction/ Handler: app.handler Runtime: nodejs12.x MemorySize: 128 Environment: Variables: UploadBucket: !Ref S3Bucket Policies: - S3CrudPolicy: BucketName: !Ref S3Bucket Events: HttpPost: Type: Api Properties: Path: '/' Method: get Outputs: S3UploaderFunction: Description: "Lambda Function ARN" Value: !GetAtt S3UploaderFunction.Arn S3UploaderFunctionIamRole: Description: "Implicit IAM Role created for function" Value: !GetAtt S3UploaderFunctionRole.Arn S3BucketName: Description: S3 bucket Value: !Ref S3Bucket