@pulumi/aws
Version:
A Pulumi package for creating and managing Amazon Web Services (AWS) cloud resources.
402 lines • 15.4 kB
JavaScript
// *** 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.BucketLifecycleConfigurationV2 = void 0;
const pulumi = require("@pulumi/pulumi");
const utilities = require("../utilities");
/**
* 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
*/
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, id, state, opts) {
pulumi.log.warn("BucketLifecycleConfigurationV2 is deprecated: aws.s3/bucketlifecycleconfigurationv2.BucketLifecycleConfigurationV2 has been deprecated in favor of aws.s3/bucketlifecycleconfiguration.BucketLifecycleConfiguration");
return new BucketLifecycleConfigurationV2(name, state, { ...opts, id: id });
}
/**
* 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) {
if (obj === undefined || obj === null) {
return false;
}
return obj['__pulumiType'] === BucketLifecycleConfigurationV2.__pulumiType;
}
/** @deprecated aws.s3/bucketlifecycleconfigurationv2.BucketLifecycleConfigurationV2 has been deprecated in favor of aws.s3/bucketlifecycleconfiguration.BucketLifecycleConfiguration */
constructor(name, argsOrState, opts) {
pulumi.log.warn("BucketLifecycleConfigurationV2 is deprecated: aws.s3/bucketlifecycleconfigurationv2.BucketLifecycleConfigurationV2 has been deprecated in favor of aws.s3/bucketlifecycleconfiguration.BucketLifecycleConfiguration");
let resourceInputs = {};
opts = opts || {};
if (opts.id) {
const state = argsOrState;
resourceInputs["bucket"] = state?.bucket;
resourceInputs["expectedBucketOwner"] = state?.expectedBucketOwner;
resourceInputs["region"] = state?.region;
resourceInputs["rules"] = state?.rules;
resourceInputs["timeouts"] = state?.timeouts;
resourceInputs["transitionDefaultMinimumObjectSize"] = state?.transitionDefaultMinimumObjectSize;
}
else {
const args = argsOrState;
if (args?.bucket === undefined && !opts.urn) {
throw new Error("Missing required property 'bucket'");
}
resourceInputs["bucket"] = args?.bucket;
resourceInputs["expectedBucketOwner"] = args?.expectedBucketOwner;
resourceInputs["region"] = args?.region;
resourceInputs["rules"] = args?.rules;
resourceInputs["timeouts"] = args?.timeouts;
resourceInputs["transitionDefaultMinimumObjectSize"] = args?.transitionDefaultMinimumObjectSize;
}
opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts);
const aliasOpts = { aliases: [{ type: "aws:s3/bucketLifecycleConfigurationV2:BucketLifecycleConfigurationV2" }] };
opts = pulumi.mergeOptions(opts, aliasOpts);
super(BucketLifecycleConfigurationV2.__pulumiType, name, resourceInputs, opts);
}
}
exports.BucketLifecycleConfigurationV2 = BucketLifecycleConfigurationV2;
/** @internal */
BucketLifecycleConfigurationV2.__pulumiType = 'aws:s3/bucketLifecycleConfigurationV2:BucketLifecycleConfigurationV2';
//# sourceMappingURL=bucketLifecycleConfigurationV2.js.map
;