Sha256: 90a016a9c3b3be5f6ba0c9d3767f5c3bf8b558fdf35c9a33b511a0c063ee7d11

Contents?: true

Size: 776 Bytes

Versions: 3

Compression:

Stored size: 776 Bytes

Contents

class Lono::CLI
  class Iam < Base
    include Lono::Cfn::Concerns::Build
    include Lono::Cfn::Concerns::TemplateOutput

    def run
      build.template_builder.run
      resources = template_output.data['Resources']
      types = resources.map { |logical_id, attrs| attrs['Type'] }
      actions = types.map do |t|
        service = t.split('::')[1]
        "#{service.downcase}:*"
      end.uniq
      text =<<~EOL
        Version: 2012-10-17
        Statement:
        - Sid: #{@blueprint.name}
          Effect: Allow
          Resource: "*"
      EOL
      policy = YAML.load(text)
      policy['Statement'][0]['Action'] = actions
      puts "IAM Policy Example for blueprint #{@blueprint.name}".color(:green)
      puts JSON.pretty_generate(policy)
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
lono-8.0.0.pre.rc6 lib/lono/cli/iam.rb
lono-8.0.0.pre.rc5 lib/lono/cli/iam.rb
lono-8.0.0.pre.rc4 lib/lono/cli/iam.rb