Class CfnPolicy
A CloudFormation AWS::IAM::Policy
.
Inherited Members
Namespace: Amazon.CDK.AWS.IAM
Assembly: Amazon.CDK.AWS.IAM.dll
Syntax (csharp)
public class CfnPolicy : CfnResource, IConstruct, IDependable, IInspectable
Syntax (vb)
Public Class CfnPolicy
Inherits CfnResource
Implements IConstruct, IDependable, IInspectable
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
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" }
});
Synopsis
Constructors
CfnPolicy(Construct, String, ICfnPolicyProps) | Create a new |
CfnPolicy(ByRefValue) | Used by jsii to construct an instance of this class from a Javascript-owned object reference |
CfnPolicy(DeputyBase.DeputyProps) | Used by jsii to construct an instance of this class from DeputyProps |
Properties
CFN_RESOURCE_TYPE_NAME | The CloudFormation resource type name for this resource class. |
CfnProperties | |
Groups | The name of the group to associate the policy with. |
PolicyDocument | The policy document. |
PolicyName | The name of the policy document. |
Roles | The name of the role to associate the policy with. |
Users | The name of the user to associate the policy with. |
Methods
Inspect(TreeInspector) | Examines the CloudFormation resource and discloses attributes. |
RenderProperties(IDictionary<String, Object>) |
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 System.String
- scoped id of the resource.
- props ICfnPolicyProps
- resource properties.
CfnPolicy(ByRefValue)
Used by jsii to construct an instance of this class from a Javascript-owned object reference
protected CfnPolicy(ByRefValue reference)
Parameters
- reference Amazon.JSII.Runtime.Deputy.ByRefValue
The Javascript-owned object reference
CfnPolicy(DeputyBase.DeputyProps)
Used by jsii to construct an instance of this class from DeputyProps
protected CfnPolicy(DeputyBase.DeputyProps props)
Parameters
- props Amazon.JSII.Runtime.Deputy.DeputyBase.DeputyProps
The deputy props
Properties
CFN_RESOURCE_TYPE_NAME
The CloudFormation resource type name for this resource class.
public static string CFN_RESOURCE_TYPE_NAME { get; }
Property Value
System.String
CfnProperties
protected override IDictionary<string, object> CfnProperties { get; }
Property Value
System.Collections.Generic.IDictionary<System.String, System.Object>
Overrides
Groups
The name of the group to associate the policy with.
public virtual string[] Groups { get; set; }
Property Value
System.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
System.Object
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
System.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: _+=,.@-
Roles
The name of the role to associate the policy with.
public virtual string[] Roles { get; set; }
Property Value
System.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 AWS::IAM::Policy
or AWS::IAM::ManagedPolicy
) has a Ref
to a role and if a resource (such as AWS::ECS::Service
) also has a Ref
to the same role, add a DependsOn
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 AWS::ECS::Service
resource, the DependsOn
attribute ensures that AWS CloudFormation deletes the AWS::ECS::Service
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
System.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 System.Collections.Generic.IDictionary<System.String, System.Object>
Returns
System.Collections.Generic.IDictionary<System.String, System.Object>