@pulumi/aws
Version:
A Pulumi package for creating and managing Amazon Web Services (AWS) cloud resources.
164 lines • 7.87 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.BucketVersioningV2 = void 0;
const pulumi = require("@pulumi/pulumi");
const utilities = require("../utilities");
/**
* Provides a resource for controlling versioning on an S3 bucket.
* Deleting this resource will either suspend versioning on the associated S3 bucket or
* simply remove the resource from state if the associated S3 bucket is unversioned.
*
* For more information, see [How S3 versioning works](https://docs.aws.amazon.com/AmazonS3/latest/userguide/manage-versioning-examples.html).
*
* > **NOTE:** If you are enabling versioning on the bucket for the first time, AWS recommends that you wait for 15 minutes after enabling versioning before issuing write operations (PUT or DELETE) on objects in the bucket.
*
* > This resource cannot be used with S3 directory buckets.
*
* ## Example Usage
*
* ### With Versioning Enabled
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as aws from "@pulumi/aws";
*
* const example = new aws.s3.Bucket("example", {bucket: "example-bucket"});
* const exampleBucketAcl = new aws.s3.BucketAcl("example", {
* bucket: example.id,
* acl: "private",
* });
* const versioningExample = new aws.s3.BucketVersioning("versioning_example", {
* bucket: example.id,
* versioningConfiguration: {
* status: "Enabled",
* },
* });
* ```
*
* ### With Versioning Disabled
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as aws from "@pulumi/aws";
*
* const example = new aws.s3.Bucket("example", {bucket: "example-bucket"});
* const exampleBucketAcl = new aws.s3.BucketAcl("example", {
* bucket: example.id,
* acl: "private",
* });
* const versioningExample = new aws.s3.BucketVersioning("versioning_example", {
* bucket: example.id,
* versioningConfiguration: {
* status: "Disabled",
* },
* });
* ```
*
* ### Object Dependency On Versioning
*
* When you create an object whose `versionId` you need and an `aws.s3.BucketVersioning` resource in the same configuration, you are more likely to have success by ensuring the `s3Object` depends either implicitly (see below) or explicitly (i.e., using `dependsOn = [aws_s3_bucket_versioning.example]`) on the `aws.s3.BucketVersioning` resource.
*
* > **NOTE:** For critical and/or production S3 objects, do not create a bucket, enable versioning, and create an object in the bucket within the same configuration. Doing so will not allow the AWS-recommended 15 minutes between enabling versioning and writing to the bucket.
*
* This example shows the `aws_s3_object.example` depending implicitly on the versioning resource through the reference to `aws_s3_bucket_versioning.example.bucket` to define `bucket`:
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as aws from "@pulumi/aws";
*
* const example = new aws.s3.Bucket("example", {bucket: "yotto"});
* const exampleBucketVersioning = new aws.s3.BucketVersioning("example", {
* bucket: example.id,
* versioningConfiguration: {
* status: "Enabled",
* },
* });
* const exampleBucketObjectv2 = new aws.s3.BucketObjectv2("example", {
* bucket: exampleBucketVersioning.id,
* key: "droeloe",
* source: new pulumi.asset.FileAsset("example.txt"),
* });
* ```
*
* ## 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` to import__ S3 bucket versioning using the `bucket` or using 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/bucketVersioningV2:BucketVersioningV2 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/bucketVersioningV2:BucketVersioningV2 example bucket-name,123456789012
* ```
*
* @deprecated aws.s3/bucketversioningv2.BucketVersioningV2 has been deprecated in favor of aws.s3/bucketversioning.BucketVersioning
*/
class BucketVersioningV2 extends pulumi.CustomResource {
/**
* Get an existing BucketVersioningV2 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("BucketVersioningV2 is deprecated: aws.s3/bucketversioningv2.BucketVersioningV2 has been deprecated in favor of aws.s3/bucketversioning.BucketVersioning");
return new BucketVersioningV2(name, state, { ...opts, id: id });
}
/**
* Returns true if the given object is an instance of BucketVersioningV2. 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'] === BucketVersioningV2.__pulumiType;
}
/** @deprecated aws.s3/bucketversioningv2.BucketVersioningV2 has been deprecated in favor of aws.s3/bucketversioning.BucketVersioning */
constructor(name, argsOrState, opts) {
pulumi.log.warn("BucketVersioningV2 is deprecated: aws.s3/bucketversioningv2.BucketVersioningV2 has been deprecated in favor of aws.s3/bucketversioning.BucketVersioning");
let resourceInputs = {};
opts = opts || {};
if (opts.id) {
const state = argsOrState;
resourceInputs["bucket"] = state?.bucket;
resourceInputs["expectedBucketOwner"] = state?.expectedBucketOwner;
resourceInputs["mfa"] = state?.mfa;
resourceInputs["region"] = state?.region;
resourceInputs["versioningConfiguration"] = state?.versioningConfiguration;
}
else {
const args = argsOrState;
if (args?.bucket === undefined && !opts.urn) {
throw new Error("Missing required property 'bucket'");
}
if (args?.versioningConfiguration === undefined && !opts.urn) {
throw new Error("Missing required property 'versioningConfiguration'");
}
resourceInputs["bucket"] = args?.bucket;
resourceInputs["expectedBucketOwner"] = args?.expectedBucketOwner;
resourceInputs["mfa"] = args?.mfa;
resourceInputs["region"] = args?.region;
resourceInputs["versioningConfiguration"] = args?.versioningConfiguration;
}
opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts);
const aliasOpts = { aliases: [{ type: "aws:s3/bucketVersioningV2:BucketVersioningV2" }] };
opts = pulumi.mergeOptions(opts, aliasOpts);
super(BucketVersioningV2.__pulumiType, name, resourceInputs, opts);
}
}
exports.BucketVersioningV2 = BucketVersioningV2;
/** @internal */
BucketVersioningV2.__pulumiType = 'aws:s3/bucketVersioningV2:BucketVersioningV2';
//# sourceMappingURL=bucketVersioningV2.js.map
;