@pulumi/aws
Version:
A Pulumi package for creating and managing Amazon Web Services (AWS) cloud resources.
256 lines • 9.26 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.BucketAcl = void 0;
const pulumi = require("@pulumi/pulumi");
const utilities = require("../utilities");
/**
* Provides an S3 bucket ACL resource.
*
* > **Note:** destroy does not delete the S3 Bucket ACL but does remove the resource from state.
*
* > This resource cannot be used with S3 directory buckets.
*
* ## Example Usage
*
* ### With `private` ACL
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as aws from "@pulumi/aws";
*
* const example = new aws.s3.Bucket("example", {bucket: "my-tf-example-bucket"});
* const exampleBucketOwnershipControls = new aws.s3.BucketOwnershipControls("example", {
* bucket: example.id,
* rule: {
* objectOwnership: "BucketOwnerPreferred",
* },
* });
* const exampleBucketAcl = new aws.s3.BucketAcl("example", {
* bucket: example.id,
* acl: "private",
* }, {
* dependsOn: [exampleBucketOwnershipControls],
* });
* ```
*
* ### With `public-read` ACL
*
* > This example explicitly disables the default S3 bucket security settings. This
* should be done with caution, as all bucket objects become publicly exposed.
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as aws from "@pulumi/aws";
*
* const example = new aws.s3.Bucket("example", {bucket: "my-tf-example-bucket"});
* const exampleBucketOwnershipControls = new aws.s3.BucketOwnershipControls("example", {
* bucket: example.id,
* rule: {
* objectOwnership: "BucketOwnerPreferred",
* },
* });
* const exampleBucketPublicAccessBlock = new aws.s3.BucketPublicAccessBlock("example", {
* bucket: example.id,
* blockPublicAcls: false,
* blockPublicPolicy: false,
* ignorePublicAcls: false,
* restrictPublicBuckets: false,
* });
* const exampleBucketAcl = new aws.s3.BucketAcl("example", {
* bucket: example.id,
* acl: "public-read",
* }, {
* dependsOn: [
* exampleBucketOwnershipControls,
* exampleBucketPublicAccessBlock,
* ],
* });
* ```
*
* ### With Grants
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as aws from "@pulumi/aws";
*
* const current = aws.s3.getCanonicalUserId({});
* const example = new aws.s3.Bucket("example", {bucket: "my-tf-example-bucket"});
* const exampleBucketOwnershipControls = new aws.s3.BucketOwnershipControls("example", {
* bucket: example.id,
* rule: {
* objectOwnership: "BucketOwnerPreferred",
* },
* });
* const exampleBucketAcl = new aws.s3.BucketAcl("example", {
* bucket: example.id,
* accessControlPolicy: {
* grants: [
* {
* grantee: {
* id: current.then(current => current.id),
* type: "CanonicalUser",
* },
* permission: "READ",
* },
* {
* grantee: {
* type: "Group",
* uri: "http://acs.amazonaws.com/groups/s3/LogDelivery",
* },
* permission: "READ_ACP",
* },
* ],
* owner: {
* id: current.then(current => current.id),
* },
* },
* }, {
* dependsOn: [exampleBucketOwnershipControls],
* });
* ```
*
* ## Import
*
* ### Identity Schema
*
* #### Required
*
* * `bucket` (String) S3 bucket name.
*
* #### Optional
*
* * `account_id` (String) AWS Account where this resource is managed.
*
* * `acl` (String) Canned ACL to apply to the bucket.
*
* * `expected_bucket_owner` (String) Account ID of the expected bucket owner.
*
* * `region` (String) Region where this resource is managed.
*
* If the owner (account ID) of the source bucket is the _same_ account used to configure the AWS Provider, and the source bucket is **configured** with a
*
* [canned ACL][1] (i.e. predefined grant), import using the `bucket` and `acl` separated by a comma (`,`):
*
* terraform
*
* import {
*
* to = aws_s3_bucket_acl.example
*
* id = "bucket-name,private"
*
* }
*
* If the owner (account ID) of the source bucket _differs_ from the account used to configure the AWS Provider, and the source bucket is **not configured** with a [canned ACL][1] (i.e. predefined grant), imported using the `bucket` and `expected_bucket_owner` separated by a comma (`,`):
*
* terraform
*
* import {
*
* to = aws_s3_bucket_acl.example
*
* id = "bucket-name,123456789012"
*
* }
*
* If the owner (account ID) of the source bucket _differs_ from the account used to configure the AWS Provider, and the source bucket is **configured** with a
*
* [canned ACL][1] (i.e. predefined grant), imported using the `bucket`, `expected_bucket_owner`, and `acl` separated by commas (`,`):
*
* terraform
*
* import {
*
* to = aws_s3_bucket_acl.example
*
* id = "bucket-name,123456789012,private"
*
* }
*
* **Using `pulumi import` to import** using `bucket`, `expected_bucket_owner`, and/or `acl`, depending on your situation. For example:
*
* If the owner (account ID) of the source bucket is the _same_ account used to configure the AWS Provider, and the source bucket is **not configured** with a
*
* [canned ACL][1] (i.e. predefined grant), import using the `bucket`:
*
* console
*
* % pulumi import aws_s3_bucket_acl.example bucket-name
*
* If the owner (account ID) of the source bucket is the _same_ account used to configure the AWS Provider, and the source bucket is **configured** with a [canned ACL][1] (i.e. predefined grant), import using the `bucket` and `acl` separated by a comma (`,`):
*
* console
*
* % pulumi import aws_s3_bucket_acl.example bucket-name,private
*
* If the owner (account ID) of the source bucket _differs_ from the account used to configure the AWS Provider, and the source bucket is **not configured** with a [canned ACL][1] (i.e. predefined grant), imported using the `bucket` and `expected_bucket_owner` separated by a comma (`,`):
*
* console
*
* % pulumi import aws_s3_bucket_acl.example bucket-name,123456789012
*
* If the owner (account ID) of the source bucket _differs_ from the account used to configure the AWS Provider, and the source bucket is **configured** with a [canned ACL][1] (i.e. predefined grant), imported using the `bucket`, `expected_bucket_owner`, and `acl` separated by commas (`,`):
*
* console
*
* % pulumi import aws_s3_bucket_acl.example bucket-name,123456789012,private
*
* [1]: https://docs.aws.amazon.com/AmazonS3/latest/userguide/acl-overview.html#canned-acl
*/
class BucketAcl extends pulumi.CustomResource {
/**
* Get an existing BucketAcl 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 BucketAcl(name, state, { ...opts, id: id });
}
/**
* Returns true if the given object is an instance of BucketAcl. 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'] === BucketAcl.__pulumiType;
}
constructor(name, argsOrState, opts) {
let resourceInputs = {};
opts = opts || {};
if (opts.id) {
const state = argsOrState;
resourceInputs["accessControlPolicy"] = state?.accessControlPolicy;
resourceInputs["acl"] = state?.acl;
resourceInputs["bucket"] = state?.bucket;
resourceInputs["expectedBucketOwner"] = state?.expectedBucketOwner;
resourceInputs["region"] = state?.region;
}
else {
const args = argsOrState;
if (args?.bucket === undefined && !opts.urn) {
throw new Error("Missing required property 'bucket'");
}
resourceInputs["accessControlPolicy"] = args?.accessControlPolicy;
resourceInputs["acl"] = args?.acl;
resourceInputs["bucket"] = args?.bucket;
resourceInputs["expectedBucketOwner"] = args?.expectedBucketOwner;
resourceInputs["region"] = args?.region;
}
opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts);
const aliasOpts = { aliases: [{ type: "aws:s3/bucketAclV2:BucketAclV2" }] };
opts = pulumi.mergeOptions(opts, aliasOpts);
super(BucketAcl.__pulumiType, name, resourceInputs, opts);
}
}
exports.BucketAcl = BucketAcl;
/** @internal */
BucketAcl.__pulumiType = 'aws:s3/bucketAcl:BucketAcl';
//# sourceMappingURL=bucketAcl.js.map