My serverless configuration fails to deploy and I keep getting a
The CloudFormation template is invalid: Template format error: Unresolved resource dependencies [aips-uploads-staging] in the Resources block of the template
My serverless configuration,
service: filetype
provider:
name: aws
runtime: go1.x
iamRoleStatements:
- Effect: Allow
Action:
- "s3:getObject"
Resource:
Fn::Join:
- ""
- - "arn:aws:s3:::"
- "Ref" : "${file(./config.yml):${opt:stage}.AIPS_UPLOADS_BUCKET}"
- "/*"
- Effect: Allow
Action:
- "s3:ListBucket"
- "s3:PutObject"
- "s3:GetBucketLocation"
Resource:
Fn::Join:
- ""
- - "arn:aws:s3:::"
- "Ref": "ServerlessDeploymentBucket"
- "/*"
stage: ${opt:stage}
region: ${file(./config.yml):${opt:stage}.REGION}
environment:
AIPS_UPLOADS_BUCKET: ${file(./config.yml):${opt:stage}.AIPS_UPLOADS_BUCKET}
package:
exclude:
- ./**
include:
- ./filetype
functions:
aips:
handler: filetype
memorySize: 128
events:
- s3:
bucket: ${file(./config.yml):${opt:stage}.AIPS_UPLOADS_BUCKET}
event: s3:ObjectCreated:*
timeout: 40
environment:
HOST: ${file(./config.yml):${opt:stage}.HOST}
USER: ${file(./config.yml):${opt:stage}.USER}
PASS: ${file(./config.yml):${opt:stage}.PASS}
resources:
Resources:
AipsUploadsBucket:
Type: AWS::S3::S3Bucket
Properties:
Bucket: ${file(./config.yml):${opt:stage}.AIPS_UPLOADS_BUCKET}
AipsBucketPolicy:
Type: AWS::S3::BucketPolicy
DependsOn:
- "AipsUploadsBucket"
Properties:
Bucket: "arn:aws:s3:::${file(./config.yml):${opt:stage}.AIPS_UPLOADS_BUCKET}"
PolicyDocument:
Statement:
-
Action:
- "s3:putObject"
Effect: "Deny"
Resource: "arn:aws:s3:::${file(./config.yml):${opt:stage}.AIPS_UPLOADS_BUCKET}/*"
Principal: "*"
Condition:
NotResource:
- "arn:aws:s3:::${file(./config.yml):${opt:stage}.AIPS_UPLOADS_BUCKET}/*.pdf"
- "arn:aws:s3:::${file(./config.yml):${opt:stage}.AIPS_UPLOADS_BUCKET}/*.jpg"
Stack Trace:
Error: The CloudFormation template is invalid: Template format error: Unresolved resource dependencies [aips-uploads-staging] in the Resources block of the template
at provider.request.catch (/usr/lib/node_modules/serverless/lib/plugins/aws/deploy/lib/validateTemplate.js:25:13)
From previous event:
at AwsDeploy.validateTemplate (/usr/lib/node_modules/serverless/lib/plugins/aws/deploy/lib/validateTemplate.js:20:12)
From previous event:
at AwsDeploy.BbPromise.bind.then (/usr/lib/node_modules/serverless/lib/plugins/aws/deploy/index.js:121:39)
From previous event:
at Object.aws:deploy:deploy:validateTemplate [as hook] (/usr/lib/node_modules/serverless/lib/plugins/aws/deploy/index.js:117:10)
at BbPromise.reduce (/usr/lib/node_modules/serverless/lib/classes/PluginManager.js:390:55)
From previous event:
at PluginManager.invoke (/usr/lib/node_modules/serverless/lib/classes/PluginManager.js:390:22)
at PluginManager.spawn (/usr/lib/node_modules/serverless/lib/classes/PluginManager.js:408:17)
at AwsDeploy.BbPromise.bind.then (/usr/lib/node_modules/serverless/lib/plugins/aws/deploy/index.js:95:48)
From previous event:
at Object.deploy:deploy [as hook] (/usr/lib/node_modules/serverless/lib/plugins/aws/deploy/index.js:91:10)
at BbPromise.reduce (/usr/lib/node_modules/serverless/lib/classes/PluginManager.js:390:55)
From previous event:
at PluginManager.invoke (/usr/lib/node_modules/serverless/lib/classes/PluginManager.js:390:22)
at PluginManager.run (/usr/lib/node_modules/serverless/lib/classes/PluginManager.js:421:17)
at variables.populateService.then.then (/usr/lib/node_modules/serverless/lib/Serverless.js:157:33)
at runCallback (timers.js:810:20)
at tryOnImmediate (timers.js:768:5)
at processImmediate [as _immediateCallback] (timers.js:745:5)
From previous event:
at Serverless.run (/usr/lib/node_modules/serverless/lib/Serverless.js:144:8)
at serverless.init.then (/usr/lib/node_modules/serverless/bin/serverless:43:50)
at <anonymous>
I couldn’t find any documentation on specifying S3 buckets in resources and bucket policies so, I am stuck. Please help.