A CLI tool to browse and inject SAM Policy Templates into your SAM template
Last updated 3 months ago by mhlabs .
ISC · Bugs · Original npm · Tarball · package.json
$ cnpm install @mhlabs/sam-policies-cli 
SYNC missed versions from official npm registry.


CLI tool to browse and inject AWS Policy Templates into the Policies array of an AWS::Serverless::Function in a SAM template


npm install -g @mhlabs/sam-policies-cli


sam-pol -t template.yaml -f yaml
  -v, --vers                 output the current version
  -f, --format <json|yaml>   Select output format (default: "json")
  -t, --template <filename>  Template file name (default: "serverless.template")
  -h, --help                 output usage information

This is intended to set policies for Lambda functions to be allowed to integrate with resources that is managed by your template. However, sometimes you might want to create a policy for a resource that doesn't exist in your template and/or you might need to specify the resource name by wildcard or by other means. To achieve this, select Not Templated from the first selection list.




  • Both JSON and YAML options will reformat your template, but especially JSON shouldn't break it. It's therefore a good idea to run this command on a template without any local changes so you can easily diff the injection and reformatting. For safety it will create a backup of your template in <template_filename>_backup before making any changes.
  • CloudFormation and SAM Policy Templates are inconsistent with which intrinsic function should be used to inject the resource identifier to the policy template transformation. Sometimes it's !Ref and sometimes !GetAtt We're making a manual mapping which could be wrong and assumes !Ref when no mapping exists.

Current Tags

  • 1.0.7                                ...           latest (3 months ago)

8 Versions

  • 1.0.7                                ...           3 months ago
  • 1.0.6                                ...           3 months ago
  • 1.0.5                                ...           3 months ago
  • 1.0.4                                ...           4 months ago
  • 1.0.3                                ...           4 months ago
  • 1.0.2                                ...           4 months ago
  • 1.0.1                                ...           4 months ago
  • 1.0.0                                ...           4 months ago
Maintainers (1)
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 2
Dependencies (5)
Dev Dependencies (1)
Dependents (0)

Copyright 2014 - 2016 © taobao.org |