@pulumi/aws
Version:
A Pulumi package for creating and managing Amazon Web Services (AWS) cloud resources.
239 lines • 10.6 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.BucketObject = void 0;
const pulumi = require("@pulumi/pulumi");
const utilities = require("../utilities");
/**
* Provides an S3 object resource.
*
* ## Example Usage
*
* ### Uploading a file to a bucket
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as aws from "@pulumi/aws";
* import * as std from "@pulumi/std";
*
* const object = new aws.s3.BucketObject("object", {
* bucket: "your_bucket_name",
* key: "new_object_key",
* source: new pulumi.asset.FileAsset("path/to/file"),
* etag: std.filemd5({
* input: "path/to/file",
* }).then(invoke => invoke.result),
* });
* ```
*
* ### Encrypting with KMS Key
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as aws from "@pulumi/aws";
*
* const examplekms = new aws.kms.Key("examplekms", {
* description: "KMS key 1",
* deletionWindowInDays: 7,
* });
* const examplebucket = new aws.s3.Bucket("examplebucket", {bucket: "examplebuckettftest"});
* const example = new aws.s3.BucketAcl("example", {
* bucket: examplebucket.id,
* acl: "private",
* });
* const exampleBucketObject = new aws.s3.BucketObject("example", {
* key: "someobject",
* bucket: examplebucket.id,
* source: new pulumi.asset.FileAsset("index.html"),
* kmsKeyId: examplekms.arn,
* });
* ```
*
* ### Server Side Encryption with S3 Default Master Key
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as aws from "@pulumi/aws";
*
* const examplebucket = new aws.s3.Bucket("examplebucket", {bucket: "examplebuckettftest"});
* const example = new aws.s3.BucketAcl("example", {
* bucket: examplebucket.id,
* acl: "private",
* });
* const exampleBucketObject = new aws.s3.BucketObject("example", {
* key: "someobject",
* bucket: examplebucket.id,
* source: new pulumi.asset.FileAsset("index.html"),
* serverSideEncryption: "aws:kms",
* });
* ```
*
* ### Server Side Encryption with AWS-Managed Key
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as aws from "@pulumi/aws";
*
* const examplebucket = new aws.s3.Bucket("examplebucket", {bucket: "examplebuckettftest"});
* const example = new aws.s3.BucketAcl("example", {
* bucket: examplebucket.id,
* acl: "private",
* });
* const exampleBucketObject = new aws.s3.BucketObject("example", {
* key: "someobject",
* bucket: examplebucket.id,
* source: new pulumi.asset.FileAsset("index.html"),
* serverSideEncryption: "AES256",
* });
* ```
*
* ### S3 Object Lock
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as aws from "@pulumi/aws";
*
* const examplebucket = new aws.s3.Bucket("examplebucket", {
* bucket: "examplebuckettftest",
* objectLockEnabled: true,
* });
* const example = new aws.s3.BucketAcl("example", {
* bucket: examplebucket.id,
* acl: "private",
* });
* const exampleBucketVersioning = new aws.s3.BucketVersioning("example", {
* bucket: examplebucket.id,
* versioningConfiguration: {
* status: "Enabled",
* },
* });
* const exampleBucketObject = new aws.s3.BucketObject("example", {
* key: "someobject",
* bucket: examplebucket.id,
* source: new pulumi.asset.FileAsset("important.txt"),
* objectLockLegalHoldStatus: "ON",
* objectLockMode: "GOVERNANCE",
* objectLockRetainUntilDate: "2021-12-31T23:59:60Z",
* forceDestroy: true,
* }, {
* dependsOn: [exampleBucketVersioning],
* });
* ```
*
* ## Import
*
* Import using S3 URL syntax:
*
* __Using `pulumi import` to import__ objects using the `id` or S3 URL. For example:
*
* Import using the `id`, which is the bucket name and the key together:
*
* ```sh
* $ pulumi import aws:s3/bucketObject:BucketObject example some-bucket-name/some/key.txt
* ```
* Import using S3 URL syntax:
*
* ```sh
* $ pulumi import aws:s3/bucketObject:BucketObject example s3://some-bucket-name/some/key.txt
* ```
*/
class BucketObject extends pulumi.CustomResource {
/**
* Get an existing BucketObject 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 BucketObject(name, state, Object.assign(Object.assign({}, opts), { id: id }));
}
/**
* Returns true if the given object is an instance of BucketObject. 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'] === BucketObject.__pulumiType;
}
constructor(name, argsOrState, opts) {
let resourceInputs = {};
opts = opts || {};
if (opts.id) {
const state = argsOrState;
resourceInputs["acl"] = state ? state.acl : undefined;
resourceInputs["arn"] = state ? state.arn : undefined;
resourceInputs["bucket"] = state ? state.bucket : undefined;
resourceInputs["bucketKeyEnabled"] = state ? state.bucketKeyEnabled : undefined;
resourceInputs["cacheControl"] = state ? state.cacheControl : undefined;
resourceInputs["content"] = state ? state.content : undefined;
resourceInputs["contentBase64"] = state ? state.contentBase64 : undefined;
resourceInputs["contentDisposition"] = state ? state.contentDisposition : undefined;
resourceInputs["contentEncoding"] = state ? state.contentEncoding : undefined;
resourceInputs["contentLanguage"] = state ? state.contentLanguage : undefined;
resourceInputs["contentType"] = state ? state.contentType : undefined;
resourceInputs["etag"] = state ? state.etag : undefined;
resourceInputs["forceDestroy"] = state ? state.forceDestroy : undefined;
resourceInputs["key"] = state ? state.key : undefined;
resourceInputs["kmsKeyId"] = state ? state.kmsKeyId : undefined;
resourceInputs["metadata"] = state ? state.metadata : undefined;
resourceInputs["objectLockLegalHoldStatus"] = state ? state.objectLockLegalHoldStatus : undefined;
resourceInputs["objectLockMode"] = state ? state.objectLockMode : undefined;
resourceInputs["objectLockRetainUntilDate"] = state ? state.objectLockRetainUntilDate : undefined;
resourceInputs["region"] = state ? state.region : undefined;
resourceInputs["serverSideEncryption"] = state ? state.serverSideEncryption : undefined;
resourceInputs["source"] = state ? state.source : undefined;
resourceInputs["sourceHash"] = state ? state.sourceHash : undefined;
resourceInputs["storageClass"] = state ? state.storageClass : undefined;
resourceInputs["tags"] = state ? state.tags : undefined;
resourceInputs["tagsAll"] = state ? state.tagsAll : undefined;
resourceInputs["versionId"] = state ? state.versionId : undefined;
resourceInputs["websiteRedirect"] = state ? state.websiteRedirect : undefined;
}
else {
const args = argsOrState;
if ((!args || args.bucket === undefined) && !opts.urn) {
throw new Error("Missing required property 'bucket'");
}
resourceInputs["acl"] = args ? args.acl : undefined;
resourceInputs["bucket"] = args ? args.bucket : undefined;
resourceInputs["bucketKeyEnabled"] = args ? args.bucketKeyEnabled : undefined;
resourceInputs["cacheControl"] = args ? args.cacheControl : undefined;
resourceInputs["content"] = args ? args.content : undefined;
resourceInputs["contentBase64"] = args ? args.contentBase64 : undefined;
resourceInputs["contentDisposition"] = args ? args.contentDisposition : undefined;
resourceInputs["contentEncoding"] = args ? args.contentEncoding : undefined;
resourceInputs["contentLanguage"] = args ? args.contentLanguage : undefined;
resourceInputs["contentType"] = args ? args.contentType : undefined;
resourceInputs["etag"] = args ? args.etag : undefined;
resourceInputs["forceDestroy"] = args ? args.forceDestroy : undefined;
resourceInputs["key"] = args ? args.key : undefined;
resourceInputs["kmsKeyId"] = args ? args.kmsKeyId : undefined;
resourceInputs["metadata"] = args ? args.metadata : undefined;
resourceInputs["objectLockLegalHoldStatus"] = args ? args.objectLockLegalHoldStatus : undefined;
resourceInputs["objectLockMode"] = args ? args.objectLockMode : undefined;
resourceInputs["objectLockRetainUntilDate"] = args ? args.objectLockRetainUntilDate : undefined;
resourceInputs["region"] = args ? args.region : undefined;
resourceInputs["serverSideEncryption"] = args ? args.serverSideEncryption : undefined;
resourceInputs["source"] = args ? args.source : undefined;
resourceInputs["sourceHash"] = args ? args.sourceHash : undefined;
resourceInputs["storageClass"] = args ? args.storageClass : undefined;
resourceInputs["tags"] = args ? args.tags : undefined;
resourceInputs["websiteRedirect"] = args ? args.websiteRedirect : undefined;
resourceInputs["arn"] = undefined /*out*/;
resourceInputs["tagsAll"] = undefined /*out*/;
resourceInputs["versionId"] = undefined /*out*/;
}
opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts);
super(BucketObject.__pulumiType, name, resourceInputs, opts);
}
}
exports.BucketObject = BucketObject;
/** @internal */
BucketObject.__pulumiType = 'aws:s3/bucketObject:BucketObject';
//# sourceMappingURL=bucketObject.js.map