ManagedPolicyProps Struct
Properties for defining an IAM managed policy.
Example
const policyDocument = {
"Version": "2012-10-17",
"Statement": [
{
"Sid": "FirstStatement",
"Effect": "Allow",
"Action": ["iam:ChangePassword"],
"Resource": ["*"],
},
{
"Sid": "SecondStatement",
"Effect": "Allow",
"Action": ["s3:ListAllMyBuckets"],
"Resource": ["*"],
},
{
"Sid": "ThirdStatement",
"Effect": "Allow",
"Action": [
"s3:List*",
"s3:Get*",
],
"Resource": [
"arn:aws:s3:::confidential-data",
"arn:aws:s3:::confidential-data/*",
],
"Condition": {"Bool": {"aws:MultiFactorAuthPresent": "true"}},
},
],
};
const customPolicyDocument = iam.PolicyDocument.fromJson(policyDocument);
// You can pass this document as an initial document to a ManagedPolicy
// or inline Policy.
const newManagedPolicy = new iam.ManagedPolicy(this, 'MyNewManagedPolicy', {
document: customPolicyDocument,
});
const newPolicy = new iam.Policy(this, 'MyNewPolicy', {
document: customPolicyDocument,
});
Properties
Typically used to store information about the permissions defined in the policy. For example, "Grants access to production DynamoDB tables." The policy description is immutable. After a value is assigned, it cannot be changed.
documentPolicyDocumentdocumentPolicyDocumentdocumentPolicyDocumentDocumentPolicyDocumentDocumentPolicyDocument= An empty policy.#If omited, any PolicyStatement provided in the statements property will be applied against the empty default PolicyDocument.
groupsIGroupRef[]groupstyping.List[IGroupRef]groupsList<IGroupRef>GroupsIGroupRef[]Groups*[]IGroupRef= No groups.#You can also use attachToGroup(group) to attach this policy to a group.
managedPolicyNamestringmanaged_policy_namestrmanagedPolicyNameStringManagedPolicyNamestringManagedPolicyName*string= A name is automatically generate…#If you specify multiple policies for an entity, specify unique names. For example, if you specify a list of policies for an IAM role, each policy must have a unique name.
default
Default: A name is automatically generated.
notes
This parameter allows (through its regex pattern) a string of characters consisting of either a forward slash (/) by itself or a string that must begin and end with forward slashes. In addition, it can contain any ASCII character from the ! (\u0021) through the DEL character (\u007F), including most punctuation characters, digits, and upper and lowercased letters.
For more information about paths, see IAM Identifiers in the IAM User Guide.
You can also use attachToRole(role) to attach this policy to a role.
statementsPolicyStatement[]statementstyping.List[PolicyStatement]statementsList<PolicyStatement>StatementsPolicyStatement[]Statements*[]PolicyStatement= No statements.#You can also use addPermission(statement) to add permissions later.