@pulumi/aws
Version:
A Pulumi package for creating and managing Amazon Web Services (AWS) cloud resources.
438 lines (437 loc) • 17.6 kB
TypeScript
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
*
* The Lifecycle rule applies to a subset of objects based on the key name prefix (`""`).
*
* This configuration is intended to replicate the default behavior of the `lifecycleRule`
* parameter in the AWS Provider `aws.s3.Bucket` resource prior to `v4.0`.
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as aws from "@pulumi/aws";
*
* const example = new aws.s3.BucketLifecycleConfiguration("example", {
* bucket: bucket.id,
* rules: [{
* id: "rule-1",
* status: "Enabled",
* }],
* });
* ```
*
* ### 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", {
* bucket: bucket.id,
* rules: [{
* id: "rule-1",
* filter: {},
* status: "Enabled",
* }],
* });
* ```
*
* ### 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", {
* bucket: bucket.id,
* rules: [{
* id: "rule-1",
* filter: {
* prefix: "logs/",
* },
* status: "Enabled",
* }],
* });
* ```
*
* 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", {
* bucket: bucket.id,
* rules: [
* {
* id: "rule-1",
* filter: {
* prefix: "logs/",
* },
* status: "Enabled",
* },
* {
* id: "rule-2",
* filter: {
* prefix: "tmp/",
* },
* status: "Enabled",
* },
* ],
* });
* ```
*
* ### 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", {
* bucket: bucket.id,
* rules: [{
* id: "rule-1",
* filter: {
* tag: {
* key: "Name",
* value: "Staging",
* },
* },
* status: "Enabled",
* }],
* });
* ```
*
* ### 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", {
* bucket: bucket.id,
* rules: [{
* id: "rule-1",
* filter: {
* and: {
* tags: {
* Key1: "Value1",
* Key2: "Value2",
* },
* },
* },
* status: "Enabled",
* }],
* });
* ```
*
* ### 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", {
* bucket: bucket.id,
* rules: [{
* id: "rule-1",
* filter: {
* and: {
* prefix: "logs/",
* tags: {
* Key1: "Value1",
* Key2: "Value2",
* },
* },
* },
* status: "Enabled",
* }],
* });
* ```
*
* ### 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", {
* bucket: bucket.id,
* rules: [{
* id: "Allow small object transitions",
* filter: {
* objectSizeGreaterThan: 1,
* },
* status: "Enabled",
* transitions: [{
* days: 365,
* storageClass: "GLACIER_IR",
* }],
* }],
* });
* ```
*
* ### 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", {
* bucket: bucket.id,
* rules: [{
* id: "rule-1",
* filter: {
* and: {
* prefix: "logs/",
* objectSizeGreaterThan: 500,
* objectSizeLessThan: 64000,
* },
* },
* status: "Enabled",
* }],
* });
* ```
*
* ### 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.id,
* acl: "private",
* });
* const bucket_config = new aws.s3.BucketLifecycleConfiguration("bucket-config", {
* bucket: bucket.id,
* rules: [
* {
* id: "log",
* expiration: {
* days: 90,
* },
* filter: {
* and: {
* prefix: "log/",
* tags: {
* rule: "log",
* autoclean: "true",
* },
* },
* },
* status: "Enabled",
* transitions: [
* {
* days: 30,
* storageClass: "STANDARD_IA",
* },
* {
* days: 60,
* storageClass: "GLACIER",
* },
* ],
* },
* {
* id: "tmp",
* filter: {
* prefix: "tmp/",
* },
* expiration: {
* date: "2023-01-13T00:00:00Z",
* },
* status: "Enabled",
* },
* ],
* });
* const versioningBucket = new aws.s3.Bucket("versioning_bucket", {bucket: "my-versioning-bucket"});
* const versioningBucketAcl = new aws.s3.BucketAcl("versioning_bucket_acl", {
* bucket: versioningBucket.id,
* acl: "private",
* });
* const versioning = new aws.s3.BucketVersioning("versioning", {
* bucket: versioningBucket.id,
* versioningConfiguration: {
* status: "Enabled",
* },
* });
* const versioning_bucket_config = new aws.s3.BucketLifecycleConfiguration("versioning-bucket-config", {
* bucket: versioningBucket.id,
* rules: [{
* id: "config",
* filter: {
* prefix: "config/",
* },
* noncurrentVersionExpiration: {
* noncurrentDays: 90,
* },
* noncurrentVersionTransitions: [
* {
* noncurrentDays: 30,
* storageClass: "STANDARD_IA",
* },
* {
* noncurrentDays: 60,
* storageClass: "GLACIER",
* },
* ],
* status: "Enabled",
* }],
* }, {
* dependsOn: [versioning],
* });
* ```
*
* ## Import
*
* If the owner (account ID) of the source bucket differs from the account used to configure the AWS Provider, import using the `bucket` and `expected_bucket_owner` separated by a comma (`,`):
*
* Using `pulumi import`, import an S3 bucket lifecycle configuration using the `bucket` or the `bucket` and `expected_bucket_owner` 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/bucketLifecycleConfigurationV2:BucketLifecycleConfigurationV2 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 `expected_bucket_owner` separated by a comma (`,`):
*
* ```sh
* $ pulumi import aws:s3/bucketLifecycleConfigurationV2:BucketLifecycleConfigurationV2 example bucket-name,123456789012
* ```
*
* @deprecated aws.s3/bucketlifecycleconfigurationv2.BucketLifecycleConfigurationV2 has been deprecated in favor of aws.s3/bucketlifecycleconfiguration.BucketLifecycleConfiguration
*/
export declare class BucketLifecycleConfigurationV2 extends pulumi.CustomResource {
/**
* Get an existing BucketLifecycleConfigurationV2 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<pulumi.ID>, state?: BucketLifecycleConfigurationV2State, opts?: pulumi.CustomResourceOptions): BucketLifecycleConfigurationV2;
/**
* Returns true if the given object is an instance of BucketLifecycleConfigurationV2. 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 BucketLifecycleConfigurationV2;
/**
* Name of the source S3 bucket you want Amazon S3 to monitor.
*/
readonly bucket: pulumi.Output<string>;
/**
* 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.
*/
readonly expectedBucketOwner: pulumi.Output<string>;
/**
* 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<string>;
/**
* List of configuration blocks describing the rules managing the replication. See below.
*/
readonly rules: pulumi.Output<outputs.s3.BucketLifecycleConfigurationV2Rule[] | undefined>;
readonly timeouts: pulumi.Output<outputs.s3.BucketLifecycleConfigurationV2Timeouts | undefined>;
/**
* The 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<string>;
/**
* Create a BucketLifecycleConfigurationV2 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.
*/
/** @deprecated aws.s3/bucketlifecycleconfigurationv2.BucketLifecycleConfigurationV2 has been deprecated in favor of aws.s3/bucketlifecycleconfiguration.BucketLifecycleConfiguration */
constructor(name: string, args: BucketLifecycleConfigurationV2Args, opts?: pulumi.CustomResourceOptions);
}
/**
* Input properties used for looking up and filtering BucketLifecycleConfigurationV2 resources.
*/
export interface BucketLifecycleConfigurationV2State {
/**
* Name of the source S3 bucket you want Amazon S3 to monitor.
*/
bucket?: pulumi.Input<string>;
/**
* 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.
*/
expectedBucketOwner?: pulumi.Input<string>;
/**
* 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<string>;
/**
* List of configuration blocks describing the rules managing the replication. See below.
*/
rules?: pulumi.Input<pulumi.Input<inputs.s3.BucketLifecycleConfigurationV2Rule>[]>;
timeouts?: pulumi.Input<inputs.s3.BucketLifecycleConfigurationV2Timeouts>;
/**
* The 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<string>;
}
/**
* The set of arguments for constructing a BucketLifecycleConfigurationV2 resource.
*/
export interface BucketLifecycleConfigurationV2Args {
/**
* Name of the source S3 bucket you want Amazon S3 to monitor.
*/
bucket: pulumi.Input<string>;
/**
* 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.
*/
expectedBucketOwner?: pulumi.Input<string>;
/**
* 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<string>;
/**
* List of configuration blocks describing the rules managing the replication. See below.
*/
rules?: pulumi.Input<pulumi.Input<inputs.s3.BucketLifecycleConfigurationV2Rule>[]>;
timeouts?: pulumi.Input<inputs.s3.BucketLifecycleConfigurationV2Timeouts>;
/**
* The 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<string>;
}