Class CfnPolicy
A CloudFormation AWS::IAM::Policy
.
public class CfnPolicy : CfnResource, IInspectable
- Inheritance
-
CfnPolicy
- Implements
-
IInspectable
Examples
// 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 policyDocument;
var cfnPolicy = new CfnPolicy(this, "MyCfnPolicy", new CfnPolicyProps {
PolicyDocument = policyDocument,
PolicyName = "policyName",
// the properties below are optional
Groups = new [] { "groups" },
Roles = new [] { "roles" },
Users = new [] { "users" }
});
Remarks
Adds or updates an inline policy document that is embedded in the specified IAM user, group, or role.
An IAM user can also have a managed policy attached to it. For information about policies, see Managed Policies and Inline Policies in the IAM User Guide .
The Groups, Roles, and Users properties are optional. However, you must specify at least one of these properties.
For information about policy documents see Creating IAM policies in the IAM User Guide .
For information about limits on the number of inline policies that you can embed in an identity, see Limitations on IAM Entities in the IAM User Guide .
CloudformationResource: AWS::IAM::Policy
Link: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-iam-policy.html
ExampleMetadata: fixture=_generated
Constructors
CfnPolicy(Construct, string, ICfnPolicyProps)
Create a new AWS::IAM::Policy
.
public CfnPolicy(Construct scope, string id, ICfnPolicyProps props)
Parameters
scope
Construct- scope in which this resource is defined.
id
string- scoped id of the resource.
props
ICfnPolicyProps- resource properties.
Properties
CFN_RESOURCE_TYPE_NAME
The CloudFormation resource type name for this resource class.
public static string CFN_RESOURCE_TYPE_NAME { get; }
Property Value
CfnProperties
protected override IDictionary<string, object> CfnProperties { get; }
Property Value
Groups
The name of the group to associate the policy with.
public virtual string[]? Groups { get; set; }
Property Value
- string[]
Remarks
This parameter allows (through its regex pattern ) a string of characters consisting of upper and lowercase alphanumeric characters with no spaces. You can also include any of the following characters: _+=,.@-.
PolicyDocument
The policy document.
public virtual object PolicyDocument { get; set; }
Property Value
Remarks
You must provide policies in JSON format in IAM. However, for AWS CloudFormation templates formatted in YAML, you can provide the policy in JSON or YAML format. AWS CloudFormation always converts a YAML policy to JSON format before submitting it to IAM.
The regex pattern used to validate this parameter is a string of characters consisting of the following:
PolicyName
The name of the policy document.
public virtual string PolicyName { get; set; }
Property Value
Remarks
This parameter allows (through its regex pattern ) a string of characters consisting of upper and lowercase alphanumeric characters with no spaces. You can also include any of the following characters: _+=,.@-
Roles
The name of the role to associate the policy with.
public virtual string[]? Roles { get; set; }
Property Value
- string[]
Remarks
This parameter allows (per its regex pattern ) a string of characters consisting of upper and lowercase alphanumeric characters with no spaces. You can also include any of the following characters: _+=,.@-
If an external policy (such as <code>AWS::IAM::Policy</code> or <code>AWS::IAM::ManagedPolicy</code> ) has a <code>Ref</code> to a role and if a resource (such as <code>AWS::ECS::Service</code> ) also has a <code>Ref</code> to the same role, add a <code>DependsOn</code> attribute to the resource to make the resource depend on the external policy. This dependency ensures that the role's policy is available throughout the resource's lifecycle. For example, when you delete a stack with an <code>AWS::ECS::Service</code> resource, the <code>DependsOn</code> attribute ensures that AWS CloudFormation deletes the <code>AWS::ECS::Service</code> resource before deleting its role's policy.
Users
The name of the user to associate the policy with.
public virtual string[]? Users { get; set; }
Property Value
- string[]
Remarks
This parameter allows (through its regex pattern ) a string of characters consisting of upper and lowercase alphanumeric characters with no spaces. You can also include any of the following characters: _+=,.@-
Methods
Inspect(TreeInspector)
Examines the CloudFormation resource and discloses attributes.
public virtual void Inspect(TreeInspector inspector)
Parameters
inspector
TreeInspector- tree inspector to collect and process attributes.
RenderProperties(IDictionary<string, object>)
protected override IDictionary<string, object> RenderProperties(IDictionary<string, object> props)
Parameters
props
IDictionary<string, object>