Class PolicyAttachment


  • public class PolicyAttachment
    extends com.pulumi.resources.CustomResource
    Provides a resource to attach an AWS Organizations policy to an organization account, root, or unit. ## Example Usage ### Organization Account
     
     package generated_program;
     
     import com.pulumi.Context;
     import com.pulumi.Pulumi;
     import com.pulumi.core.Output;
     import com.pulumi.aws.organizations.PolicyAttachment;
     import com.pulumi.aws.organizations.PolicyAttachmentArgs;
     import java.util.ArrayList;
     import java.util.Arrays;
     import java.util.Map;
     import java.io.File;
     import java.nio.file.Files;
     import java.nio.file.Paths;
     
     public class App {
         public static void main(String[] args) {
             Pulumi.run(App::stack);
         }
     
         public static void stack(Context ctx) {
             var account = new PolicyAttachment("account", PolicyAttachmentArgs.builder()
                 .policyId(example.id())
                 .targetId("123456789012")
                 .build());
     
         }
     }
     
     
    ### Organization Root
     
     package generated_program;
     
     import com.pulumi.Context;
     import com.pulumi.Pulumi;
     import com.pulumi.core.Output;
     import com.pulumi.aws.organizations.PolicyAttachment;
     import com.pulumi.aws.organizations.PolicyAttachmentArgs;
     import java.util.ArrayList;
     import java.util.Arrays;
     import java.util.Map;
     import java.io.File;
     import java.nio.file.Files;
     import java.nio.file.Paths;
     
     public class App {
         public static void main(String[] args) {
             Pulumi.run(App::stack);
         }
     
         public static void stack(Context ctx) {
             var root = new PolicyAttachment("root", PolicyAttachmentArgs.builder()
                 .policyId(example.id())
                 .targetId(exampleAwsOrganizationsOrganization.roots()[0].id())
                 .build());
     
         }
     }
     
     
    ### Organization Unit
     
     package generated_program;
     
     import com.pulumi.Context;
     import com.pulumi.Pulumi;
     import com.pulumi.core.Output;
     import com.pulumi.aws.organizations.PolicyAttachment;
     import com.pulumi.aws.organizations.PolicyAttachmentArgs;
     import java.util.ArrayList;
     import java.util.Arrays;
     import java.util.Map;
     import java.io.File;
     import java.nio.file.Files;
     import java.nio.file.Paths;
     
     public class App {
         public static void main(String[] args) {
             Pulumi.run(App::stack);
         }
     
         public static void stack(Context ctx) {
             var unit = new PolicyAttachment("unit", PolicyAttachmentArgs.builder()
                 .policyId(example.id())
                 .targetId(exampleAwsOrganizationsOrganizationalUnit.id())
                 .build());
     
         }
     }
     
     
    ## Import ### Identity Schema #### Required * `policyId` (String) Organizations policy ID. * `targetId` (String) Organizations target ID (account, OU, or root). #### Optional * `accountId` (String) AWS Account where this resource is managed. Using `pulumi import`, import `aws.organizations.PolicyAttachment` using the target ID and policy ID. For example: With an account target: ```sh $ pulumi import aws:organizations/policyAttachment:PolicyAttachment example 123456789012:p-12345678 ```
    • Nested Class Summary

      • Nested classes/interfaces inherited from class com.pulumi.resources.CustomResource

        com.pulumi.resources.CustomResource.CustomResourceInternal
      • Nested classes/interfaces inherited from class com.pulumi.resources.Resource

        com.pulumi.resources.Resource.LazyField<T extends java.lang.Object>, com.pulumi.resources.Resource.LazyFields, com.pulumi.resources.Resource.ResourceInternal
    • Field Summary

      • Fields inherited from class com.pulumi.resources.Resource

        childResources, remote
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      static PolicyAttachment get​(java.lang.String name, com.pulumi.core.Output<java.lang.String> id, PolicyAttachmentState state, com.pulumi.resources.CustomResourceOptions options)
      Get an existing Host resource's state with the given name, ID, and optional extra properties used to qualify the lookup.
      com.pulumi.core.Output<java.lang.String> policyId()  
      com.pulumi.core.Output<java.util.Optional<java.lang.Boolean>> skipDestroy()  
      com.pulumi.core.Output<java.lang.String> targetId()  
      • Methods inherited from class com.pulumi.resources.CustomResource

        getId, id, idFuture
      • Methods inherited from class com.pulumi.resources.Resource

        getChildResources, getResourceName, getResourceType, getUrn, pulumiChildResources, pulumiResourceName, pulumiResourceType, urn
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • PolicyAttachment

        public PolicyAttachment​(java.lang.String name)
        Parameters:
        name - The _unique_ name of the resulting resource.
      • PolicyAttachment

        public PolicyAttachment​(java.lang.String name,
                                PolicyAttachmentArgs args)
        Parameters:
        name - The _unique_ name of the resulting resource.
        args - The arguments to use to populate this resource's properties.
      • PolicyAttachment

        public PolicyAttachment​(java.lang.String name,
                                PolicyAttachmentArgs args,
                                @Nullable
                                com.pulumi.resources.CustomResourceOptions options)
        Parameters:
        name - The _unique_ name of the resulting resource.
        args - The arguments to use to populate this resource's properties.
        options - A bag of options that control this resource's behavior.
    • Method Detail

      • policyId

        public com.pulumi.core.Output<java.lang.String> policyId()
        Returns:
        The unique identifier (ID) of the policy that you want to attach to the target.
      • skipDestroy

        public com.pulumi.core.Output<java.util.Optional<java.lang.Boolean>> skipDestroy()
        Returns:
        If set to `true`, destroy will **not** detach the policy and instead just remove the resource from state. This can be useful in situations where the attachment must be preserved to meet the AWS minimum requirement of 1 attached policy.
      • targetId

        public com.pulumi.core.Output<java.lang.String> targetId()
        Returns:
        The unique identifier (ID) of the root, organizational unit, or account number that you want to attach the policy to.
      • get

        public static PolicyAttachment get​(java.lang.String name,
                                           com.pulumi.core.Output<java.lang.String> id,
                                           @Nullable
                                           PolicyAttachmentState state,
                                           @Nullable
                                           com.pulumi.resources.CustomResourceOptions options)
        Get an existing Host resource's state with the given name, ID, and optional extra properties used to qualify the lookup.
        Parameters:
        name - The _unique_ name of the resulting resource.
        id - The _unique_ provider ID of the resource to lookup.
        state -
        options - Optional settings to control the behavior of the CustomResource.