java.lang.Object
software.amazon.jsii.JsiiObject
software.constructs.Construct
All Implemented Interfaces:
IInspectable, ITaggable, software.amazon.jsii.JsiiSerializable, software.constructs.IConstruct, software.constructs.IDependable

@Generated(value="jsii-pacmak/1.98.0 (build 00b106d)", date="2024-05-08T21:35:10.384Z") @Stability(Stable) public class CfnPolicy extends CfnResource implements IInspectable, ITaggable
Creates a policy of a specified type that you can attach to a root, an organizational unit (OU), or an individual AWS account .

For more information about policies and their use, see Managing AWS Organizations policies .

If the request includes tags, then the requester must have the organizations:TagResource permission.

This operation can be called only from the organization's management account.

Before you can create a policy of a given type, you must first enable that policy type in your organization.

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.organizations.*;
 Object content;
 CfnPolicy cfnPolicy = CfnPolicy.Builder.create(this, "MyCfnPolicy")
         .content(content)
         .name("name")
         .type("type")
         // the properties below are optional
         .description("description")
         .tags(List.of(CfnTag.builder()
                 .key("key")
                 .value("value")
                 .build()))
         .targetIds(List.of("targetIds"))
         .build();
 

See Also:
  • Field Details

    • CFN_RESOURCE_TYPE_NAME

      @Stability(Stable) public static final String CFN_RESOURCE_TYPE_NAME
      The CloudFormation resource type name for this resource class.
  • Constructor Details

    • CfnPolicy

      protected CfnPolicy(software.amazon.jsii.JsiiObjectRef objRef)
    • CfnPolicy

      protected CfnPolicy(software.amazon.jsii.JsiiObject.InitializationMode initializationMode)
    • CfnPolicy

      @Stability(Stable) public CfnPolicy(@NotNull software.constructs.Construct scope, @NotNull String id, @NotNull CfnPolicyProps props)
      Parameters:
      scope - Scope in which this resource is defined. This parameter is required.
      id - Construct identifier for this resource (unique in its scope). This parameter is required.
      props - Resource properties. This parameter is required.
  • Method Details

    • inspect

      @Stability(Stable) public void inspect(@NotNull TreeInspector inspector)
      Examines the CloudFormation resource and discloses attributes.

      Specified by:
      inspect in interface IInspectable
      Parameters:
      inspector - tree inspector to collect and process attributes. This parameter is required.
    • renderProperties

      @Stability(Stable) @NotNull protected Map<String,Object> renderProperties(@NotNull Map<String,Object> props)
      Overrides:
      renderProperties in class CfnResource
      Parameters:
      props - This parameter is required.
    • getAttrArn

      @Stability(Stable) @NotNull public String getAttrArn()
      Returns the Amazon Resource Name (ARN) of the policy.

      For example: arn:aws:organizations::111111111111:policy/o-exampleorgid/service_control_policy/p-examplepolicyid111 .

    • getAttrAwsManaged

      @Stability(Stable) @NotNull public IResolvable getAttrAwsManaged()
      Returns a boolean value that indicates whether the specified policy is an AWS managed policy.

      If true, then you can attach the policy to roots, OUs, or accounts, but you cannot edit it. For example: true | false .

    • getAttrId

      @Stability(Stable) @NotNull public String getAttrId()
      Returns the unique identifier (ID) of the policy.

      For example: p-examplepolicyid111 .

    • getCfnProperties

      @Stability(Stable) @NotNull protected Map<String,Object> getCfnProperties()
      Overrides:
      getCfnProperties in class CfnResource
    • getTags

      @Stability(Stable) @NotNull public TagManager getTags()
      Tag Manager which manages the tags for this resource.
      Specified by:
      getTags in interface ITaggable
    • getContent

      @Stability(Stable) @NotNull public Object getContent()
      The policy text content.

      You can specify the policy content as a JSON object or a JSON string.

    • setContent

      @Stability(Stable) public void setContent(@NotNull Object value)
      The policy text content.

      You can specify the policy content as a JSON object or a JSON string.

    • getName

      @Stability(Stable) @NotNull public String getName()
      Name of the policy.
    • setName

      @Stability(Stable) public void setName(@NotNull String value)
      Name of the policy.
    • getType

      @Stability(Stable) @NotNull public String getType()
      The type of policy to create.
    • setType

      @Stability(Stable) public void setType(@NotNull String value)
      The type of policy to create.
    • getDescription

      @Stability(Stable) @Nullable public String getDescription()
      Human readable description of the policy.
    • setDescription

      @Stability(Stable) public void setDescription(@Nullable String value)
      Human readable description of the policy.
    • getTagsRaw

      @Stability(Stable) @Nullable public List<CfnTag> getTagsRaw()
      A list of tags that you want to attach to the newly created policy.
    • setTagsRaw

      @Stability(Stable) public void setTagsRaw(@Nullable List<CfnTag> value)
      A list of tags that you want to attach to the newly created policy.
    • getTargetIds

      @Stability(Stable) @Nullable public List<String> getTargetIds()
      List of unique identifiers (IDs) of the root, OU, or account that you want to attach the policy to.
    • setTargetIds

      @Stability(Stable) public void setTargetIds(@Nullable List<String> value)
      List of unique identifiers (IDs) of the root, OU, or account that you want to attach the policy to.