import * as pulumi from "@pulumi/pulumi"; import * as inputs from "../types/input"; import * as outputs from "../types/output"; /** * Provides an independent configuration resource for S3 bucket [lifecycle configuration](https://docs.aws.amazon.com/AmazonS3/latest/userguide/object-lifecycle-mgmt.html). * * An S3 Lifecycle configuration consists of one or more Lifecycle rules. Each rule consists of the following: * * * Rule metadata (`id` and `status`) * * Filter identifying objects to which the rule applies * * One or more transition or expiration actions * * For more information see the Amazon S3 User Guide on [`Lifecycle Configuration Elements`](https://docs.aws.amazon.com/AmazonS3/latest/userguide/intro-lifecycle-rules.html). * * > S3 Buckets only support a single lifecycle configuration. Declaring multiple `aws.s3.BucketLifecycleConfiguration` resources to the same S3 Bucket will cause a perpetual difference in configuration. * * > Lifecycle configurations may take some time to fully propagate to all AWS S3 systems. * Running Pulumi operations shortly after creating a lifecycle configuration may result in changes that affect configuration idempotence. * See the Amazon S3 User Guide on [setting lifecycle configuration on a bucket](https://docs.aws.amazon.com/AmazonS3/latest/userguide/how-to-set-lifecycle-configuration-intro.html). * * ## Example Usage * * ### With neither a filter nor prefix specified * * When you don't specify a filter or prefix, the lifecycle rule applies to all objects in the bucket. This has the same effect as setting an empty `filter` element. * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as aws from "@pulumi/aws"; * * const example = new aws.s3.BucketLifecycleConfiguration("example", { * rules: [{ * id: "rule-1", * status: "Enabled", * }], * bucket: bucket.bucket, * }); * ``` * * ### Specifying an empty filter * * The Lifecycle rule applies to all objects in the bucket. * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as aws from "@pulumi/aws"; * * const example = new aws.s3.BucketLifecycleConfiguration("example", { * rules: [{ * filter: {}, * id: "rule-1", * status: "Enabled", * }], * bucket: bucket.bucket, * }); * ``` * * ### Specifying a filter using key prefixes * * The Lifecycle rule applies to a subset of objects based on the key name prefix (`logs/`). * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as aws from "@pulumi/aws"; * * const example = new aws.s3.BucketLifecycleConfiguration("example", { * rules: [{ * filter: { * prefix: "logs/", * }, * id: "rule-1", * status: "Enabled", * }], * bucket: bucket.bucket, * }); * ``` * * If you want to apply a Lifecycle action to a subset of objects based on different key name prefixes, specify separate rules. * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as aws from "@pulumi/aws"; * * const example = new aws.s3.BucketLifecycleConfiguration("example", { * rules: [ * { * filter: { * prefix: "logs/", * }, * id: "rule-1", * status: "Enabled", * }, * { * filter: { * prefix: "tmp/", * }, * id: "rule-2", * status: "Enabled", * }, * ], * bucket: bucket.bucket, * }); * ``` * * ### Specifying a filter based on an object tag * * The Lifecycle rule specifies a filter based on a tag key and value. The rule then applies only to a subset of objects with the specific tag. * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as aws from "@pulumi/aws"; * * const example = new aws.s3.BucketLifecycleConfiguration("example", { * rules: [{ * filter: { * tag: { * key: "Name", * value: "Staging", * }, * }, * id: "rule-1", * status: "Enabled", * }], * bucket: bucket.bucket, * }); * ``` * * ### Specifying a filter based on multiple tags * * The Lifecycle rule directs Amazon S3 to perform lifecycle actions on objects with two tags (with the specific tag keys and values). Notice `tags` is wrapped in the `and` configuration block. * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as aws from "@pulumi/aws"; * * const example = new aws.s3.BucketLifecycleConfiguration("example", { * rules: [{ * filter: { * and: { * tags: { * Key1: "Value1", * Key2: "Value2", * }, * }, * }, * id: "rule-1", * status: "Enabled", * }], * bucket: bucket.bucket, * }); * ``` * * ### Specifying a filter based on both prefix and one or more tags * * The Lifecycle rule directs Amazon S3 to perform lifecycle actions on objects with the specified prefix and two tags (with the specific tag keys and values). Notice both `prefix` and `tags` are wrapped in the `and` configuration block. * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as aws from "@pulumi/aws"; * * const example = new aws.s3.BucketLifecycleConfiguration("example", { * rules: [{ * filter: { * and: { * prefix: "logs/", * tags: { * Key1: "Value1", * Key2: "Value2", * }, * }, * }, * id: "rule-1", * status: "Enabled", * }], * bucket: bucket.bucket, * }); * ``` * * ### Specifying a filter based on object size * * Object size values are in bytes. Maximum filter size is 5TB. Amazon S3 applies a default behavior to your Lifecycle configuration that prevents objects smaller than 128 KB from being transitioned to any storage class. You can allow smaller objects to transition by adding a minimum size (`objectSizeGreaterThan`) or a maximum size (`objectSizeLessThan`) filter that specifies a smaller size to the configuration. This example allows any object smaller than 128 KB to transition to the S3 Glacier Instant Retrieval storage class: * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as aws from "@pulumi/aws"; * * const example = new aws.s3.BucketLifecycleConfiguration("example", { * rules: [{ * filter: { * objectSizeGreaterThan: 1, * }, * transitions: [{ * days: 365, * storageClass: "GLACIER_IR", * }], * id: "Allow small object transitions", * status: "Enabled", * }], * bucket: bucket.bucket, * }); * ``` * * ### Specifying a filter based on object size range and prefix * * The `objectSizeGreaterThan` must be less than the `objectSizeLessThan`. Notice both the object size range and prefix are wrapped in the `and` configuration block. * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as aws from "@pulumi/aws"; * * const example = new aws.s3.BucketLifecycleConfiguration("example", { * rules: [{ * filter: { * and: { * prefix: "logs/", * objectSizeGreaterThan: 500, * objectSizeLessThan: 64000, * }, * }, * id: "rule-1", * status: "Enabled", * }], * bucket: bucket.bucket, * }); * ``` * * ### Creating a Lifecycle Configuration for a bucket with versioning * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as aws from "@pulumi/aws"; * * const bucket = new aws.s3.Bucket("bucket", {bucket: "my-bucket"}); * const bucketAcl = new aws.s3.BucketAcl("bucket_acl", { * bucket: bucket.bucket, * acl: "private", * }); * const bucket_config = new aws.s3.BucketLifecycleConfiguration("bucket-config", { * rules: [ * { * expiration: { * days: 90, * }, * filter: { * and: { * prefix: "log/", * tags: { * rule: "log", * autoclean: "true", * }, * }, * }, * transitions: [ * { * days: 30, * storageClass: "STANDARD_IA", * }, * { * days: 60, * storageClass: "GLACIER", * }, * ], * id: "log", * status: "Enabled", * }, * { * filter: { * prefix: "tmp/", * }, * expiration: { * date: "2023-01-13T00:00:00Z", * }, * id: "tmp", * status: "Enabled", * }, * ], * bucket: bucket.bucket, * }); * const versioningBucket = new aws.s3.Bucket("versioning_bucket", {bucket: "my-versioning-bucket"}); * const versioningBucketAcl = new aws.s3.BucketAcl("versioning_bucket_acl", { * bucket: versioningBucket.bucket, * acl: "private", * }); * const versioning = new aws.s3.BucketVersioning("versioning", { * versioningConfiguration: { * status: "Enabled", * }, * bucket: versioningBucket.bucket, * }); * const versioning_bucket_config = new aws.s3.BucketLifecycleConfiguration("versioning-bucket-config", { * rules: [{ * filter: { * prefix: "config/", * }, * noncurrentVersionExpiration: { * noncurrentDays: 90, * }, * noncurrentVersionTransitions: [ * { * noncurrentDays: 30, * storageClass: "STANDARD_IA", * }, * { * noncurrentDays: 60, * storageClass: "GLACIER", * }, * ], * id: "config", * status: "Enabled", * }], * bucket: versioningBucket.bucket, * }, { * dependsOn: [versioning], * }); * ``` * * ## Import * * ### Identity Schema * * #### Required * * * `bucket` (String) S3 bucket name. * * #### Optional * * * `accountId` (String) AWS Account where this resource is managed. * * `region` (String) Region where this resource is managed. * * If the owner (account ID) of the source bucket differs from the account used to configure the AWS Provider, import using the `bucket` and `expectedBucketOwner` separated by a comma (`,`): * * Using `pulumi import`, import an S3 bucket lifecycle configuration using the `bucket` or the `bucket` and `expectedBucketOwner` separated by a comma (`,`). For example: * * If the owner (account ID) of the source bucket is the same account used to configure the AWS Provider, import using the `bucket`: * * ```sh * $ pulumi import aws:s3/bucketLifecycleConfiguration:BucketLifecycleConfiguration example bucket-name * ``` * * If the owner (account ID) of the source bucket differs from the account used to configure the AWS Provider, import using the `bucket` and `expectedBucketOwner` separated by a comma (`,`): * * ```sh * $ pulumi import aws:s3/bucketLifecycleConfiguration:BucketLifecycleConfiguration example bucket-name,123456789012 * ``` */ export declare class BucketLifecycleConfiguration extends pulumi.CustomResource { /** * Get an existing BucketLifecycleConfiguration 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: string, id: pulumi.Input, state?: BucketLifecycleConfigurationState, opts?: pulumi.CustomResourceOptions): BucketLifecycleConfiguration; /** * Returns true if the given object is an instance of BucketLifecycleConfiguration. This is designed to work even * when multiple copies of the Pulumi SDK have been loaded into the same process. */ static isInstance(obj: any): obj is BucketLifecycleConfiguration; /** * Name of the source S3 bucket you want Amazon S3 to monitor. */ readonly bucket: pulumi.Output; /** * Account ID of the expected bucket owner. If the bucket is owned by a different account, the request will fail with an HTTP 403 (Access Denied) error. * * @deprecated This attribute will be removed in a future verion of the provider. */ readonly expectedBucketOwner: pulumi.Output; /** * 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. */ readonly region: pulumi.Output; /** * List of configuration blocks describing the rules managing the replication. See below. */ readonly rules: pulumi.Output; readonly timeouts: pulumi.Output; /** * Default minimum object size behavior applied to the lifecycle configuration. Valid values: `all_storage_classes_128K` (default), `variesByStorageClass`. To customize the minimum object size for any transition you can add a `filter` that specifies a custom `objectSizeGreaterThan` or `objectSizeLessThan` value. Custom filters always take precedence over the default transition behavior. */ readonly transitionDefaultMinimumObjectSize: pulumi.Output; /** * Create a BucketLifecycleConfiguration resource with the given unique name, arguments, and options. * * @param name The _unique_ name of the resource. * @param args The arguments to use to populate this resource's properties. * @param opts A bag of options that control this resource's behavior. */ constructor(name: string, args: BucketLifecycleConfigurationArgs, opts?: pulumi.CustomResourceOptions); } /** * Input properties used for looking up and filtering BucketLifecycleConfiguration resources. */ export interface BucketLifecycleConfigurationState { /** * Name of the source S3 bucket you want Amazon S3 to monitor. */ bucket?: pulumi.Input; /** * Account ID of the expected bucket owner. If the bucket is owned by a different account, the request will fail with an HTTP 403 (Access Denied) error. * * @deprecated This attribute will be removed in a future verion of the provider. */ expectedBucketOwner?: pulumi.Input; /** * 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. */ region?: pulumi.Input; /** * List of configuration blocks describing the rules managing the replication. See below. */ rules?: pulumi.Input[] | undefined>; timeouts?: pulumi.Input; /** * Default minimum object size behavior applied to the lifecycle configuration. Valid values: `all_storage_classes_128K` (default), `variesByStorageClass`. To customize the minimum object size for any transition you can add a `filter` that specifies a custom `objectSizeGreaterThan` or `objectSizeLessThan` value. Custom filters always take precedence over the default transition behavior. */ transitionDefaultMinimumObjectSize?: pulumi.Input; } /** * The set of arguments for constructing a BucketLifecycleConfiguration resource. */ export interface BucketLifecycleConfigurationArgs { /** * Name of the source S3 bucket you want Amazon S3 to monitor. */ bucket: pulumi.Input; /** * Account ID of the expected bucket owner. If the bucket is owned by a different account, the request will fail with an HTTP 403 (Access Denied) error. * * @deprecated This attribute will be removed in a future verion of the provider. */ expectedBucketOwner?: pulumi.Input; /** * 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. */ region?: pulumi.Input; /** * List of configuration blocks describing the rules managing the replication. See below. */ rules?: pulumi.Input[] | undefined>; timeouts?: pulumi.Input; /** * Default minimum object size behavior applied to the lifecycle configuration. Valid values: `all_storage_classes_128K` (default), `variesByStorageClass`. To customize the minimum object size for any transition you can add a `filter` that specifies a custom `objectSizeGreaterThan` or `objectSizeLessThan` value. Custom filters always take precedence over the default transition behavior. */ transitionDefaultMinimumObjectSize?: pulumi.Input; } //# sourceMappingURL=bucketLifecycleConfiguration.d.ts.map