I use Serverless to create a web application that serves its static content, for example. Web font from S3 bucket. The S3 bucket is configured as a resource in my serverless.yml file. Its CORS configuration has the AllowOrigin parameter specified by a wildcard.
I want to change this to have AllowOrigin with an http endpoint of a service created without a server, for example. 31alib51b6.execute-api.eu-west-1.amazonaws.com.
I wondered if this can be configured in the serverless.yml file itself.
My example serverless.yml file:
service: example-service
provider:
name: aws
runtime: nodejs4.3
region: eu-west-1
functions:
web:
handler: handler.handler
name: ${self:service}-${self:provider.stage}
description: ${self:service} web application - ${self:provider.stage}
events:
- http:
path: web
method: get
- http:
path: web/{proxy+}
method: get
resources:
Resources:
S3Assets:
Type: AWS::S3::Bucket
Properties:
BucketName: ${self:service}-${self:provider.stage}-assets
CorsConfiguration:
CorsRules:
- AllowedMethods:
- GET
- HEAD
AllowedOrigins:
- "*"