Deploying new style api stack locally?

I used to be able to do within services/notes-api sls deploy function -f list

Now when I do it, it says:

Invalid variable reference syntax for variable AWS::Region. You can only reference env vars, options, & files. You can check our docs for more info.

Works fine on seed, but for small changes, i’d rather just do it locally first.

Check the version of the serverless framework you have installed.

I got the same error, and after a bit of digging I realised I had 1.83.0 installed. I uninstalled it, and reinstalled with the latest version 2.7.0, and all is right with the world again.

It’s because the CloudFormation pseudo parameters are not supported in older versions - you will find the AWS::Region param being used in the cognito-policy.yml in your notes/resources dir.

There is a pseudo parameters plugin if you’d rather not upgrade to the latest serverless for whatever reason - I haven’t tried using that, as I’ve not got any other serverless projects yet, just the tutorial.

2 Likes

That’s exactly right! The newer and simpler syntax is supported in the newer versions of Serverless Framework. It works on Seed because it’s using one of the newer versions.

1 Like

Isn’t the issue that package.json set to a really old version on the github repo (serverless-bundle)? If i just update that, it would be fine?

Hmm no it’s Serverless Framework that only recently added support this syntax.

Ah right ok, it’s been a while since I installed it. For those who can’t remember

npm install -g serverless

Also @jayair can you please advise why you are keeping a lower version on the below:

“devDependencies”: {
“aws-sdk”: “^2.541.0”,
“serverless-bundle”: “^1.2.5”,
“serverless-offline”: “^5.12.0”
},

Just wondering if there is any reason for this? As we are in 3.1.0 for serverless-bundle for example.

Assuming my understanding of the hats are correct

It will update you to the most recent major version (the first number). ^1.2.3 will match any 1.x.xrelease including 1.3.0, but will hold off on 2.0.0.

Cheers.

No specific reason here. It’ll be updated in the future. There just haven’t been any breaking changes that required an update.