@pulumi/aws
Version:
A Pulumi package for creating and managing Amazon Web Services (AWS) cloud resources.
114 lines • 5.39 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.BucketObjectLockConfiguration = void 0;
const pulumi = require("@pulumi/pulumi");
const utilities = require("../utilities");
/**
* Provides an S3 bucket Object Lock configuration resource. For more information about Object Locking, go to [Using S3 Object Lock](https://docs.aws.amazon.com/AmazonS3/latest/userguide/object-lock.html) in the Amazon S3 User Guide.
*
* > This resource can be used enable Object Lock for **new** and **existing** buckets.
*
* > This resource cannot be used with S3 directory buckets.
*
* ## Example Usage
*
* ### Object Lock configuration for new or existing buckets
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as aws from "@pulumi/aws";
*
* const example = new aws.s3.Bucket("example", {bucket: "mybucket"});
* const exampleBucketVersioning = new aws.s3.BucketVersioning("example", {
* bucket: example.id,
* versioningConfiguration: {
* status: "Enabled",
* },
* });
* const exampleBucketObjectLockConfiguration = new aws.s3.BucketObjectLockConfiguration("example", {
* bucket: example.id,
* rule: {
* defaultRetention: {
* mode: "COMPLIANCE",
* days: 5,
* },
* },
* });
* ```
*
* ## 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 (`,`). For example:
*
* __Using `pulumi import`__, import an S3 bucket Object Lock Configuration using one of two forms. If the owner (account ID) of the source bucket is the same account used to configure the AWS Provider, import using the `bucket`. For example:
*
* ```sh
* $ pulumi import aws:s3/bucketObjectLockConfiguration:BucketObjectLockConfiguration 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 (`,`). For example:
*
* ```sh
* $ pulumi import aws:s3/bucketObjectLockConfiguration:BucketObjectLockConfiguration example bucket-name,123456789012
* ```
*/
class BucketObjectLockConfiguration extends pulumi.CustomResource {
/**
* Get an existing BucketObjectLockConfiguration 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 BucketObjectLockConfiguration(name, state, { ...opts, id: id });
}
/**
* Returns true if the given object is an instance of BucketObjectLockConfiguration. 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'] === BucketObjectLockConfiguration.__pulumiType;
}
constructor(name, argsOrState, opts) {
let resourceInputs = {};
opts = opts || {};
if (opts.id) {
const state = argsOrState;
resourceInputs["bucket"] = state?.bucket;
resourceInputs["expectedBucketOwner"] = state?.expectedBucketOwner;
resourceInputs["objectLockEnabled"] = state?.objectLockEnabled;
resourceInputs["region"] = state?.region;
resourceInputs["rule"] = state?.rule;
resourceInputs["token"] = state?.token;
}
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["objectLockEnabled"] = args?.objectLockEnabled;
resourceInputs["region"] = args?.region;
resourceInputs["rule"] = args?.rule;
resourceInputs["token"] = args?.token ? pulumi.secret(args.token) : undefined;
}
opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts);
const aliasOpts = { aliases: [{ type: "aws:s3/bucketObjectLockConfigurationV2:BucketObjectLockConfigurationV2" }] };
opts = pulumi.mergeOptions(opts, aliasOpts);
const secretOpts = { additionalSecretOutputs: ["token"] };
opts = pulumi.mergeOptions(opts, secretOpts);
super(BucketObjectLockConfiguration.__pulumiType, name, resourceInputs, opts);
}
}
exports.BucketObjectLockConfiguration = BucketObjectLockConfiguration;
/** @internal */
BucketObjectLockConfiguration.__pulumiType = 'aws:s3/bucketObjectLockConfiguration:BucketObjectLockConfiguration';
//# sourceMappingURL=bucketObjectLockConfiguration.js.map