Class Selection


  • public class Selection
    extends com.pulumi.resources.CustomResource
    Manages selection conditions for AWS Backup plan resources. ## Example Usage ### IAM Role > For more information about creating and managing IAM Roles for backups and restores, see the [AWS Backup Developer Guide](https://docs.aws.amazon.com/aws-backup/latest/devguide/iam-service-roles.html). The below example creates an IAM role with the default managed IAM Policy for allowing AWS Backup to create backups.
     
     package generated_program;
     
     import com.pulumi.Context;
     import com.pulumi.Pulumi;
     import com.pulumi.core.Output;
     import com.pulumi.aws.iam.IamFunctions;
     import com.pulumi.aws.iam.inputs.GetPolicyDocumentArgs;
     import com.pulumi.aws.iam.inputs.GetPolicyDocumentStatementArgs;
     import com.pulumi.aws.iam.inputs.GetPolicyDocumentStatementPrincipalArgs;
     import com.pulumi.aws.iam.Role;
     import com.pulumi.aws.iam.RoleArgs;
     import com.pulumi.aws.iam.RolePolicyAttachment;
     import com.pulumi.aws.iam.RolePolicyAttachmentArgs;
     import com.pulumi.aws.backup.Selection;
     import com.pulumi.aws.backup.SelectionArgs;
     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) {
             final var assumeRole = IamFunctions.getPolicyDocument(GetPolicyDocumentArgs.builder()
                 .statements(GetPolicyDocumentStatementArgs.builder()
                     .principals(GetPolicyDocumentStatementPrincipalArgs.builder()
                         .type("Service")
                         .identifiers("backup.amazonaws.com")
                         .build())
                     .effect("Allow")
                     .actions("sts:AssumeRole")
                     .build())
                 .build());
     
             var example = new Role("example", RoleArgs.builder()
                 .name("example")
                 .assumeRolePolicy(assumeRole.json())
                 .build());
     
             var exampleRolePolicyAttachment = new RolePolicyAttachment("exampleRolePolicyAttachment", RolePolicyAttachmentArgs.builder()
                 .policyArn("arn:aws:iam::aws:policy/service-role/AWSBackupServiceRolePolicyForBackup")
                 .role(example.name())
                 .build());
     
             var exampleSelection = new Selection("exampleSelection", SelectionArgs.builder()
                 .iamRoleArn(example.arn())
                 .build());
     
         }
     }
     
     
    ### Selecting Backups By Tag
     
     package generated_program;
     
     import com.pulumi.Context;
     import com.pulumi.Pulumi;
     import com.pulumi.core.Output;
     import com.pulumi.aws.backup.Selection;
     import com.pulumi.aws.backup.SelectionArgs;
     import com.pulumi.aws.backup.inputs.SelectionSelectionTagArgs;
     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 example = new Selection("example", SelectionArgs.builder()
                 .selectionTags(SelectionSelectionTagArgs.builder()
                     .type("STRINGEQUALS")
                     .key("foo")
                     .value("bar")
                     .build())
                 .iamRoleArn(exampleAwsIamRole.arn())
                 .name("my_example_backup_selection")
                 .planId(exampleAwsBackupPlan.id())
                 .build());
     
         }
     }
     
     
    ### Selecting Backups By Conditions
     
     package generated_program;
     
     import com.pulumi.Context;
     import com.pulumi.Pulumi;
     import com.pulumi.core.Output;
     import com.pulumi.aws.backup.Selection;
     import com.pulumi.aws.backup.SelectionArgs;
     import com.pulumi.aws.backup.inputs.SelectionConditionArgs;
     import com.pulumi.aws.backup.inputs.SelectionConditionStringEqualArgs;
     import com.pulumi.aws.backup.inputs.SelectionConditionStringLikeArgs;
     import com.pulumi.aws.backup.inputs.SelectionConditionStringNotEqualArgs;
     import com.pulumi.aws.backup.inputs.SelectionConditionStringNotLikeArgs;
     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 example = new Selection("example", SelectionArgs.builder()
                 .conditions(SelectionConditionArgs.builder()
                     .stringEquals(SelectionConditionStringEqualArgs.builder()
                         .key("aws:ResourceTag/Component")
                         .value("rds")
                         .build())
                     .stringLikes(SelectionConditionStringLikeArgs.builder()
                         .key("aws:ResourceTag/Application")
                         .value("app*")
                         .build())
                     .stringNotEquals(SelectionConditionStringNotEqualArgs.builder()
                         .key("aws:ResourceTag/Backup")
                         .value("false")
                         .build())
                     .stringNotLikes(SelectionConditionStringNotLikeArgs.builder()
                         .key("aws:ResourceTag/Environment")
                         .value("test*")
                         .build())
                     .build())
                 .iamRoleArn(exampleAwsIamRole.arn())
                 .name("my_example_backup_selection")
                 .planId(exampleAwsBackupPlan.id())
                 .resources("*")
                 .build());
     
         }
     }
     
     
    ### Selecting Backups By Resource
     
     package generated_program;
     
     import com.pulumi.Context;
     import com.pulumi.Pulumi;
     import com.pulumi.core.Output;
     import com.pulumi.aws.backup.Selection;
     import com.pulumi.aws.backup.SelectionArgs;
     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 example = new Selection("example", SelectionArgs.builder()
                 .iamRoleArn(exampleAwsIamRole.arn())
                 .name("my_example_backup_selection")
                 .planId(exampleAwsBackupPlan.id())
                 .resources(            
                     exampleAwsDbInstance.arn(),
                     exampleAwsEbsVolume.arn(),
                     exampleAwsEfsFileSystem.arn())
                 .build());
     
         }
     }
     
     
    ### Selecting Backups By Not Resource
     
     package generated_program;
     
     import com.pulumi.Context;
     import com.pulumi.Pulumi;
     import com.pulumi.core.Output;
     import com.pulumi.aws.backup.Selection;
     import com.pulumi.aws.backup.SelectionArgs;
     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 example = new Selection("example", SelectionArgs.builder()
                 .iamRoleArn(exampleAwsIamRole.arn())
                 .name("my_example_backup_selection")
                 .planId(exampleAwsBackupPlan.id())
                 .notResources(            
                     exampleAwsDbInstance.arn(),
                     exampleAwsEbsVolume.arn(),
                     exampleAwsEfsFileSystem.arn())
                 .build());
     
         }
     }
     
     
    ## Import ### Identity Schema #### Required * `planId` (Required) Backup plan ID associated with the selection of resources. * `id` (String) Backup selection ID. #### Optional * `accountId` (String) AWS Account where this resource is managed. * `region` (String) Region where this resource is managed. Using `pulumi import`, import Backup selection using the `planId` and `id` separated by `|`. For example: ```sh $ pulumi import aws:backup/selection:Selection example abcd1234|efgh5678 ```
    • 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
    • Constructor Summary

      Constructors 
      Constructor Description
      Selection​(java.lang.String name)  
      Selection​(java.lang.String name, SelectionArgs args)  
      Selection​(java.lang.String name, SelectionArgs args, com.pulumi.resources.CustomResourceOptions options)  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      com.pulumi.core.Output<java.util.List<SelectionCondition>> conditions()  
      static Selection get​(java.lang.String name, com.pulumi.core.Output<java.lang.String> id, SelectionState 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> iamRoleArn()  
      com.pulumi.core.Output<java.lang.String> name()  
      com.pulumi.core.Output<java.util.List<java.lang.String>> notResources()  
      com.pulumi.core.Output<java.lang.String> planId()  
      com.pulumi.core.Output<java.lang.String> region()  
      com.pulumi.core.Output<java.util.Optional<java.util.List<java.lang.String>>> resources()  
      com.pulumi.core.Output<java.util.Optional<java.util.List<SelectionSelectionTag>>> selectionTags()  
      • 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

      • Selection

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

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

        public Selection​(java.lang.String name,
                         SelectionArgs 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

      • conditions

        public com.pulumi.core.Output<java.util.List<SelectionCondition>> conditions()
        Returns:
        Condition-based filters used to specify sets of resources for a backup plan. See below for details.
      • iamRoleArn

        public com.pulumi.core.Output<java.lang.String> iamRoleArn()
        Returns:
        ARN of the IAM role that AWS Backup uses to authenticate when restoring and backing up the target resource. See the [AWS Backup Developer Guide](https://docs.aws.amazon.com/aws-backup/latest/devguide/access-control.html#managed-policies) for additional information about using AWS managed policies or creating custom policies attached to the IAM role.
      • name

        public com.pulumi.core.Output<java.lang.String> name()
        Returns:
        Display name of a resource selection document.
      • notResources

        public com.pulumi.core.Output<java.util.List<java.lang.String>> notResources()
        Returns:
        Array of strings that either contain ARNs or match patterns of resources to exclude from a backup plan.
      • planId

        public com.pulumi.core.Output<java.lang.String> planId()
        Returns:
        Backup plan ID to be associated with the selection of resources.
      • region

        public com.pulumi.core.Output<java.lang.String> region()
        Returns:
        Region where this resource will be [managed](https://docs.aws.amazon.com/general/latest/gr/rande.html#regional-endpoints). Defaults to the Region set in the provider configuration.
      • resources

        public com.pulumi.core.Output<java.util.Optional<java.util.List<java.lang.String>>> resources()
        Returns:
        Array of strings that either contain ARNs or match patterns of resources to assign to a backup plan.
      • selectionTags

        public com.pulumi.core.Output<java.util.Optional<java.util.List<SelectionSelectionTag>>> selectionTags()
        Returns:
        Tag-based conditions used to specify a set of resources to assign to a backup plan. See below for details.
      • get

        public static Selection get​(java.lang.String name,
                                    com.pulumi.core.Output<java.lang.String> id,
                                    @Nullable
                                    SelectionState 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.