PrincipalPolicyFragment Class
A collection of the fields in a PolicyStatement that can be used to identify a principal.
This consists of the JSON used in the "Principal" field, and optionally a set of "Condition"s that need to be applied to the policy.
Generally, a principal looks like:
{ '<TYPE>': ['ID', 'ID', ...] }
And this is also the type of the field principalJson. However, there is a special type of principal that is just the string '*', which is treated differently by some services. To represent that principal, principalJson should contain { 'LiteralString': ['*'] }.
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';
declare const conditions: any;
const principalPolicyFragment = new iam.PrincipalPolicyFragment({
principalJsonKey: ['principalJson'],
}, /* all optional props */ {
conditionsKey: conditions,
});
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
# conditions: Any
principal_policy_fragment = iam.PrincipalPolicyFragment({
"principal_json_key": ["principalJson"]
}, {
"conditions_key": conditions
})
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.*;
Object conditions;
PrincipalPolicyFragment principalPolicyFragment = new PrincipalPolicyFragment(Map.of(
"principalJsonKey", List.of("principalJson")), Map.of(
"conditionsKey", conditions));
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;
var conditions;
var principalPolicyFragment = new PrincipalPolicyFragment(new Dictionary<string, string[]> {
{ "principalJsonKey", new [] { "principalJson" } }
}, new Dictionary<string, object> {
{ "conditionsKey", conditions }
});
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"
var conditions interface{}
principalPolicyFragment := awscdk.Aws_iam.NewPrincipalPolicyFragment(map[string][]*string{
"principalJsonKey": []*string{
jsii.String("principalJson"),
},
}, map[string]interface{}{
"conditionsKey": conditions,
})
Initializer
ts
new PrincipalPolicyFragment(principalJson: { [key: string]: string[] }, conditions?: { [key: string]: any })
python
PrincipalPolicyFragment(principal_json: typing.Mapping[str, typing.List[str]], conditions: typing.Optional[typing.Mapping[str, Any]] = None)
java
new PrincipalPolicyFragment(Map<String, List<String>> principalJson, Map<String, Object> conditions)
csharp
new PrincipalPolicyFragment(IDictionary<string, string[]> principalJson, IDictionary<string, object>? conditions = null)
go
NewPrincipalPolicyFragment(PrincipalJson *map[string]*[]*string, Conditions *map[string]interface{})
Properties
conditions{ [key: string]: any }conditionstyping.Mapping[str, Any]conditionsMap<String, Object>ConditionsIDictionary<string, object>Conditions*map[string]interface{}#The conditions under which the policy is in effect.
See the IAM documentation. conditions that need to be applied to this policy
principalJson{ [key: string]: string[] }principal_jsontyping.Mapping[str, typing.List[str]]principalJsonMap<String, List<String>>PrincipalJsonIDictionary<string, string[]>PrincipalJson*map[string]*[]*string#JSON of the "Principal" section in a policy statement.