Package com.pulumi.aws.s3
Class Bucket
- java.lang.Object
-
- com.pulumi.resources.Resource
-
- com.pulumi.resources.CustomResource
-
- com.pulumi.aws.s3.Bucket
-
public class Bucket extends com.pulumi.resources.CustomResourceProvides a S3 bucket resource. > This resource provides functionality for managing S3 general purpose buckets in an AWS Partition. To manage Amazon S3 Express directory buckets, use the `aws.s3.DirectoryBucket` resource. To manage [S3 on Outposts](https://docs.aws.amazon.com/AmazonS3/latest/dev/S3onOutposts.html), use the `aws.s3control.Bucket` resource. > Object Lock can be enabled by using the `objectLockEnabled` attribute or by using the `aws.s3.BucketObjectLockConfiguration` resource. > To support ABAC (Attribute Based Access Control) in general purpose buckets, this resource will now attempt to send tags in the create request and use the S3 Control tagging APIs [`TagResource`](https://docs.aws.amazon.com/AmazonS3/latest/API/API_control_TagResource.html), [`UntagResource`](https://docs.aws.amazon.com/AmazonS3/latest/API/API_control_UntagResource.html), and [`ListTagsForResource`](https://docs.aws.amazon.com/AmazonS3/latest/API/API_control_ListTagsForResource.html) for read and update operations. The calling principal must have the corresponding `s3:TagResource`, `s3:UntagResource`, and `s3:ListTagsForResource` [IAM permissions](https://docs.aws.amazon.com/service-authorization/latest/reference/list_amazons3.html#amazons3-actions-as-permissions). If the principal lacks the appropriate permissions, the provider will fall back to tagging after creation and using the S3 tagging APIs [`PutBucketTagging`](https://docs.aws.amazon.com/AmazonS3/latest/API/API_PutBucketTagging.html), [`DeleteBucketTagging`](https://docs.aws.amazon.com/AmazonS3/latest/API/API_DeleteBucketTagging.html), and [`GetBucketTagging`](https://docs.aws.amazon.com/AmazonS3/latest/API/API_GetBucketTagging.html) instead. With ABAC enabled, tag modifications may fail with the fall back behavior. See the [AWS documentation](https://docs.aws.amazon.com/AmazonS3/latest/userguide/buckets-tagging-enable-abac.html) for additional details on enabling ABAC in general purpose buckets. ## Example Usage ### Private Bucket With Tags
### Bucket In Account-Regional Namespacepackage generated_program; import com.pulumi.Context; import com.pulumi.Pulumi; import com.pulumi.core.Output; import com.pulumi.aws.s3.Bucket; import com.pulumi.aws.s3.BucketArgs; import java.util.ArrayList; import java.util.Arrays; import java.util.Map; import java.io.File; import java.nio.file.Files; import java.nio.file.Paths; public class App { public static void main(String[] args) { Pulumi.run(App::stack); } public static void stack(Context ctx) { var example = new Bucket("example", BucketArgs.builder() .bucket("my-tf-test-bucket") .tags(Map.ofEntries( Map.entry("Name", "My bucket"), Map.entry("Environment", "Dev") )) .build()); } }
## Import ### Identity Schema #### Required * `bucket` (String) Name of the S3 bucket. #### Optional * `accountId` (String) AWS Account where this resource is managed. * `region` (String) Region where this resource is managed. Using `pulumi import`, import S3 bucket using the `bucket`. For example: ```sh $ pulumi import aws:s3/bucket:Bucket example bucket-name ```package generated_program; import com.pulumi.Context; import com.pulumi.Pulumi; import com.pulumi.core.Output; import com.pulumi.aws.AwsFunctions; import com.pulumi.aws.inputs.GetCallerIdentityArgs; import com.pulumi.aws.inputs.GetRegionArgs; import com.pulumi.aws.s3.Bucket; import com.pulumi.aws.s3.BucketArgs; import com.pulumi.std.StdFunctions; import com.pulumi.std.inputs.FormatArgs; import java.util.ArrayList; import java.util.Arrays; import java.util.Map; import java.io.File; import java.nio.file.Files; import java.nio.file.Paths; public class App { public static void main(String[] args) { Pulumi.run(App::stack); } public static void stack(Context ctx) { final var current = AwsFunctions.getCallerIdentity(GetCallerIdentityArgs.builder() .build()); final var currentGetRegion = AwsFunctions.getRegion(GetRegionArgs.builder() .build()); var example = new Bucket("example", BucketArgs.builder() .bucket(StdFunctions.format(FormatArgs.builder() .input("my-tf-test-bucket-%s-%s-an") .args( current.accountId(), currentGetRegion.region()) .build()).result()) .bucketNamespace("account-regional") .build()); } }
-
-
Constructor Summary
Constructors Constructor Description Bucket(java.lang.String name)Bucket(java.lang.String name, BucketArgs args)Bucket(java.lang.String name, BucketArgs args, com.pulumi.resources.CustomResourceOptions options)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description com.pulumi.core.Output<java.lang.String>accelerationStatus()com.pulumi.core.Output<java.lang.String>acl()com.pulumi.core.Output<java.lang.String>arn()com.pulumi.core.Output<java.lang.String>bucket()com.pulumi.core.Output<java.lang.String>bucketDomainName()com.pulumi.core.Output<java.lang.String>bucketNamespace()com.pulumi.core.Output<java.lang.String>bucketPrefix()com.pulumi.core.Output<java.lang.String>bucketRegion()com.pulumi.core.Output<java.lang.String>bucketRegionalDomainName()com.pulumi.core.Output<java.util.List<BucketCorsRule>>corsRules()com.pulumi.core.Output<java.util.Optional<java.lang.Boolean>>forceDestroy()static Bucketget(java.lang.String name, com.pulumi.core.Output<java.lang.String> id, BucketState state, com.pulumi.resources.CustomResourceOptions options)Get an existing Host resource's state with the given name, ID, and optional extra properties used to qualify the lookup.com.pulumi.core.Output<java.util.List<BucketGrant>>grants()com.pulumi.core.Output<java.lang.String>hostedZoneId()com.pulumi.core.Output<java.util.List<BucketLifecycleRule>>lifecycleRules()com.pulumi.core.Output<BucketLogging>logging()com.pulumi.core.Output<BucketObjectLockConfiguration>objectLockConfiguration()com.pulumi.core.Output<java.lang.Boolean>objectLockEnabled()com.pulumi.core.Output<java.lang.String>policy()com.pulumi.core.Output<java.lang.String>region()com.pulumi.core.Output<BucketReplicationConfiguration>replicationConfiguration()com.pulumi.core.Output<java.lang.String>requestPayer()com.pulumi.core.Output<BucketServerSideEncryptionConfiguration>serverSideEncryptionConfiguration()com.pulumi.core.Output<java.util.Optional<java.util.Map<java.lang.String,java.lang.String>>>tags()com.pulumi.core.Output<java.util.Map<java.lang.String,java.lang.String>>tagsAll()com.pulumi.core.Output<BucketVersioning>versioning()com.pulumi.core.Output<BucketWebsite>website()com.pulumi.core.Output<java.lang.String>websiteDomain()com.pulumi.core.Output<java.lang.String>websiteEndpoint()
-
-
-
Constructor Detail
-
Bucket
public Bucket(java.lang.String name)
- Parameters:
name- The _unique_ name of the resulting resource.
-
Bucket
public Bucket(java.lang.String name, @Nullable BucketArgs args)- Parameters:
name- The _unique_ name of the resulting resource.args- The arguments to use to populate this resource's properties.
-
Bucket
public Bucket(java.lang.String name, @Nullable BucketArgs args, @Nullable com.pulumi.resources.CustomResourceOptions options)- Parameters:
name- The _unique_ name of the resulting resource.args- The arguments to use to populate this resource's properties.options- A bag of options that control this resource's behavior.
-
-
Method Detail
-
accelerationStatus
public com.pulumi.core.Output<java.lang.String> accelerationStatus()
- Returns:
- Sets the accelerate configuration of an existing bucket. Can be `Enabled` or `Suspended`. Cannot be used in `cn-north-1` or `us-gov-west-1`. This provider will only perform drift detection if a configuration value is provided. Use the resource `aws.s3.BucketAccelerateConfiguration` instead.
-
acl
public com.pulumi.core.Output<java.lang.String> acl()
- Returns:
- [Canned ACL](https://docs.aws.amazon.com/AmazonS3/latest/dev/acl-overview.html#canned-acl) to apply. Valid values are `private`, `public-read`, `public-read-write`, `aws-exec-read`, `authenticated-read`, and `log-delivery-write`. Defaults to `private`. Conflicts with `grant`. The provider will only perform drift detection if a configuration value is provided. Use the resource `aws.s3.BucketAcl` instead.
-
arn
public com.pulumi.core.Output<java.lang.String> arn()
- Returns:
- ARN of the bucket. Will be of format `arn:aws:s3:::bucketname`.
-
bucket
public com.pulumi.core.Output<java.lang.String> bucket()
- Returns:
- Name of the bucket. If omitted, the provider will assign a random, unique name. Must be lowercase and less than or equal to 63 characters in length. A full list of bucket naming rules [may be found here](https://docs.aws.amazon.com/AmazonS3/latest/userguide/bucketnamingrules.html). The name must not be in the format `[bucketName]--[azid]--x-s3`. Use the `aws.s3.DirectoryBucket` resource to manage S3 Express buckets.
-
bucketDomainName
public com.pulumi.core.Output<java.lang.String> bucketDomainName()
- Returns:
- Bucket domain name. Will be of format `bucketname.s3.amazonaws.com`.
-
bucketNamespace
public com.pulumi.core.Output<java.lang.String> bucketNamespace()
- Returns:
- Namespace for the bucket. Determines bucket naming scope. Valid values: `account-regional`, `global`. Defaults to `global` (AWS).
-
bucketPrefix
public com.pulumi.core.Output<java.lang.String> bucketPrefix()
- Returns:
- Creates a unique bucket name beginning with the specified prefix. Conflicts with `bucket`. Must be lowercase and less than or equal to 37 characters in length. A full list of bucket naming rules [may be found here](https://docs.aws.amazon.com/AmazonS3/latest/userguide/bucketnamingrules.html).
-
bucketRegion
public com.pulumi.core.Output<java.lang.String> bucketRegion()
- Returns:
- AWS region this bucket resides in.
-
bucketRegionalDomainName
public com.pulumi.core.Output<java.lang.String> bucketRegionalDomainName()
- Returns:
- Bucket region-specific domain name. The bucket domain name including the region name. Please refer to the [S3 endpoints reference](https://docs.aws.amazon.com/general/latest/gr/s3.html#s3_region) for format. Note: AWS CloudFront allows specifying an S3 region-specific endpoint when creating an S3 origin. This will prevent redirect issues from CloudFront to the S3 Origin URL. For more information, see the [Virtual Hosted-Style Requests for Other Regions](https://docs.aws.amazon.com/AmazonS3/latest/userguide/VirtualHosting.html#deprecated-global-endpoint) section in the AWS S3 User Guide.
-
corsRules
public com.pulumi.core.Output<java.util.List<BucketCorsRule>> corsRules()
- Returns:
- Rule of [Cross-Origin Resource Sharing](https://docs.aws.amazon.com/AmazonS3/latest/dev/cors.html). See `corsRule` Block below for details. The provider will only perform drift detection if a configuration value is provided. Use the resource `aws.s3.BucketCorsConfiguration` instead.
-
forceDestroy
public com.pulumi.core.Output<java.util.Optional<java.lang.Boolean>> forceDestroy()
- Returns:
- Boolean that indicates all objects (including any [locked objects](https://docs.aws.amazon.com/AmazonS3/latest/dev/object-lock-overview.html)) should be deleted from the bucket *when the bucket is destroyed* so that the bucket can be destroyed without error. These objects are *not* recoverable. This only deletes objects when the bucket is destroyed, *not* when setting this parameter to `true`. Once this parameter is set to `true`, there must be a successful `pulumi up` run before a destroy is required to update this value in the resource state. Without a successful `pulumi up` after this parameter is set, this flag will have no effect. If setting this field in the same operation that would require replacing the bucket or destroying the bucket, this flag will not work. Additionally when importing a bucket, a successful `pulumi up` is required to set this value in state before it will take effect on a destroy operation.
-
grants
public com.pulumi.core.Output<java.util.List<BucketGrant>> grants()
- Returns:
- [ACL policy grant](https://docs.aws.amazon.com/AmazonS3/latest/dev/acl-overview.html#sample-acl). See `grant` Block below for details. Conflicts with `acl`. The provider will only perform drift detection if a configuration value is provided. Use the resource `aws.s3.BucketAcl` instead.
-
hostedZoneId
public com.pulumi.core.Output<java.lang.String> hostedZoneId()
- Returns:
- [Route 53 Hosted Zone ID](https://docs.aws.amazon.com/general/latest/gr/rande.html#s3_website_region_endpoints) for this bucket's region.
-
lifecycleRules
public com.pulumi.core.Output<java.util.List<BucketLifecycleRule>> lifecycleRules()
- Returns:
- Configuration of [object lifecycle management](http://docs.aws.amazon.com/AmazonS3/latest/dev/object-lifecycle-mgmt.html). See `lifecycleRule` Block below for details. The provider will only perform drift detection if a configuration value is provided. Use the resource `aws.s3.BucketLifecycleConfiguration` instead.
-
logging
public com.pulumi.core.Output<BucketLogging> logging()
- Returns:
- Configuration of [S3 bucket logging](https://docs.aws.amazon.com/AmazonS3/latest/UG/ManagingBucketLogging.html) parameters. See `logging` Block below for details. The provider will only perform drift detection if a configuration value is provided. Use the resource `aws.s3.BucketLogging` instead.
-
objectLockConfiguration
public com.pulumi.core.Output<BucketObjectLockConfiguration> objectLockConfiguration()
- Returns:
- Configuration of [S3 object locking](https://docs.aws.amazon.com/AmazonS3/latest/dev/object-lock.html). See `objectLockConfiguration` Block below for details. The provider will only perform drift detection if a configuration value is provided. Use the `objectLockEnabled` parameter and the resource `aws.s3.BucketObjectLockConfiguration` instead.
-
objectLockEnabled
public com.pulumi.core.Output<java.lang.Boolean> objectLockEnabled()
- Returns:
- Whether this bucket has an Object Lock configuration enabled. Valid values are `true` or `false`. This argument is not supported in all regions or partitions.
-
policy
public com.pulumi.core.Output<java.lang.String> policy()
- Returns:
- Valid [bucket policy](https://docs.aws.amazon.com/AmazonS3/latest/dev/example-bucket-policies.html) JSON document. Note that if the policy document is not specific enough (but still valid), this provider may view the policy as constantly changing. In this case, please make sure you use the verbose/specific version of the policy. For more information about building AWS IAM policy documents with this provider, see the AWS IAM Policy Document Guide. The provider will only perform drift detection if a configuration value is provided. Use the resource `aws.s3.BucketPolicy` instead.
-
region
public com.pulumi.core.Output<java.lang.String> region()
- Returns:
- Region where this resource will be [managed](https://docs.aws.amazon.com/general/latest/gr/rande.html#regional-endpoints). Defaults to the Region set in the provider configuration.
-
replicationConfiguration
public com.pulumi.core.Output<BucketReplicationConfiguration> replicationConfiguration()
- Returns:
- Configuration of [replication configuration](http://docs.aws.amazon.com/AmazonS3/latest/dev/crr.html). See `replicationConfiguration` Block below for details. The provider will only perform drift detection if a configuration value is provided. Use the resource `aws.s3.BucketReplicationConfig` instead.
-
requestPayer
public com.pulumi.core.Output<java.lang.String> requestPayer()
- Returns:
- Who should bear the cost of Amazon S3 data transfer. Can be either `BucketOwner` or `Requester`. By default, the owner of the S3 bucket would incur the costs of any data transfer. See [Requester Pays Buckets](http://docs.aws.amazon.com/AmazonS3/latest/dev/RequesterPaysBuckets.html) developer guide for more information. The provider will only perform drift detection if a configuration value is provided. Use the resource `aws.s3.BucketRequestPaymentConfiguration` instead.
-
serverSideEncryptionConfiguration
public com.pulumi.core.Output<BucketServerSideEncryptionConfiguration> serverSideEncryptionConfiguration()
- Returns:
- Configuration of [server-side encryption configuration](http://docs.aws.amazon.com/AmazonS3/latest/dev/bucket-encryption.html). See `serverSideEncryptionConfiguration` Block below for details. The provider will only perform drift detection if a configuration value is provided. Use the resource `aws.s3.BucketServerSideEncryptionConfiguration` instead.
-
tags
public com.pulumi.core.Output<java.util.Optional<java.util.Map<java.lang.String,java.lang.String>>> tags()
- Returns:
- Map of tags to assign to the bucket. If configured with a provider `defaultTags` configuration block present, tags with matching keys will overwrite those defined at the provider-level.
-
tagsAll
public com.pulumi.core.Output<java.util.Map<java.lang.String,java.lang.String>> tagsAll()
- Returns:
- Map of tags assigned to the resource, including those inherited from the provider `defaultTags` configuration block.
-
versioning
public com.pulumi.core.Output<BucketVersioning> versioning()
- Returns:
- Configuration of the [S3 bucket versioning state](https://docs.aws.amazon.com/AmazonS3/latest/dev/Versioning.html). See `versioning` Block below for details. The provider will only perform drift detection if a configuration value is provided. Use the resource `aws.s3.BucketVersioning` instead.
-
website
public com.pulumi.core.Output<BucketWebsite> website()
- Returns:
- Configuration of the [S3 bucket website](https://docs.aws.amazon.com/AmazonS3/latest/userguide/WebsiteHosting.html). See `website` Block below for details. The provider will only perform drift detection if a configuration value is provided. Use the resource `aws.s3.BucketWebsiteConfiguration` instead.
-
websiteDomain
public com.pulumi.core.Output<java.lang.String> websiteDomain()
- Returns:
- (**Deprecated**) Domain of the website endpoint, if the bucket is configured with a website. If not, this will be an empty string. This is used to create Route 53 alias records. Use the resource `aws.s3.BucketWebsiteConfiguration` instead.
-
websiteEndpoint
public com.pulumi.core.Output<java.lang.String> websiteEndpoint()
- Returns:
- (**Deprecated**) Website endpoint, if the bucket is configured with a website. If not, this will be an empty string. Use the resource `aws.s3.BucketWebsiteConfiguration` instead.
-
get
public static Bucket get(java.lang.String name, com.pulumi.core.Output<java.lang.String> id, @Nullable BucketState state, @Nullable com.pulumi.resources.CustomResourceOptions options)
Get an existing Host resource's state with the given name, ID, and optional extra properties used to qualify the lookup.- Parameters:
name- The _unique_ name of the resulting resource.id- The _unique_ provider ID of the resource to lookup.state-options- Optional settings to control the behavior of the CustomResource.
-
-