pulumi_wasm_providers_aws_mini::s3

Module bucket_website_configuration_v_2

source
Expand description

Provides an S3 bucket website configuration resource. For more information, see Hosting Websites on S3.

This resource cannot be used with S3 directory buckets.

§Example Usage

§With routing_rule configured

use pulumi_wasm_rust::Output;
use pulumi_wasm_rust::{add_export, pulumi_main};
#[pulumi_main]
fn test_main() -> Result<(), Error> {
    let example = bucket_website_configuration_v_2::create(
        "example",
        BucketWebsiteConfigurationV2Args::builder()
            .bucket("${exampleAwsS3Bucket.id}")
            .error_document(
                BucketWebsiteConfigurationV2ErrorDocument::builder()
                    .key("error.html")
                    .build_struct(),
            )
            .index_document(
                BucketWebsiteConfigurationV2IndexDocument::builder()
                    .suffix("index.html")
                    .build_struct(),
            )
            .routing_rules(
                vec![
                    BucketWebsiteConfigurationV2RoutingRule::builder()
                    .condition(BucketWebsiteConfigurationV2RoutingRuleCondition::builder()
                    .keyPrefixEquals("docs/").build_struct())
                    .redirect(BucketWebsiteConfigurationV2RoutingRuleRedirect::builder()
                    .replaceKeyPrefixWith("documents/").build_struct()).build_struct(),
                ],
            )
            .build_struct(),
    );
}

§With routing_rules configured

use pulumi_wasm_rust::Output;
use pulumi_wasm_rust::{add_export, pulumi_main};
#[pulumi_main]
fn test_main() -> Result<(), Error> {
    let example = bucket_website_configuration_v_2::create(
        "example",
        BucketWebsiteConfigurationV2Args::builder()
            .bucket("${exampleAwsS3Bucket.id}")
            .error_document(
                BucketWebsiteConfigurationV2ErrorDocument::builder()
                    .key("error.html")
                    .build_struct(),
            )
            .index_document(
                BucketWebsiteConfigurationV2IndexDocument::builder()
                    .suffix("index.html")
                    .build_struct(),
            )
            .routing_rule_details(
                "[{\n    \"Condition\": {\n        \"KeyPrefixEquals\": \"docs/\"\n    },\n    \"Redirect\": {\n        \"ReplaceKeyPrefixWith\": \"\"\n    }\n}]",
            )
            .build_struct(),
    );
}

§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 (,):

Using pulumi import to import S3 bucket website configuration using the bucket or using the bucket and expected_bucket_owner 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:

$ pulumi import aws:s3/bucketWebsiteConfigurationV2:BucketWebsiteConfigurationV2 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 (,):

$ pulumi import aws:s3/bucketWebsiteConfigurationV2:BucketWebsiteConfigurationV2 example bucket-name,123456789012

Structs§

Functions§

  • Registers a new resource with the given unique name and arguments