fernando-mc / serverless-finch

A Serverless Framework Plugin for Static Site Deployment

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Provide custom policy and cors configuration through serverless config

mdnorman opened this issue · comments

Is your feature request related to a problem? Please describe.
I'd rather not keep multiple complete copies of a custom policy and cors configuration around. So, instead I end up telling serverless-finch to not stomp over the custom policy and cors that I set up within my serverless yaml.

In fact, for some configuration, for example CloudFrontOriginAccessIdentity, I'm not able to use a static json file at all because I need the WebAppCloudFrontOriginAccessIdentity.S3CanonicalUserId to provide to the custom policy.

For instance, this is an example of my policy in yaml:

    WebAppCloudFrontOriginAccessIdentity:
      Type: AWS::CloudFront::CloudFrontOriginAccessIdentity
      Properties:
        CloudFrontOriginAccessIdentityConfig:
          Comment: ${self:service}-${self:custom.stage}-oai

    WebAppS3BucketPolicy:
      Type: AWS::S3::BucketPolicy
      Properties:
        Bucket: !Ref WebAppS3Bucket
        PolicyDocument:
          Statement:
            - Action: 's3:Get*'
              Effect: Allow
              Resource: 'arn:aws:s3:::${self:custom.client.bucketName}/*'
              Principal:
                CanonicalUser: !GetAtt WebAppCloudFrontOriginAccessIdentity.S3CanonicalUserId

Describe the solution you'd like
I'd like a way to provide custom policy and cors within my current serverless configuration, so I can use variable interpolation from the serverless config as well as results from cloudformation itself.

Describe alternatives you've considered
Supporting variable interpolation within the json files might work for some instances, but it gets more difficult when attempting to get CloudFormation results, so there would need to be an example for that as well.