lib/modulator/stack/policies.rb
# policy to access prefixed dynamo tables
policy to access prefixed dynamo tables
policy to access prefixed dynamo tables
def dynamo_db(**opts)
      prefixes = opts[:prefixes] || []
      prefix_separator = opts[:prefix_separator] || '-'
      wildcard = '*'
      if prefixes.any?
        prefixes.map!{|prefix| prefix == :app_name ? StackBuilder.stack.app_name.dasherize.split('-') : prefix}
        wildcard = "#{(prefixes << '*').join(prefix_separator)}"
      end
      {
        "policy_document" => {
          "Version" => "2012-10-17",
          'Statement' => [
            {
              "Sid" => "AllowAllActionsOnPrefixedTable",
              "Effect" => "Allow",
              "Action" => [
                  "dynamodb:*"
              ],
              "Resource" => Humidifier.fn.sub("arn:aws:dynamodb:${AWS::Region}:${AWS::AccountId}:table/#{wildcard}")
            },
            {
              "Sid" => "AdditionalPrivileges",
              "Effect" => "Allow",
              "Action" => [
                  "dynamodb:ListTables",
                  "dynamodb:DescribeTable"
              ],
              "Resource" => "*"
            }
          ]
        },
        "policy_name" => "dynamo-db-access"
      }
    end
def dynamo_db ( ** opts ) prefixes = opts [ :prefixes ] || [ ] prefix_separator = opts [ :prefix_separator ] || '-' wildcard = '*' if prefixes . any? prefixes . map! { | prefix | prefix == :app_name ? StackBuilder . stack . app_name . dasherize . split ( '-' ) : prefix } wildcard = "#{(prefixes << '*').join(prefix_separator)}" end { "policy_document" => { "Version" => "2012-10-17" , 'Statement' => [ { "Sid" => "AllowAllActionsOnPrefixedTable" , "Effect" => "Allow" , "Action" => [ "dynamodb:*" ] , "Resource" => Humidifier . fn . sub ( "arn:aws:dynamodb:${AWS::Region}:${AWS::AccountId}:table/#{wildcard}" ) } , { "Sid" => "AdditionalPrivileges" , "Effect" => "Allow" , "Action" => [ "dynamodb:ListTables" , "dynamodb:DescribeTable" ] , "Resource" => "*" } ] } , "policy_name" => "dynamo-db-access" } end
policy to access prefixed dynamo tables
policy to access prefixed dynamo tables
opts