Class: AWSCDK::IAM::GrantPolicyWithResourceOptions

Inherits:
GrantWithResourceOptions
  • Object
show all
Defined in:
iam/grant_policy_with_resource_options.rb

Overview

Options for a grant operation that directly adds a policy statement to a resource.

This differs from GrantWithResourceOptions in that it requires a pre-constructed PolicyStatement rather than constructing one from individual permissions. Use this when you need fine-grained control over the initial policy statement's contents.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(actions:, grantee:, resource_arns:, conditions: nil, resource:, resource_self_arns: nil, statement:) ⇒ GrantPolicyWithResourceOptions

Returns a new instance of GrantPolicyWithResourceOptions.

Parameters:

  • actions (Array<String>)

    The actions to grant.

  • grantee (AWSCDK::IAM::IGrantable)

    The principal to grant to.

  • resource_arns (Array<String>)

    The resource ARNs to grant to.

  • conditions (Hash{String => Hash{String => Object}}, nil) (defaults to: nil)

    Any conditions to attach to the grant.

  • resource (AWSCDK::IAM::IResourceWithPolicyV2)

    The resource with a resource policy.

  • resource_self_arns (Array<String>, nil) (defaults to: nil)

    When referring to the resource in a resource policy, use this as ARN.

  • statement (AWSCDK::IAM::PolicyStatement)

    The policy statement to add to the resource's policy.



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'iam/grant_policy_with_resource_options.rb', line 18

def initialize(actions:, grantee:, resource_arns:, conditions: nil, resource:, resource_self_arns: nil, statement:)
  @actions = actions
  Jsii::Type.check_type(@actions, JSON.parse(Base64.strict_decode64("eyJjb2xsZWN0aW9uIjp7ImVsZW1lbnR0eXBlIjp7InByaW1pdGl2ZSI6InN0cmluZyJ9LCJraW5kIjoiYXJyYXkifX0=")), "actions")
  @grantee = grantee
  Jsii::Type.check_type(@grantee, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfaWFtLklHcmFudGFibGUifQ==")), "grantee")
  @resource_arns = resource_arns
  Jsii::Type.check_type(@resource_arns, JSON.parse(Base64.strict_decode64("eyJjb2xsZWN0aW9uIjp7ImVsZW1lbnR0eXBlIjp7InByaW1pdGl2ZSI6InN0cmluZyJ9LCJraW5kIjoiYXJyYXkifX0=")), "resourceArns")
  @conditions = conditions
  Jsii::Type.check_type(@conditions, JSON.parse(Base64.strict_decode64("eyJjb2xsZWN0aW9uIjp7ImVsZW1lbnR0eXBlIjp7ImNvbGxlY3Rpb24iOnsiZWxlbWVudHR5cGUiOnsicHJpbWl0aXZlIjoiYW55In0sImtpbmQiOiJtYXAifX0sImtpbmQiOiJtYXAifX0=")), "conditions") unless @conditions.nil?
  @resource = resource
  Jsii::Type.check_type(@resource, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfaWFtLklSZXNvdXJjZVdpdGhQb2xpY3lWMiJ9")), "resource")
  @resource_self_arns = resource_self_arns
  Jsii::Type.check_type(@resource_self_arns, JSON.parse(Base64.strict_decode64("eyJjb2xsZWN0aW9uIjp7ImVsZW1lbnR0eXBlIjp7InByaW1pdGl2ZSI6InN0cmluZyJ9LCJraW5kIjoiYXJyYXkifX0=")), "resourceSelfArns") unless @resource_self_arns.nil?
  @statement = statement
  Jsii::Type.check_type(@statement, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfaWFtLlBvbGljeVN0YXRlbWVudCJ9")), "statement")
end

Instance Attribute Details

#actionsArray<String> (readonly)

The actions to grant.

Returns:

  • (Array<String>)


38
39
40
# File 'iam/grant_policy_with_resource_options.rb', line 38

def actions
  @actions
end

#conditionsHash{String => Hash{String => Object}}? (readonly)

Note:

Default: - No conditions

Any conditions to attach to the grant.

Returns:

  • (Hash{String => Hash{String => Object}}, nil)


52
53
54
# File 'iam/grant_policy_with_resource_options.rb', line 52

def conditions
  @conditions
end

#granteeAWSCDK::IAM::IGrantable (readonly)

Note:

Default: if principal is undefined, no work is done.

The principal to grant to.



43
44
45
# File 'iam/grant_policy_with_resource_options.rb', line 43

def grantee
  @grantee
end

#resourceAWSCDK::IAM::IResourceWithPolicyV2 (readonly)

The resource with a resource policy.

The statement will be added to the resource policy if it couldn't be added to the principal policy.



59
60
61
# File 'iam/grant_policy_with_resource_options.rb', line 59

def resource
  @resource
end

#resource_arnsArray<String> (readonly)

The resource ARNs to grant to.

Returns:

  • (Array<String>)


47
48
49
# File 'iam/grant_policy_with_resource_options.rb', line 47

def resource_arns
  @resource_arns
end

#resource_self_arnsArray<String>? (readonly)

Note:

Default: Same as regular resource ARNs

When referring to the resource in a resource policy, use this as ARN.

(Depending on the resource type, this needs to be '*' in a resource policy).

Returns:

  • (Array<String>, nil)


66
67
68
# File 'iam/grant_policy_with_resource_options.rb', line 66

def resource_self_arns
  @resource_self_arns
end

#statementAWSCDK::IAM::PolicyStatement (readonly)

The policy statement to add to the resource's policy.

This statement will be passed to the resource's addToResourcePolicy method. The actual handling of the statement depends on the specific IResourceWithPolicyV2 implementation.



74
75
76
# File 'iam/grant_policy_with_resource_options.rb', line 74

def statement
  @statement
end

Class Method Details

.jsii_propertiesObject



76
77
78
79
80
81
82
83
84
85
86
# File 'iam/grant_policy_with_resource_options.rb', line 76

def self.jsii_properties
  {
    :actions => "actions",
    :grantee => "grantee",
    :resource_arns => "resourceArns",
    :conditions => "conditions",
    :resource => "resource",
    :resource_self_arns => "resourceSelfArns",
    :statement => "statement",
  }
end

Instance Method Details

#to_jsiiObject



88
89
90
91
92
93
94
95
96
97
98
99
100
101
# File 'iam/grant_policy_with_resource_options.rb', line 88

def to_jsii
  result = {}
  result.merge!(super)
  result.merge!({
    "actions" => @actions,
    "grantee" => @grantee,
    "resourceArns" => @resource_arns,
    "conditions" => @conditions,
    "resource" => @resource,
    "resourceSelfArns" => @resource_self_arns,
    "statement" => @statement,
  })
  result.compact
end