UNPKG

@pulumi/aws

Version:

A Pulumi package for creating and managing Amazon Web Services (AWS) cloud resources.

199 lines 6.97 kB
"use strict"; // *** WARNING: this file was generated by pulumi-language-nodejs. *** // *** Do not edit by hand unless you're certain you know what you are doing! *** Object.defineProperty(exports, "__esModule", { value: true }); exports.Selection = void 0; const pulumi = require("@pulumi/pulumi"); const utilities = require("../utilities"); /** * 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. * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as aws from "@pulumi/aws"; * * const assumeRole = aws.iam.getPolicyDocument({ * statements: [{ * effect: "Allow", * principals: [{ * type: "Service", * identifiers: ["backup.amazonaws.com"], * }], * actions: ["sts:AssumeRole"], * }], * }); * const example = new aws.iam.Role("example", { * name: "example", * assumeRolePolicy: assumeRole.then(assumeRole => assumeRole.json), * }); * const exampleRolePolicyAttachment = new aws.iam.RolePolicyAttachment("example", { * policyArn: "arn:aws:iam::aws:policy/service-role/AWSBackupServiceRolePolicyForBackup", * role: example.name, * }); * const exampleSelection = new aws.backup.Selection("example", {iamRoleArn: example.arn}); * ``` * * ### Selecting Backups By Tag * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as aws from "@pulumi/aws"; * * const example = new aws.backup.Selection("example", { * iamRoleArn: exampleAwsIamRole.arn, * name: "my_example_backup_selection", * planId: exampleAwsBackupPlan.id, * selectionTags: [{ * type: "STRINGEQUALS", * key: "foo", * value: "bar", * }], * }); * ``` * * ### Selecting Backups By Conditions * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as aws from "@pulumi/aws"; * * const example = new aws.backup.Selection("example", { * iamRoleArn: exampleAwsIamRole.arn, * name: "my_example_backup_selection", * planId: exampleAwsBackupPlan.id, * resources: ["*"], * conditions: [{ * stringEquals: [{ * key: "aws:ResourceTag/Component", * value: "rds", * }], * stringLikes: [{ * key: "aws:ResourceTag/Application", * value: "app*", * }], * stringNotEquals: [{ * key: "aws:ResourceTag/Backup", * value: "false", * }], * stringNotLikes: [{ * key: "aws:ResourceTag/Environment", * value: "test*", * }], * }], * }); * ``` * * ### Selecting Backups By Resource * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as aws from "@pulumi/aws"; * * const example = new aws.backup.Selection("example", { * iamRoleArn: exampleAwsIamRole.arn, * name: "my_example_backup_selection", * planId: exampleAwsBackupPlan.id, * resources: [ * exampleAwsDbInstance.arn, * exampleAwsEbsVolume.arn, * exampleAwsEfsFileSystem.arn, * ], * }); * ``` * * ### Selecting Backups By Not Resource * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as aws from "@pulumi/aws"; * * const example = new aws.backup.Selection("example", { * iamRoleArn: exampleAwsIamRole.arn, * name: "my_example_backup_selection", * planId: exampleAwsBackupPlan.id, * notResources: [ * exampleAwsDbInstance.arn, * exampleAwsEbsVolume.arn, * exampleAwsEfsFileSystem.arn, * ], * }); * ``` * * ## Import * * Using `pulumi import`, import Backup selection using the role plan_id and id separated by `|`. For example: * * ```sh * $ pulumi import aws:backup/selection:Selection example plan-id|selection-id * ``` */ class Selection extends pulumi.CustomResource { /** * Get an existing Selection resource's state with the given name, ID, and optional extra * properties used to qualify the lookup. * * @param name The _unique_ name of the resulting resource. * @param id The _unique_ provider ID of the resource to lookup. * @param state Any extra arguments used during the lookup. * @param opts Optional settings to control the behavior of the CustomResource. */ static get(name, id, state, opts) { return new Selection(name, state, { ...opts, id: id }); } /** * Returns true if the given object is an instance of Selection. This is designed to work even * when multiple copies of the Pulumi SDK have been loaded into the same process. */ static isInstance(obj) { if (obj === undefined || obj === null) { return false; } return obj['__pulumiType'] === Selection.__pulumiType; } constructor(name, argsOrState, opts) { let resourceInputs = {}; opts = opts || {}; if (opts.id) { const state = argsOrState; resourceInputs["conditions"] = state?.conditions; resourceInputs["iamRoleArn"] = state?.iamRoleArn; resourceInputs["name"] = state?.name; resourceInputs["notResources"] = state?.notResources; resourceInputs["planId"] = state?.planId; resourceInputs["region"] = state?.region; resourceInputs["resources"] = state?.resources; resourceInputs["selectionTags"] = state?.selectionTags; } else { const args = argsOrState; if (args?.iamRoleArn === undefined && !opts.urn) { throw new Error("Missing required property 'iamRoleArn'"); } if (args?.planId === undefined && !opts.urn) { throw new Error("Missing required property 'planId'"); } resourceInputs["conditions"] = args?.conditions; resourceInputs["iamRoleArn"] = args?.iamRoleArn; resourceInputs["name"] = args?.name; resourceInputs["notResources"] = args?.notResources; resourceInputs["planId"] = args?.planId; resourceInputs["region"] = args?.region; resourceInputs["resources"] = args?.resources; resourceInputs["selectionTags"] = args?.selectionTags; } opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts); super(Selection.__pulumiType, name, resourceInputs, opts); } } exports.Selection = Selection; /** @internal */ Selection.__pulumiType = 'aws:backup/selection:Selection'; //# sourceMappingURL=selection.js.map