Class BucketWebsiteConfiguration


  • public class BucketWebsiteConfiguration
    extends com.pulumi.resources.CustomResource
    Provides an S3 bucket website configuration resource. For more information, see [Hosting Websites on S3](https://docs.aws.amazon.com/AmazonS3/latest/dev/WebsiteHosting.html). > This resource cannot be used with S3 directory buckets. ## Example Usage ### With `routingRule` configured
     
     package generated_program;
     
     import com.pulumi.Context;
     import com.pulumi.Pulumi;
     import com.pulumi.core.Output;
     import com.pulumi.aws.s3.BucketWebsiteConfiguration;
     import com.pulumi.aws.s3.BucketWebsiteConfigurationArgs;
     import com.pulumi.aws.s3.inputs.BucketWebsiteConfigurationIndexDocumentArgs;
     import com.pulumi.aws.s3.inputs.BucketWebsiteConfigurationErrorDocumentArgs;
     import com.pulumi.aws.s3.inputs.BucketWebsiteConfigurationRoutingRuleArgs;
     import com.pulumi.aws.s3.inputs.BucketWebsiteConfigurationRoutingRuleConditionArgs;
     import com.pulumi.aws.s3.inputs.BucketWebsiteConfigurationRoutingRuleRedirectArgs;
     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 BucketWebsiteConfiguration("example", BucketWebsiteConfigurationArgs.builder()
                 .indexDocument(BucketWebsiteConfigurationIndexDocumentArgs.builder()
                     .suffix("index.html")
                     .build())
                 .errorDocument(BucketWebsiteConfigurationErrorDocumentArgs.builder()
                     .key("error.html")
                     .build())
                 .routingRules(BucketWebsiteConfigurationRoutingRuleArgs.builder()
                     .condition(BucketWebsiteConfigurationRoutingRuleConditionArgs.builder()
                         .keyPrefixEquals("docs/")
                         .build())
                     .redirect(BucketWebsiteConfigurationRoutingRuleRedirectArgs.builder()
                         .replaceKeyPrefixWith("documents/")
                         .build())
                     .build())
                 .bucket(exampleAwsS3Bucket.id())
                 .build());
     
         }
     }
     
     
    ### With `routingRules` configured
     
     package generated_program;
     
     import com.pulumi.Context;
     import com.pulumi.Pulumi;
     import com.pulumi.core.Output;
     import com.pulumi.aws.s3.BucketWebsiteConfiguration;
     import com.pulumi.aws.s3.BucketWebsiteConfigurationArgs;
     import com.pulumi.aws.s3.inputs.BucketWebsiteConfigurationIndexDocumentArgs;
     import com.pulumi.aws.s3.inputs.BucketWebsiteConfigurationErrorDocumentArgs;
     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 BucketWebsiteConfiguration("example", BucketWebsiteConfigurationArgs.builder()
                 .indexDocument(BucketWebsiteConfigurationIndexDocumentArgs.builder()
                     .suffix("index.html")
                     .build())
                 .errorDocument(BucketWebsiteConfigurationErrorDocumentArgs.builder()
                     .key("error.html")
                     .build())
                 .bucket(exampleAwsS3Bucket.id())
                 .routingRuleDetails("""
     [{
         \"Condition\": {
             \"KeyPrefixEquals\": \"docs/\"
         },
         \"Redirect\": {
             \"ReplaceKeyPrefixWith\": \"\"
         }
     }]
                 """)
                 .build());
     
         }
     }
     
     
    ## Import ### Identity Schema #### Required * `bucket` (String) S3 bucket name. #### Optional * `accountId` (String) AWS Account where this resource is managed. * `region` (String) Region where this resource is managed. If the owner (account ID) of the source bucket differs from the account used to configure the AWS Provider, import using the `bucket` and `expectedBucketOwner` separated by a comma (`,`): **Using `pulumi import` to import** S3 bucket website configuration using the `bucket` or using the `bucket` and `expectedBucketOwner` 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/bucketWebsiteConfiguration:BucketWebsiteConfiguration 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 `expectedBucketOwner` separated by a comma (`,`): ```sh $ pulumi import aws:s3/bucketWebsiteConfiguration:BucketWebsiteConfiguration example bucket-name,123456789012 ```
    • Constructor Detail

      • BucketWebsiteConfiguration

        public BucketWebsiteConfiguration​(java.lang.String name)
        Parameters:
        name - The _unique_ name of the resulting resource.
      • BucketWebsiteConfiguration

        public BucketWebsiteConfiguration​(java.lang.String name,
                                          BucketWebsiteConfigurationArgs args)
        Parameters:
        name - The _unique_ name of the resulting resource.
        args - The arguments to use to populate this resource's properties.
      • BucketWebsiteConfiguration

        public BucketWebsiteConfiguration​(java.lang.String name,
                                          BucketWebsiteConfigurationArgs 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

      • bucket

        public com.pulumi.core.Output<java.lang.String> bucket()
        Returns:
        Name of the bucket.
      • expectedBucketOwner

        public com.pulumi.core.Output<java.util.Optional<java.lang.String>> expectedBucketOwner()
        Returns:
        Account ID of the expected bucket owner.
      • redirectAllRequestsTo

        public com.pulumi.core.Output<java.util.Optional<BucketWebsiteConfigurationRedirectAllRequestsTo>> redirectAllRequestsTo()
        Returns:
        Redirect behavior for every request to this bucket's website endpoint. See below. Conflicts with `errorDocument`, `indexDocument`, and `routingRule`.
      • 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.
      • routingRuleDetails

        public com.pulumi.core.Output<java.lang.String> routingRuleDetails()
        Returns:
        JSON array containing [routing rules](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-s3-websiteconfiguration-routingrules.html) describing redirect behavior and when redirects are applied. Use this parameter when your routing rules contain empty String values (`""`) as seen in the example above.
      • routingRules

        public com.pulumi.core.Output<java.util.List<BucketWebsiteConfigurationRoutingRule>> routingRules()
        Returns:
        List of rules that define when a redirect is applied and the redirect behavior. See below.
      • websiteDomain

        public com.pulumi.core.Output<java.lang.String> websiteDomain()
        Returns:
        Domain of the website endpoint. This is used to create Route 53 alias records.
      • websiteEndpoint

        public com.pulumi.core.Output<java.lang.String> websiteEndpoint()
        Returns:
        Website endpoint.
      • get

        public static BucketWebsiteConfiguration get​(java.lang.String name,
                                                     com.pulumi.core.Output<java.lang.String> id,
                                                     @Nullable
                                                     BucketWebsiteConfigurationState 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.