@Generated(value="jsii-pacmak/1.67.0 (build 2c027f5)", date="2022-09-19T20:26:39.725Z") @Stability(value=Stable) 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. |
software.amazon.jsii.JsiiObject.InitializationModeIInspectable.Jsii$Default, IInspectable.Jsii$Proxy| Modifier and Type | Field and Description |
|---|---|
static String |
CFN_RESOURCE_TYPE_NAME
The CloudFormation resource type name for this resource class.
|
| Modifier | Constructor and Description |
|---|---|
|
CfnPolicy(software.constructs.Construct scope,
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 Map<String,Object> |
getCfnProperties() |
List<String> |
getGroups()
The name of the group to associate the policy with.
|
Object |
getPolicyDocument()
The policy document.
|
String |
getPolicyName()
The name of the policy document.
|
List<String> |
getRoles()
The name of the role to associate the policy with.
|
List<String> |
getUsers()
The name of the user to associate the policy with.
|
void |
inspect(TreeInspector inspector)
Examines the CloudFormation resource and discloses attributes.
|
protected Map<String,Object> |
renderProperties(Map<String,Object> props) |
void |
setGroups(List<String> value)
The name of the group to associate the policy with.
|
void |
setPolicyDocument(Object value)
The policy document.
|
void |
setPolicyName(String value)
The name of the policy document.
|
void |
setRoles(List<String> value)
The name of the role to associate the policy with.
|
void |
setUsers(List<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, getUpdatedProperties, isCfnResource, shouldSynthesize, toString, validatePropertiesgetRefgetCreationStack, getLogicalId, getStack, isCfnElement, overrideLogicalIdjsiiAsyncCall, jsiiAsyncCall, jsiiCall, jsiiCall, jsiiGet, jsiiGet, jsiiSet, jsiiStaticCall, jsiiStaticCall, jsiiStaticGet, jsiiStaticGet, jsiiStaticSet, jsiiStaticSet@Stability(value=Stable) public static final String CFN_RESOURCE_TYPE_NAME
protected CfnPolicy(software.amazon.jsii.JsiiObjectRef objRef)
protected CfnPolicy(software.amazon.jsii.JsiiObject.InitializationMode initializationMode)
@Stability(value=Stable)
public CfnPolicy(@NotNull
software.constructs.Construct scope,
@NotNull
String id,
@NotNull
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.@Stability(value=Stable)
public void inspect(@NotNull
TreeInspector inspector)
inspect in interface IInspectableinspector - - tree inspector to collect and process attributes. This parameter is required.@Stability(value=Stable) @NotNull protected Map<String,Object> renderProperties(@NotNull Map<String,Object> props)
renderProperties in class CfnResourceprops - This parameter is required.@Stability(value=Stable) @NotNull protected Map<String,Object> getCfnProperties()
getCfnProperties in class CfnResource@Stability(value=Stable) @NotNull public 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 )@Stability(value=Stable)
public void setPolicyDocument(@NotNull
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 )@Stability(value=Stable) @NotNull public 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: _+=,.@-
@Stability(value=Stable)
public void setPolicyName(@NotNull
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: _+=,.@-
@Stability(value=Stable) @Nullable public List<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: _+=,.@-.
@Stability(value=Stable)
public void setGroups(@Nullable
List<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: _+=,.@-.
@Stability(value=Stable) @Nullable public List<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::PolicyorAWS::IAM::ManagedPolicy) has aRefto a role and if a resource (such asAWS::ECS::Service) also has aRefto the same role, add aDependsOnattribute 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::Serviceresource, theDependsOnattribute ensures that AWS CloudFormation deletes theAWS::ECS::Serviceresource before deleting its role's policy.
@Stability(value=Stable)
public void setRoles(@Nullable
List<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::PolicyorAWS::IAM::ManagedPolicy) has aRefto a role and if a resource (such asAWS::ECS::Service) also has aRefto the same role, add aDependsOnattribute 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::Serviceresource, theDependsOnattribute ensures that AWS CloudFormation deletes theAWS::ECS::Serviceresource before deleting its role's policy.
@Stability(value=Stable) @Nullable public List<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: _+=,.@-
@Stability(value=Stable)
public void setUsers(@Nullable
List<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: _+=,.@-
Copyright © 2022. All rights reserved.