Class: Pipedream::Role

Inherits:
Object
  • Object
show all
Includes:
Dsl::Role, Evaluate
Defined in:
lib/pipedream/role.rb

Constant Summary

Constants included from Dsl::Role

Dsl::Role::PROPERTIES

Instance Method Summary collapse

Methods included from Evaluate

#evaluate

Methods included from Dsl::Role

#iam_policy, #managed_iam_policy, #standardize_iam_policy, #standardize_managed_iam_policy

Constructor Details

#initialize(options = {}) ⇒ Role

Returns a new instance of Role.



8
9
10
11
12
# File 'lib/pipedream/role.rb', line 8

def initialize(options={})
  @options = options
  @role_path = options[:role_path] || get_role_path
  @properties = default_properties
end

Instance Method Details

#logical_idObject



35
36
37
# File 'lib/pipedream/role.rb', line 35

def logical_id
  "IamRole"
end

#runObject



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/pipedream/role.rb', line 14

def run
  evaluate(@role_path) if File.exist?(@role_path)
  @properties[:policies] = [{
    policy_name: "CodePipelineAccess",
    policy_document: {
      version: "2012-10-17",
      statement: derived_iam_statements
    }
  }]

  @properties[:managed_policy_arns] = @managed_policy_arns if @managed_policy_arns && !@managed_policy_arns.empty?

  resource = {
    logical_id => {
      type: "AWS::IAM::Role",
      properties: @properties
    }
  }
  CfnCamelizer.transform(resource)
end