Class: ElasticWhenever::Task::Role
- Inherits:
-
Object
- Object
- ElasticWhenever::Task::Role
- Defined in:
- lib/elastic_whenever/task/role.rb
Constant Summary collapse
- NAME =
"ecsEventsRole"
Instance Method Summary collapse
- #arn ⇒ Object
- #create ⇒ Object
- #exists? ⇒ Boolean
-
#initialize(option) ⇒ Role
constructor
A new instance of Role.
Constructor Details
#initialize(option) ⇒ Role
Returns a new instance of Role.
6 7 8 9 10 |
# File 'lib/elastic_whenever/task/role.rb', line 6 def initialize(option) client = Aws::IAM::Client.new(option.aws_config) @resource = Aws::IAM::Resource.new(client: client) @role = resource.role(NAME) end |
Instance Method Details
#arn ⇒ Object
26 27 28 |
# File 'lib/elastic_whenever/task/role.rb', line 26 def arn role&.arn end |
#create ⇒ Object
12 13 14 15 16 17 18 19 20 |
# File 'lib/elastic_whenever/task/role.rb', line 12 def create @role = resource.create_role( role_name: NAME, assume_role_policy_document: role_json, ) role.attach_policy( policy_arn: "arn:aws:iam::aws:policy/service-role/AmazonEC2ContainerServiceEventsRole" ) end |
#exists? ⇒ Boolean
22 23 24 |
# File 'lib/elastic_whenever/task/role.rb', line 22 def exists? !!role end |