UnknownPrincipal Class
A principal for use in resources that need to have a role but it's unknown.
Some resources have roles associated with them which they assume, such as Lambda Functions, CodeBuild projects, StepFunctions machines, etc.
When those resources are imported, their actual roles are not always imported with them. When that happens, we use an instance of this class instead, which will add user warnings when statements are attempted to be added to it.
Example
ts
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import { aws_iam as iam } from 'aws-cdk-lib';
import * as constructs from 'constructs';
declare const construct: constructs.Construct;
const unknownPrincipal = new iam.UnknownPrincipal({
resource: construct,
});
python
# The code below shows an example of how to instantiate this type.
# The values are placeholders you should change.
from aws_cdk import aws_iam as iam
import constructs as constructs
# construct: constructs.Construct
unknown_principal = iam.UnknownPrincipal(
resource=construct
)
java
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import software.amazon.awscdk.services.iam.*;
import software.constructs.*;
Construct construct;
UnknownPrincipal unknownPrincipal = UnknownPrincipal.Builder.create()
.resource(construct)
.build();
csharp
// Install: dotnet add package Amazon.CDK.Lib
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
using Amazon.CDK.AWS.IAM;
using Constructs;
Construct construct;
var unknownPrincipal = new UnknownPrincipal(new UnknownPrincipalProps {
Resource = construct
});
go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import "github.com/aws/aws-cdk-go/awscdk"
import constructs "github.com/aws/constructs-go/constructs"
var construct Construct
unknownPrincipal := awscdk.Aws_iam.NewUnknownPrincipal(&UnknownPrincipalProps{
Resource: construct,
})
Initializer
ts
new UnknownPrincipal(props: UnknownPrincipalProps)
python
UnknownPrincipal(props: UnknownPrincipalProps)
java
new UnknownPrincipal(UnknownPrincipalProps props)
csharp
new UnknownPrincipal(UnknownPrincipalProps props)
go
NewUnknownPrincipal(Props UnknownPrincipalProps)
Properties
assumeRoleActionstringassume_role_actionstrassumeRoleActionStringAssumeRoleActionstringAssumeRoleAction*string#When this Principal is used in an AssumeRole policy, the action to use.
grantPrincipalIPrincipalgrant_principalIPrincipalgrantPrincipalIPrincipalGrantPrincipalIPrincipalGrantPrincipalIPrincipal#The principal to grant permissions to.
policyFragmentPrincipalPolicyFragmentpolicy_fragmentPrincipalPolicyFragmentpolicyFragmentPrincipalPolicyFragmentPolicyFragmentPrincipalPolicyFragmentPolicyFragmentPrincipalPolicyFragment#Return the policy fragment that identifies this principal in a Policy.
Methods
addToPolicy(statement: PolicyStatement): booleandef add_to_policy(self, statement: PolicyStatement) -> boolpublic Boolean addToPolicy(PolicyStatement statement)public bool AddToPolicy(PolicyStatement statement)func AddToPolicy(Statement PolicyStatement) *bool#Add to the policy of this principal.
addToPrincipalPolicy(statement: PolicyStatement): AddToPrincipalPolicyResultdef add_to_principal_policy(self, statement: PolicyStatement) -> AddToPrincipalPolicyResultpublic AddToPrincipalPolicyResult addToPrincipalPolicy(PolicyStatement statement)public AddToPrincipalPolicyResult AddToPrincipalPolicy(PolicyStatement statement)func AddToPrincipalPolicy(Statement PolicyStatement) AddToPrincipalPolicyResult#Add to the policy of this principal.