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
descriptionoptionalstringdescriptionoptionalstrdescriptionoptionalStringDescriptionoptionalstringDescriptionoptional*string= empty#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.
documentoptionalPolicyDocumentdocumentoptionalPolicyDocumentdocumentoptionalPolicyDocumentDocumentoptionalPolicyDocumentDocumentoptionalPolicyDocument#Default: An empty policy.
If omited, any PolicyStatement provided in the statements property will be applied against the empty default PolicyDocument.
groupsoptionalIGroupRef[]groupsoptionaltyping.List[IGroupRef]groupsoptionalList<IGroupRef>GroupsoptionalIGroupRef[]Groupsoptional*[]IGroupRef#Default: No groups.
You can also use attachToGroup(group) to attach this policy to a group.
managedPolicyNameoptionalstringmanaged_policy_nameoptionalstrmanagedPolicyNameoptionalStringManagedPolicyNameoptionalstringManagedPolicyNameoptional*string#Default: A name is automatically generated.
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.
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.
rolesoptionalIRole[]rolesoptionaltyping.List[IRole]rolesoptionalList<IRole>RolesoptionalIRole[]Rolesoptional*[]IRole#Default: No roles.
You can also use attachToRole(role) to attach this policy to a role.
statementsoptionalPolicyStatement[]statementsoptionaltyping.List[PolicyStatement]statementsoptionalList<PolicyStatement>StatementsoptionalPolicyStatement[]Statementsoptional*[]PolicyStatement#Default: No statements.
You can also use addPermission(statement) to add permissions later.