class Terrafying::Components::InstanceProfile
Attributes
id[R]
resource_name[R]
role_arn[R]
role_resource[R]
Public Class Methods
create(name, options = {})
click to toggle source
# File lib/terrafying/components/instanceprofile.rb, line 8 def self.create(name, options = {}) InstanceProfile.new.create name, options end
find(name)
click to toggle source
# File lib/terrafying/components/instanceprofile.rb, line 12 def self.find(name) InstanceProfile.new.find name end
new()
click to toggle source
Calls superclass method
# File lib/terrafying/components/instanceprofile.rb, line 16 def initialize super end
Public Instance Methods
add_statement!(statement)
click to toggle source
# File lib/terrafying/components/instanceprofile.rb, line 85 def add_statement!(statement) @statements << statement @policy_config[:policy] = policy end
create(name, options = {})
click to toggle source
# File lib/terrafying/components/instanceprofile.rb, line 24 def create(name, options = {}) options = { statements: [] }.merge(options) resource :aws_iam_role, name, name: name, assume_role_policy: JSON.pretty_generate( Version: '2012-10-17', Statement: [ { Effect: 'Allow', Principal: { "Service": 'ec2.amazonaws.com' }, Action: 'sts:AssumeRole' } ] ) @id = resource :aws_iam_instance_profile, name, name: name, role: output_of(:aws_iam_role, name, :name) @name = name @resource_name = "aws_iam_instance_profile.#{name}" @role_arn = output_of(:aws_iam_role, name, :arn) @role_resource = "aws_iam_role.#{name}" @statements = [ { Sid: 'Stmt1442396947000', Effect: 'Allow', Action: [ 'iam:GetGroup', 'iam:GetSSHPublicKey', 'iam:GetUser', 'iam:ListSSHPublicKeys' ], Resource: [ 'arn:aws:iam::*' ] } ].push(*options[:statements]) @policy_config = { name: @name, policy: policy, role: output_of(:aws_iam_role, @name, :name) } resource :aws_iam_role_policy, @name, @policy_config self end
find(_name)
click to toggle source
# File lib/terrafying/components/instanceprofile.rb, line 20 def find(_name) raise 'unimplemented' end
policy()
click to toggle source
# File lib/terrafying/components/instanceprofile.rb, line 78 def policy JSON.pretty_generate( Version: '2012-10-17', Statement: @statements ) end