Class: AWSCDK::IAM::PolicyProps

Inherits:
Jsii::Struct
  • Object
show all
Defined in:
iam/policy_props.rb

Overview

Properties for defining an IAM inline policy document.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(document: nil, force: nil, groups: nil, policy_name: nil, roles: nil, statements: nil, users: nil) ⇒ PolicyProps

Returns a new instance of PolicyProps.

Parameters:

  • document (AWSCDK::IAM::PolicyDocument, nil) (defaults to: nil)

    Initial PolicyDocument to use for this Policy.

  • force (Boolean, nil) (defaults to: nil)

    Force creation of an AWS::IAM::Policy.

  • groups (Array<AWSCDK::IAM::IGroup>, nil) (defaults to: nil)

    Groups to attach this policy to.

  • policy_name (String, nil) (defaults to: nil)

    The name of the policy.

  • roles (Array<AWSCDK::IAM::IRole>, nil) (defaults to: nil)

    Roles to attach this policy to.

  • statements (Array<AWSCDK::IAM::PolicyStatement>, nil) (defaults to: nil)

    Initial set of permissions to add to this policy document.

  • users (Array<AWSCDK::IAM::IUser>, nil) (defaults to: nil)

    Users to attach this policy to.



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'iam/policy_props.rb', line 14

def initialize(document: nil, force: nil, groups: nil, policy_name: nil, roles: nil, statements: nil, users: nil)
  @document = document
  Jsii::Type.check_type(@document, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfaWFtLlBvbGljeURvY3VtZW50In0=")), "document") unless @document.nil?
  @force = force
  Jsii::Type.check_type(@force, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJib29sZWFuIn0=")), "force") unless @force.nil?
  @groups = groups
  Jsii::Type.check_type(@groups, JSON.parse(Base64.strict_decode64("eyJjb2xsZWN0aW9uIjp7ImVsZW1lbnR0eXBlIjp7ImZxbiI6ImF3cy1jZGstbGliLmF3c19pYW0uSUdyb3VwIn0sImtpbmQiOiJhcnJheSJ9fQ==")), "groups") unless @groups.nil?
  @policy_name = policy_name
  Jsii::Type.check_type(@policy_name, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "policyName") unless @policy_name.nil?
  @roles = roles
  Jsii::Type.check_type(@roles, JSON.parse(Base64.strict_decode64("eyJjb2xsZWN0aW9uIjp7ImVsZW1lbnR0eXBlIjp7ImZxbiI6ImF3cy1jZGstbGliLmF3c19pYW0uSVJvbGUifSwia2luZCI6ImFycmF5In19")), "roles") unless @roles.nil?
  @statements = statements
  Jsii::Type.check_type(@statements, JSON.parse(Base64.strict_decode64("eyJjb2xsZWN0aW9uIjp7ImVsZW1lbnR0eXBlIjp7ImZxbiI6ImF3cy1jZGstbGliLmF3c19pYW0uUG9saWN5U3RhdGVtZW50In0sImtpbmQiOiJhcnJheSJ9fQ==")), "statements") unless @statements.nil?
  @users = users
  Jsii::Type.check_type(@users, JSON.parse(Base64.strict_decode64("eyJjb2xsZWN0aW9uIjp7ImVsZW1lbnR0eXBlIjp7ImZxbiI6ImF3cy1jZGstbGliLmF3c19pYW0uSVVzZXIifSwia2luZCI6ImFycmF5In19")), "users") unless @users.nil?
end

Instance Attribute Details

#documentAWSCDK::IAM::PolicyDocument? (readonly)

Note:

Default: - An empty policy.

Initial PolicyDocument to use for this Policy.

If omited, any PolicyStatement provided in the statements property will be applied against the empty default PolicyDocument.

Returns:



39
40
41
# File 'iam/policy_props.rb', line 39

def document
  @document
end

#forceBoolean? (readonly)

Note:

Default: false

Force creation of an AWS::IAM::Policy.

Unless set to true, this Policy construct will not materialize to an AWS::IAM::Policy CloudFormation resource in case it would have no effect (for example, if it remains unattached to an IAM identity or if it has no statements). This is generally desired behavior, since it prevents creating invalid--and hence undeployable--CloudFormation templates.

In cases where you know the policy must be created and it is actually an error if no statements have been added to it or it remains unattached to an IAM identity, you can set this to true.

Returns:

  • (Boolean, nil)


54
55
56
# File 'iam/policy_props.rb', line 54

def force
  @force
end

#groupsArray<AWSCDK::IAM::IGroup>? (readonly)

Note:

Default: - No groups.

Groups to attach this policy to.

You can also use attach_to_group(group) to attach this policy to a group.

Returns:



61
62
63
# File 'iam/policy_props.rb', line 61

def groups
  @groups
end

#policy_nameString? (readonly)

Note:

Default: - Uses the logical ID of the policy resource, which is ensured to be unique within the stack.

The name of the policy.

If you specify multiple policies for an entity, specify unique names. For example, if you specify a list of policies for an IAM role, each policy must have a unique name.

Returns:

  • (String, nil)


70
71
72
# File 'iam/policy_props.rb', line 70

def policy_name
  @policy_name
end

#rolesArray<AWSCDK::IAM::IRole>? (readonly)

Note:

Default: - No roles.

Roles to attach this policy to.

You can also use attach_to_role(role) to attach this policy to a role.

Returns:



77
78
79
# File 'iam/policy_props.rb', line 77

def roles
  @roles
end

#statementsArray<AWSCDK::IAM::PolicyStatement>? (readonly)

Note:

Default: - No statements.

Initial set of permissions to add to this policy document.

You can also use addStatements(...statement) to add permissions later.

Returns:



84
85
86
# File 'iam/policy_props.rb', line 84

def statements
  @statements
end

#usersArray<AWSCDK::IAM::IUser>? (readonly)

Note:

Default: - No users.

Users to attach this policy to.

You can also use attach_to_user(user) to attach this policy to a user.

Returns:



91
92
93
# File 'iam/policy_props.rb', line 91

def users
  @users
end

Class Method Details

.jsii_propertiesObject



93
94
95
96
97
98
99
100
101
102
103
# File 'iam/policy_props.rb', line 93

def self.jsii_properties
  {
    :document => "document",
    :force => "force",
    :groups => "groups",
    :policy_name => "policyName",
    :roles => "roles",
    :statements => "statements",
    :users => "users",
  }
end

Instance Method Details

#to_jsiiObject



105
106
107
108
109
110
111
112
113
114
115
116
117
# File 'iam/policy_props.rb', line 105

def to_jsii
  result = {}
  result.merge!({
    "document" => @document,
    "force" => @force,
    "groups" => @groups,
    "policyName" => @policy_name,
    "roles" => @roles,
    "statements" => @statements,
    "users" => @users,
  })
  result.compact
end