Module: Pipedream::Dsl::Role

Included in:
Role
Defined in:
lib/pipedream/dsl/role.rb

Constant Summary collapse

PROPERTIES =
%w[
  assume_role_policy_document
  managed_policy_arns
  max_session_duration
  path
  permissions_boundary
  policies
  role_name
]

Instance Method Summary collapse

Instance Method Details

#iam_policy(*definitions) ⇒ Object

convenience wrapper methods



19
20
21
# File 'lib/pipedream/dsl/role.rb', line 19

def iam_policy(*definitions)
  @iam_statements = definitions.map { |definition| standardize_iam_policy(definition) }
end

#managed_iam_policy(*definitions) ⇒ Object



39
40
41
# File 'lib/pipedream/dsl/role.rb', line 39

def managed_iam_policy(*definitions)
  @managed_policy_arns = definitions.map { |definition| standardize_managed_iam_policy(definition) }
end

#standardize_iam_policy(definition) ⇒ Object

Returns standarized IAM statement



24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/pipedream/dsl/role.rb', line 24

def standardize_iam_policy(definition)
  case definition
  when String
    # Expands simple string from: logs => logs:*
    definition = "#{definition}:*" unless definition.include?(':')
    {
      action: [definition],
      effect: "Allow",
      resource: "*",
    }
  when Hash
    definition
  end
end

#standardize_managed_iam_policy(definition) ⇒ Object

AmazonEC2ReadOnlyAccess => arn:aws:iam::aws:policy/AmazonEC2ReadOnlyAccess



44
45
46
47
48
# File 'lib/pipedream/dsl/role.rb', line 44

def standardize_managed_iam_policy(definition)
  return definition if definition.include?('iam::aws:policy')

  "arn:aws:iam::aws:policy/#{definition}"
end