Module: Formatron::CloudFormation::Resources::IAM
- Defined in:
- lib/formatron/cloud_formation/resources/iam.rb
Overview
Generates CloudFormation template IAM resources
Class Method Summary collapse
-
.access_key(user_name:) ⇒ Object
rubocop:enable Metrics/MethodLength.
-
.instance_profile(role:) ⇒ Object
rubocop:enable Metrics/MethodLength.
-
.policy(role:, name:, statements:) ⇒ Object
rubocop:disable Metrics/MethodLength.
-
.role ⇒ Object
rubocop:disable Metrics/MethodLength.
-
.user(policy_name:, statements:) ⇒ Object
rubocop:disable Metrics/MethodLength.
Class Method Details
.access_key(user_name:) ⇒ Object
rubocop:enable Metrics/MethodLength
83 84 85 86 87 88 89 90 |
# File 'lib/formatron/cloud_formation/resources/iam.rb', line 83 def self.access_key(user_name:) { Type: 'AWS::IAM::AccessKey', Properties: { UserName: user_name } } end |
.instance_profile(role:) ⇒ Object
rubocop:enable Metrics/MethodLength
27 28 29 30 31 32 33 34 35 |
# File 'lib/formatron/cloud_formation/resources/iam.rb', line 27 def self.instance_profile(role:) { Type: 'AWS::IAM::InstanceProfile', Properties: { Path: '/', Roles: [Template.ref(role)] } } end |
.policy(role:, name:, statements:) ⇒ Object
rubocop:disable Metrics/MethodLength
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/formatron/cloud_formation/resources/iam.rb', line 38 def self.policy(role:, name:, statements:) { Type: 'AWS::IAM::Policy', Properties: { Roles: [Template.ref(role)], PolicyName: name, PolicyDocument: { Version: '2012-10-17', Statement: statements.collect do |statement| { Effect: 'Allow', Action: statement[:actions], Resource: statement[:resources] } end } } } end |
.role ⇒ Object
rubocop:disable Metrics/MethodLength
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/formatron/cloud_formation/resources/iam.rb', line 9 def self.role { Type: 'AWS::IAM::Role', Properties: { AssumeRolePolicyDocument: { Version: '2012-10-17', Statement: [{ Effect: 'Allow', Principal: { Service: ['ec2.amazonaws.com'] }, Action: ['sts:AssumeRole'] }] }, Path: '/' } } end |
.user(policy_name:, statements:) ⇒ Object
rubocop:disable Metrics/MethodLength
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'lib/formatron/cloud_formation/resources/iam.rb', line 60 def self.user(policy_name:, statements:) { Type: 'AWS::IAM::User', Properties: { Path: '/', Policies: [{ PolicyName: policy_name, PolicyDocument: { Version: '2012-10-17', Statement: statements.collect do |statement| { Effect: 'Allow', Action: statement[:actions], Resource: statement[:resources] } end } }] } } end |