Class Policy
- Namespace
- Amazon.Auth.AccessControlPolicy
- Assembly
- AWSSDK.Core.dll
An AWS access control policy is a object that acts as a container for one or more statements, which specify fine grained rules for allowing or denying various types of actions from being performed on your AWS resources.
By default, all requests to use your resource coming from anyone but you are denied. Access control polices can override that by allowing different types of access to your resources, or by explicitly denying different types of access.
Each statement in an AWS access control policy takes the form: "A has permission to do B to C where D applies".
Note that an AWS access control policy should not be confused with the similarly named "POST form policy" concept used in Amazon S3.
public class Policy
- Inheritance
-
Policy
- Inherited Members
Constructors
Policy()
Constructs an empty AWS access control policy ready to be populated with statements.
public Policy()
Policy(string)
Constructs a new AWS access control policy with the specified policy ID. The policy ID is a user specified string that serves to help developers keep track of multiple polices. Policy IDs are often used as a human readable name for a policy.
public Policy(string id)
Parameters
id
stringThe policy ID for the new policy object. Policy IDs serve to help developers keep track of multiple policies, and are often used to give the policy a meaningful, human readable name.
Policy(string, IList<Statement>)
Constructs a new AWS access control policy with the specified policy ID and collection of statements. The policy ID is a user specified string that serves to help developers keep track of multiple polices. Policy IDs are often used as a human readable name for a policy.
public Policy(string id, IList<Statement> statements)
Parameters
id
stringThe policy ID for the new policy object. Policy IDs serve to help developers keep track of multiple policies, and are often used to give the policy a meaningful, human readable name.
statements
IList<Statement>The statements to include in the new policy.
Properties
Id
Gets and Sets the policy ID for this policy. Policy IDs serve to help developers keep track of multiple policies, and are often used as human readable name for a policy.
public string Id { get; set; }
Property Value
Statements
Gets and Sets the collection of statements contained by this policy. Individual statements in a policy are what specify the rules that enable or disable access to your AWS resources.
public IList<Statement> Statements { get; set; }
Property Value
Version
Gets and sets the version of this AWS policy.
public string Version { get; set; }
Property Value
Methods
CheckIfStatementExists(Statement)
Checks to see if the permissions set in the statement are already set by another statement in the policy.
public bool CheckIfStatementExists(Statement statement)
Parameters
statement
StatementThe statement to verify
Returns
- bool
True if the statement's permissions are already allowed by the statement
FromJson(string)
Parses a JSON document of a policy and creates a Policy object.
public static Policy FromJson(string json)
Parameters
json
stringJSON document of a policy.
Returns
ToJson()
Returns a JSON string representation of this AWS access control policy, suitable to be sent to an AWS service as part of a request to set an access control policy.
public string ToJson()
Returns
- string
A JSON string representation of this AWS access control policy.
ToJson(bool)
Returns a JSON string representation of this AWS access control policy, suitable to be sent to an AWS service as part of a request to set an access control policy.
public string ToJson(bool prettyPrint)
Parameters
prettyPrint
boolToggle pretty print for the generated JSON document
Returns
- string
A JSON string representation of this AWS access control policy.
WithId(string)
Sets the policy ID for this policy and returns the updated policy so that multiple calls can be chained together.
Policy IDs serve to help developers keep track of multiple policies, and are often used as human readable name for a policy.
public Policy WithId(string id)
Parameters
id
string
Returns
- Policy
this instance
WithStatements(params Statement[])
Sets the collection of statements contained by this policy and returns this policy object so that additional method calls can be chained together.
Individual statements in a policy are what specify the rules that enable or disable access to your AWS resources.
public Policy WithStatements(params Statement[] statements)
Parameters
statements
Statement[]The collection of statements included in this policy.
Returns
- Policy
this instance