You are viewing documentation for version 1 of the AWS SDK for Ruby. Version 2 documentation can be found here.

Class: AWS::Core::Policy::Statement

Inherits:
Object
  • Object
show all
Defined in:
lib/aws/core/policy.rb,
lib/aws/core/policy.rb

Overview

Represents a statement in a policy.

See Also:

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(opts = {}) {|_self| ... } ⇒ Statement

Constructs a new statement.

Parameters:

  • opts (Hash) (defaults to: {})

    a customizable set of options

Options Hash (opts):

  • :sid (String)

    The statement ID. This is optional; if omitted, a UUID will be generated for the statement.

  • :effect (String)

    The statement effect, which must be either "Allow" or "Deny". @see Policy#allow @see Policy#deny

  • :principals (String or array of strings)

    The account(s) affected by the statement. These should be AWS account IDs.

  • :actions (Object)

    The action or actions affected by the statement. These can be symbols or strings. If they are strings, you can use wildcard character "*" to match zero or more characters in the action name. Symbols are expected to match methods of S3::Client.

  • :excluded_actions (Object)

    Action or actions which are explicitly not affected by this statement. As with :actions, these may be symbols or strings.

  • :resources (String or array of strings)

    The resource(s) affected by the statement. These can be expressed as ARNs (e.g. arn:aws:s3:::mybucket/mykey) or you may omit the arn:aws:s3::: prefix and just give the path as bucket_name/key. You may use the wildcard character "*" to match zero or more characters in the resource name.

  • :conditions (ConditionBlock or Hash)

    Additional conditions that narrow the effect of the statement. It's typically more convenient to use the ConditionBuilder instance returned from Policy#allow or Policy#deny to add conditions to a statement.

Yields:

  • (_self)

Yield Parameters:

See Also:



749
750
751
752
753
754
755
756
# File 'lib/aws/core/policy.rb', line 749

def initialize(opts = {})
  self.sid = SecureRandom.uuid.tr('-','')
  self.conditions = ConditionBlock.new

  parse_options(opts)

  yield(self) if block_given?
end

Instance Attribute Details

#actionsArray

Returns an array of statement actions included by this policy statement.

Returns:

  • (Array)

    Returns an array of statement actions included by this policy statement.



703
704
705
# File 'lib/aws/core/policy.rb', line 703

def actions
  @actions
end

#conditionsArray

Returns an array of conditions for this policy.

Returns:

  • (Array)

    Returns an array of conditions for this policy.



714
715
716
# File 'lib/aws/core/policy.rb', line 714

def conditions
  @conditions
end

#effectString

Returns the statement effect, either "Allow" or "Deny"

Returns:

  • (String)

    Returns the statement effect, either "Allow" or "Deny"



696
697
698
# File 'lib/aws/core/policy.rb', line 696

def effect
  @effect
end

#excluded_actionsArray

Returns an array of actions excluded by this policy statement.

Returns:

  • (Array)

    Returns an array of actions excluded by this policy statement.



707
708
709
# File 'lib/aws/core/policy.rb', line 707

def excluded_actions
  @excluded_actions
end

#excluded_resourcesObject

Returns the value of attribute excluded_resources



716
717
718
# File 'lib/aws/core/policy.rb', line 716

def excluded_resources
  @excluded_resources
end

#principalsArray

Returns an array of principals.

Returns:

  • (Array)

    Returns an array of principals.



699
700
701
# File 'lib/aws/core/policy.rb', line 699

def principals
  @principals
end

#resourcesArray

Returns an array of resources affected by this policy statement.

Returns:

  • (Array)

    Returns an array of resources affected by this policy statement.



711
712
713
# File 'lib/aws/core/policy.rb', line 711

def resources
  @resources
end

#sidString

Returns the statement id

Returns:

  • (String)

    Returns the statement id



692
693
694
# File 'lib/aws/core/policy.rb', line 692

def sid
  @sid
end

Instance Method Details

#exclude_actions(*actions) ⇒ Object Also known as: exclude_action

Convenience method to add to the list of actions explicitly not affected by this statement.



768
769
770
771
# File 'lib/aws/core/policy.rb', line 768

def exclude_actions(*actions)
  self.excluded_actions ||= []
  self.excluded_actions.push(*actions)
end

#include_actions(*actions) ⇒ Object Also known as: include_action

Convenience method to add to the list of actions affected by this statement.



760
761
762
763
# File 'lib/aws/core/policy.rb', line 760

def include_actions(*actions)
  self.actions ||= []
  self.actions.push(*actions)
end