Module: AWSCDK::IAM::IIdentity

Includes:
IPrincipal, AWSCDK::IResource
Included in:
IGroup, IRole, IUser, User
Defined in:
iam/i_identity.rb

Overview

A construct that represents an IAM principal, such as a user, group or role.

[awslint:interface-extends-ref]

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.jsii_overridable_methodsObject



133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
# File 'iam/i_identity.rb', line 133

def self.jsii_overridable_methods
  {
    :grant_principal => { kind: :property, name: "grantPrincipal", is_optional: false },
    :assume_role_action => { kind: :property, name: "assumeRoleAction", is_optional: false },
    :policy_fragment => { kind: :property, name: "policyFragment", is_optional: false },
    :principal_account => { kind: :property, name: "principalAccount", is_optional: true },
    :node => { kind: :property, name: "node", is_optional: false },
    :env => { kind: :property, name: "env", is_optional: false },
    :stack => { kind: :property, name: "stack", is_optional: false },
    :add_to_principal_policy => { kind: :method, name: "addToPrincipalPolicy", is_optional: false },
    :with => { kind: :method, name: "with", is_optional: false },
    :apply_removal_policy => { kind: :method, name: "applyRemovalPolicy", is_optional: false },
    :add_managed_policy => { kind: :method, name: "addManagedPolicy", is_optional: false },
    :attach_inline_policy => { kind: :method, name: "attachInlinePolicy", is_optional: false },
  }
end

Instance Method Details

#add_managed_policy(policy) ⇒ void

This method returns an undefined value.

Attaches a managed policy to this principal.

Parameters:



117
118
119
120
# File 'iam/i_identity.rb', line 117

def add_managed_policy(policy)
  Jsii::Type.check_type(policy, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfaWFtLklNYW5hZ2VkUG9saWN5In0=")), "policy")
  jsii_call_method("addManagedPolicy", [policy])
end

#add_to_principal_policy(statement) ⇒ AWSCDK::IAM::AddToPrincipalPolicyResult

Add to the policy of this principal.



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

def add_to_principal_policy(statement)
  Jsii::Type.check_type(statement, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfaWFtLlBvbGljeVN0YXRlbWVudCJ9")), "statement")
  jsii_call_method("addToPrincipalPolicy", [statement])
end

#apply_removal_policy(policy) ⇒ void

This method returns an undefined value.

Apply the given removal policy to this resource.

The Removal Policy controls what happens to this resource when it stops being managed by CloudFormation, either because you've removed it from the CDK application or because you've made a change that requires the resource to be replaced.

The resource can be deleted (RemovalPolicy.DESTROY), or left in your AWS account for data recovery and cleanup later (RemovalPolicy.RETAIN).

Parameters:



108
109
110
111
# File 'iam/i_identity.rb', line 108

def apply_removal_policy(policy)
  Jsii::Type.check_type(policy, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5SZW1vdmFsUG9saWN5In0=")), "policy")
  jsii_call_method("applyRemovalPolicy", [policy])
end

#assume_role_actionString

When this Principal is used in an AssumeRole policy, the action to use.

Returns:

  • (String)


21
22
23
# File 'iam/i_identity.rb', line 21

def assume_role_action()
  jsii_get_property("assumeRoleAction")
end

#attach_inline_policy(policy) ⇒ void

This method returns an undefined value.

Attaches an inline policy to this principal.

This is the same as calling policy.addToXxx(principal).

Parameters:

  • policy (AWSCDK::IAM::Policy)

    The policy resource to attach to this principal [disable-awslint:ref-via-interface].



128
129
130
131
# File 'iam/i_identity.rb', line 128

def attach_inline_policy(policy)
  Jsii::Type.check_type(policy, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfaWFtLlBvbGljeSJ9")), "policy")
  jsii_call_method("attachInlinePolicy", [policy])
end

#envAWSCDK::Interfaces::ResourceEnvironment

The environment this resource belongs to.

For resources that are created and managed in a Stack (those created by creating new class instances like new Role(), new Bucket(), etc.), this is always the same as the environment of the stack they belong to.

For referenced resources (those obtained from referencing methods like Role.fromRoleArn(), Bucket.fromBucketName(), etc.), they might be different than the stack they were imported into.



62
63
64
# File 'iam/i_identity.rb', line 62

def env()
  jsii_get_property("env")
end

#grant_principalAWSCDK::IAM::IPrincipal

The principal to grant permissions to.



14
15
16
# File 'iam/i_identity.rb', line 14

def grant_principal()
  jsii_get_property("grantPrincipal")
end

#nodeConstructs::Node

The tree node.

Returns:

  • (Constructs::Node)


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

def node()
  jsii_get_property("node")
end

#policy_fragmentAWSCDK::IAM::PrincipalPolicyFragment

Return the policy fragment that identifies this principal in a Policy.



28
29
30
# File 'iam/i_identity.rb', line 28

def policy_fragment()
  jsii_get_property("policyFragment")
end

#principal_accountString?

The AWS account ID of this principal.

Can be undefined when the account is not known (for example, for service principals). Can be a Token - in that case, it's assumed to be AWS::AccountId.

Returns:

  • (String, nil)


40
41
42
# File 'iam/i_identity.rb', line 40

def ()
  jsii_get_property("principalAccount")
end

#stackAWSCDK::Stack

The stack in which this resource is defined.

Returns:



69
70
71
# File 'iam/i_identity.rb', line 69

def stack()
  jsii_get_property("stack")
end

#with(*mixins) ⇒ Constructs::IConstruct

Applies one or more mixins to this construct.

Mixins are applied in order. The list of constructs is captured at the start of the call, so constructs added by a mixin will not be visited.

Parameters:

  • mixins (Array<Constructs::IMixin>)

    The mixins to apply.

Returns:

  • (Constructs::IConstruct)

    This construct for chaining



89
90
91
92
93
94
# File 'iam/i_identity.rb', line 89

def with(*mixins)
  mixins.each_with_index do |item, index|
    Jsii::Type.check_type(item, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJjb25zdHJ1Y3RzLklNaXhpbiJ9")), "mixins[#{index}]")
  end
  jsii_call_method("with", [*mixins])
end