I’m trying to dynamically assemble a resource arn for a policy in the Resources section of my serverless.yml file. I’m able to get all the things I need except for the ApiGatewayRestApi id. I’ve looked at assembling variables like ${cf:${self:service}-${self:provider.stage}.ApiGatewayRestApi} but get the following error returned to my terminal:
Invalid variable reference syntax for variable cf:<myAPIName>.ApiGatewayRestApi.
You can only reference env vars, options, & files. You
can check our docs for more info.
I’ve also tried ${self:resources.Resources.ApiGatewayRestApi}, ${self:resources.ApiGatewayRestApi}, and ${self:resources.Outputs.ApiGatewayRestApi} with similar results.
Is the resource you’re trying to reference in the same stack as where you’re referencing it? If so, use Ref (as per @buggy’s comment) - the ${cf:...} variable syntax is for CloudFormation Outputs (i.e. from other stacks).