@Generated(value="jsii-pacmak/1.74.0 (build 6d08790)", date="2023-03-22T19:35:36.572Z") public class CfnPolicy extends CfnResource implements IInspectable
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 limits on the number of inline policies that you can embed in an identity, see Limitations on IAM Entities in the IAM User Guide .
Example:
// The code below shows an example of how to instantiate this type. // The values are placeholders you should change. import software.amazon.awscdk.services.iam.*; Object policyDocument; CfnPolicy cfnPolicy = CfnPolicy.Builder.create(this, "MyCfnPolicy") .policyDocument(policyDocument) .policyName("policyName") // the properties below are optional .groups(List.of("groups")) .roles(List.of("roles")) .users(List.of("users")) .build();
Modifier and Type | Class and Description |
---|---|
static class |
CfnPolicy.Builder
A fluent builder for
CfnPolicy . |
IInspectable.Jsii$Default, IInspectable.Jsii$Proxy
IConstruct.Jsii$Default
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
CFN_RESOURCE_TYPE_NAME
The CloudFormation resource type name for this resource class.
|
Modifier | Constructor and Description |
---|---|
|
CfnPolicy(Construct scope,
java.lang.String id,
CfnPolicyProps props)
Create a new `AWS::IAM::Policy`.
|
protected |
CfnPolicy(software.amazon.jsii.JsiiObject.InitializationMode initializationMode) |
protected |
CfnPolicy(software.amazon.jsii.JsiiObjectRef objRef) |
Modifier and Type | Method and Description |
---|---|
protected java.util.Map<java.lang.String,java.lang.Object> |
getCfnProperties() |
java.util.List<java.lang.String> |
getGroups()
The name of the group to associate the policy with.
|
java.lang.Object |
getPolicyDocument()
The policy document.
|
java.lang.String |
getPolicyName()
The name of the policy document.
|
java.util.List<java.lang.String> |
getRoles()
The name of the role to associate the policy with.
|
java.util.List<java.lang.String> |
getUsers()
The name of the user to associate the policy with.
|
void |
inspect(TreeInspector inspector)
Examines the CloudFormation resource and discloses attributes.
|
protected java.util.Map<java.lang.String,java.lang.Object> |
renderProperties(java.util.Map<java.lang.String,java.lang.Object> props) |
void |
setGroups(java.util.List<java.lang.String> value)
The name of the group to associate the policy with.
|
void |
setPolicyDocument(java.lang.Object value)
The policy document.
|
void |
setPolicyName(java.lang.String value)
The name of the policy document.
|
void |
setRoles(java.util.List<java.lang.String> value)
The name of the role to associate the policy with.
|
void |
setUsers(java.util.List<java.lang.String> value)
The name of the user to associate the policy with.
|
addDeletionOverride, addDependsOn, addMetadata, addOverride, addPropertyDeletionOverride, addPropertyOverride, applyRemovalPolicy, applyRemovalPolicy, applyRemovalPolicy, getAtt, getCfnOptions, getCfnResourceType, getMetadata, getUpdatedProperites, isCfnResource, shouldSynthesize, toString, validateProperties
getRef
getCreationStack, getLogicalId, getStack, isCfnElement, overrideLogicalId
getNode, isConstruct, onPrepare, onSynthesize, onValidate, prepare, synthesize, validate
public static final java.lang.String CFN_RESOURCE_TYPE_NAME
protected CfnPolicy(software.amazon.jsii.JsiiObjectRef objRef)
protected CfnPolicy(software.amazon.jsii.JsiiObject.InitializationMode initializationMode)
public CfnPolicy(Construct scope, java.lang.String id, CfnPolicyProps props)
scope
- - scope in which this resource is defined. This parameter is required.id
- - scoped id of the resource. This parameter is required.props
- - resource properties. This parameter is required.public void inspect(TreeInspector inspector)
inspect
in interface IInspectable
inspector
- - tree inspector to collect and process attributes. This parameter is required.protected java.util.Map<java.lang.String,java.lang.Object> renderProperties(java.util.Map<java.lang.String,java.lang.Object> props)
renderProperties
in class CfnResource
props
- This parameter is required.protected java.util.Map<java.lang.String,java.lang.Object> getCfnProperties()
getCfnProperties
in class CfnResource
public java.lang.Object getPolicyDocument()
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:
\ u0020
) through the end of the ASCII character range\ u00FF
)\ u0009
), line feed ( \ u000A
), and carriage return ( \ u000D
)public void setPolicyDocument(java.lang.Object value)
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:
\ u0020
) through the end of the ASCII character range\ u00FF
)\ u0009
), line feed ( \ u000A
), and carriage return ( \ u000D
)public java.lang.String getPolicyName()
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: _+=,.@-
public void setPolicyName(java.lang.String value)
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: _+=,.@-
public java.util.List<java.lang.String> getGroups()
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: _+=,.@-.
public void setGroups(java.util.List<java.lang.String> value)
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: _+=,.@-.
public java.util.List<java.lang.String> getRoles()
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
orAWS::IAM::ManagedPolicy
) has aRef
to a role and if a resource (such asAWS::ECS::Service
) also has aRef
to the same role, add aDependsOn
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 anAWS::ECS::Service
resource, theDependsOn
attribute ensures that AWS CloudFormation deletes theAWS::ECS::Service
resource before deleting its role's policy.
public void setRoles(java.util.List<java.lang.String> value)
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
orAWS::IAM::ManagedPolicy
) has aRef
to a role and if a resource (such asAWS::ECS::Service
) also has aRef
to the same role, add aDependsOn
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 anAWS::ECS::Service
resource, theDependsOn
attribute ensures that AWS CloudFormation deletes theAWS::ECS::Service
resource before deleting its role's policy.
public java.util.List<java.lang.String> getUsers()
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: _+=,.@-
public void setUsers(java.util.List<java.lang.String> value)
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: _+=,.@-