AWS Tools for Windows PowerShell
Command Reference

AWS services or capabilities described in AWS Documentation may vary by region/location. Click Getting Started with Amazon AWS to see specific differences applicable to the China (Beijing) Region.

Synopsis

Calls the Amazon Simple Storage Service (S3) PutBucketWebsite API operation.

Syntax

Write-S3BucketWebsite
-BucketName <String>
-ChecksumAlgorithm <ChecksumAlgorithm>
-WebsiteConfiguration_ErrorDocument <String>
-ExpectedBucketOwner <String>
-RedirectAllRequestsTo_HostName <String>
-RedirectAllRequestsTo_HttpRedirectCode <String>
-WebsiteConfiguration_IndexDocumentSuffix <String>
-RedirectAllRequestsTo_Protocol <String>
-RedirectAllRequestsTo_ReplaceKeyPrefixWith <String>
-RedirectAllRequestsTo_ReplaceKeyWith <String>
-WebsiteConfiguration_RoutingRule <RoutingRule[]>
-Select <String>
-PassThru <SwitchParameter>
-Force <SwitchParameter>
-ClientConfig <AmazonS3Config>
-UseAccelerateEndpoint <SwitchParameter>
-UseDualstackEndpoint <SwitchParameter>
-ForcePathStyleAddressing <Boolean>

Description

This operation is not supported by directory buckets. Sets the configuration of the website that is specified in the website subresource. To configure a bucket as a website, you can add this subresource on the bucket with website configuration information such as the file name of the index document and any redirect rules. For more information, see Hosting Websites on Amazon S3. This PUT action requires the S3:PutBucketWebsite permission. By default, only the bucket owner can configure the website attached to a bucket; however, bucket owners can allow other users to set the website configuration by writing a bucket policy that grants them the S3:PutBucketWebsite permission. To redirect all website requests sent to the bucket's website endpoint, you add a website configuration with the following elements. Because all requests are sent to another website, you don't need to provide index document name for the bucket.
  • WebsiteConfiguration
  • RedirectAllRequestsTo
  • HostName
  • Protocol
If you want granular control over redirects, you can use the following elements to add routing rules that describe conditions for redirecting requests and information about the redirect destination. In this case, the website configuration must provide an index document for the bucket, because some requests might not be redirected.
  • WebsiteConfiguration
  • IndexDocument
  • Suffix
  • ErrorDocument
  • Key
  • RoutingRules
  • RoutingRule
  • Condition
  • HttpErrorCodeReturnedEquals
  • KeyPrefixEquals
  • Redirect
  • Protocol
  • HostName
  • ReplaceKeyPrefixWith
  • ReplaceKeyWith
  • HttpRedirectCode
Amazon S3 has a limitation of 50 routing rules per website configuration. If you require more than 50 routing rules, you can use object redirect. For more information, see Configuring an Object Redirect in the Amazon S3 User Guide. The maximum request length is limited to 128 KB.

Parameters

-BucketName <String>
The name of the bucket to apply the configuration to.
Required?False
Position?1
Accept pipeline input?True (ByValue, ByPropertyName)
-ChecksumAlgorithm <ChecksumAlgorithm>
Indicates the algorithm used to create the checksum for the object when you use the SDK. This header will not provide any additional functionality if you don't use the SDK. When you send this header, there must be a corresponding x-amz-checksum or x-amz-trailer header sent. Otherwise, Amazon S3 fails the request with the HTTP status code 400 Bad Request. For more information, see Checking object integrity in the Amazon S3 User Guide.If you provide an individual checksum, Amazon S3 ignores any provided ChecksumAlgorithm parameter.
Required?False
Position?Named
Accept pipeline input?True (ByPropertyName)
-ClientConfig <AmazonS3Config>
Amazon.PowerShell.Cmdlets.S3.AmazonS3ClientCmdlet.ClientConfig
Required?False
Position?Named
Accept pipeline input?True (ByPropertyName)
-ExpectedBucketOwner <String>
The account ID of the expected bucket owner. If the account ID that you provide does not match the actual owner of the bucket, the request fails with the HTTP status code 403 Forbidden (access denied).
Required?False
Position?Named
Accept pipeline input?True (ByPropertyName)
This parameter overrides confirmation prompts to force the cmdlet to continue its operation. This parameter should always be used with caution.
Required?False
Position?Named
Accept pipeline input?True (ByPropertyName)
-ForcePathStyleAddressing <Boolean>
S3 requests can be performed using one of two URI styles: Virtual or Path. When using Virtual style, the bucket is included as part of the hostname. When using Path style the bucket is included as part of the URI path. The default value is $true when the EndpointUrl parameter is specified, $false otherwise.
Required?False
Position?Named
Accept pipeline input?True (ByPropertyName)
-PassThru <SwitchParameter>
Changes the cmdlet behavior to return the value passed to the BucketName parameter. The -PassThru parameter is deprecated, use -Select '^BucketName' instead. This parameter will be removed in a future version.
Required?False
Position?Named
Accept pipeline input?True (ByPropertyName)
-RedirectAllRequestsTo_HostName <String>
Name of the host where requests will be redirected.
Required?False
Position?Named
Accept pipeline input?True (ByPropertyName)
AliasesWebsiteConfiguration_RedirectAllRequestsTo_HostName
-RedirectAllRequestsTo_HttpRedirectCode <String>
The HTTP redirect code to use on the response. Not required if one of the siblings is present.
Required?False
Position?Named
Accept pipeline input?True (ByPropertyName)
AliasesWebsiteConfiguration_RedirectAllRequestsTo_HttpRedirectCode
-RedirectAllRequestsTo_Protocol <String>
Protocol to use (http, https) when redirecting requests. The default is the protocol that is used in the original request.
Required?False
Position?Named
Accept pipeline input?True (ByPropertyName)
AliasesWebsiteConfiguration_RedirectAllRequestsTo_Protocol
-RedirectAllRequestsTo_ReplaceKeyPrefixWith <String>
The object key prefix to use in the redirect request. For example, to redirect requests for all pages with prefix docs/ (objects in the docs/ folder) to documents/, you can set a condition block with KeyPrefixEquals set to docs/ and in the Redirect set ReplaceKeyPrefixWith to /documents. Not required if one of the siblings is present. Can be present only if ReplaceKeyWith is not provided.
Required?False
Position?Named
Accept pipeline input?True (ByPropertyName)
AliasesWebsiteConfiguration_RedirectAllRequestsTo_ReplaceKeyPrefixWith
-RedirectAllRequestsTo_ReplaceKeyWith <String>
The specific object key to use in the redirect request. For example, redirect request to error.html. Not required if one of the sibling is present. Can be present only if ReplaceKeyPrefixWith is not provided.
Required?False
Position?Named
Accept pipeline input?True (ByPropertyName)
AliasesWebsiteConfiguration_RedirectAllRequestsTo_ReplaceKeyWith
-Select <String>
Use the -Select parameter to control the cmdlet output. The cmdlet doesn't have a return value by default. Specifying -Select '*' will result in the cmdlet returning the whole service response (Amazon.S3.Model.PutBucketWebsiteResponse). Specifying -Select '^ParameterName' will result in the cmdlet returning the selected cmdlet parameter value.
Required?False
Position?Named
Accept pipeline input?True (ByPropertyName)
-UseAccelerateEndpoint <SwitchParameter>
Enables S3 accelerate by sending requests to the accelerate endpoint instead of the regular region endpoint. To use this feature, the bucket name must be DNS compliant and must not contain periods (.).
Required?False
Position?Named
Accept pipeline input?True (ByPropertyName)
-UseDualstackEndpoint <SwitchParameter>
Configures the request to Amazon S3 to use the dualstack endpoint for a region. S3 supports dualstack endpoints which return both IPv6 and IPv4 values. The dualstack mode of Amazon S3 cannot be used with accelerate mode.
Required?False
Position?Named
Accept pipeline input?True (ByPropertyName)
-WebsiteConfiguration_ErrorDocument <String>
The ErrorDocument value, an object key name to use when a 4XX class error occurs.
Required?False
Position?Named
Accept pipeline input?True (ByPropertyName)
-WebsiteConfiguration_IndexDocumentSuffix <String>
This value is a suffix that is appended to a request that is for a "directory" on the website endpoint (e.g. if the suffix is index.html and you make a request to samplebucket/images/ the data that is returned will be for the object with the key name images/index.html)The suffix must not be empty and must not include a slash character.
Required?False
Position?Named
Accept pipeline input?True (ByPropertyName)
-WebsiteConfiguration_RoutingRule <RoutingRule[]>
The list of routing rules that can be used for configuring redirects if certain conditions are meet.
Required?False
Position?Named
Accept pipeline input?True (ByPropertyName)
AliasesWebsiteConfiguration_RoutingRules

Common Credential and Region Parameters

-AccessKey <String>
The AWS access key for the user account. This can be a temporary access key if the corresponding session token is supplied to the -SessionToken parameter.
Required?False
Position?Named
Accept pipeline input?True (ByPropertyName)
AliasesAK
-Credential <AWSCredentials>
An AWSCredentials object instance containing access and secret key information, and optionally a token for session-based credentials.
Required?False
Position?Named
Accept pipeline input?True (ByValue, ByPropertyName)
-EndpointUrl <String>
The endpoint to make the call against.Note: This parameter is primarily for internal AWS use and is not required/should not be specified for normal usage. The cmdlets normally determine which endpoint to call based on the region specified to the -Region parameter or set as default in the shell (via Set-DefaultAWSRegion). Only specify this parameter if you must direct the call to a specific custom endpoint.
Required?False
Position?Named
Accept pipeline input?True (ByPropertyName)
-NetworkCredential <PSCredential>
Used with SAML-based authentication when ProfileName references a SAML role profile. Contains the network credentials to be supplied during authentication with the configured identity provider's endpoint. This parameter is not required if the user's default network identity can or should be used during authentication.
Required?False
Position?Named
Accept pipeline input?True (ByValue, ByPropertyName)
-ProfileLocation <String>
Used to specify the name and location of the ini-format credential file (shared with the AWS CLI and other AWS SDKs)If this optional parameter is omitted this cmdlet will search the encrypted credential file used by the AWS SDK for .NET and AWS Toolkit for Visual Studio first. If the profile is not found then the cmdlet will search in the ini-format credential file at the default location: (user's home directory)\.aws\credentials.If this parameter is specified then this cmdlet will only search the ini-format credential file at the location given.As the current folder can vary in a shell or during script execution it is advised that you use specify a fully qualified path instead of a relative path.
Required?False
Position?Named
Accept pipeline input?True (ByPropertyName)
AliasesAWSProfilesLocation, ProfilesLocation
-ProfileName <String>
The user-defined name of an AWS credentials or SAML-based role profile containing credential information. The profile is expected to be found in the secure credential file shared with the AWS SDK for .NET and AWS Toolkit for Visual Studio. You can also specify the name of a profile stored in the .ini-format credential file used with the AWS CLI and other AWS SDKs.
Required?False
Position?Named
Accept pipeline input?True (ByPropertyName)
AliasesStoredCredentials, AWSProfileName
-Region <Object>
The system name of an AWS region or an AWSRegion instance. This governs the endpoint that will be used when calling service operations. Note that the AWS resources referenced in a call are usually region-specific.
Required?False
Position?Named
Accept pipeline input?True (ByPropertyName)
AliasesRegionToCall
-SecretKey <String>
The AWS secret key for the user account. This can be a temporary secret key if the corresponding session token is supplied to the -SessionToken parameter.
Required?False
Position?Named
Accept pipeline input?True (ByPropertyName)
AliasesSK, SecretAccessKey
-SessionToken <String>
The session token if the access and secret keys are temporary session-based credentials.
Required?False
Position?Named
Accept pipeline input?True (ByPropertyName)
AliasesST

Outputs

This cmdlet does not generate any output.The service response (type Amazon.S3.Model.PutBucketWebsiteResponse) can be referenced from properties attached to the cmdlet entry in the $AWSHistory stack.

Examples

Example 1

Write-S3BucketWebsite -BucketName 's3testbucket' -WebsiteConfiguration_IndexDocumentSuffix 'index.html' -WebsiteConfiguration_ErrorDocument 'error.html'
The command enables website hosting for the given bucket with the index document as 'index.html' and error document as 'error.html'.

Supported Version

AWS Tools for PowerShell: 2.x.y.z