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>
-WebsiteConfiguration_ErrorDocument <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>

Description

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 operation 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

Parameters

-BucketName <String>
The name of the bucket to apply the configuration to.
Required?False
Position?1
Accept pipeline input?True (ByValue, 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)
-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)
-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)
Aliases AK
-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 (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. Note that the encrypted credential file is not supported on all platforms. It will be skipped when searching for profiles on Windows Nano Server, Mac, and Linux platforms.

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)
Aliases AWSProfilesLocation, 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)
Aliases AWSProfileName, StoredCredentials
-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 (ByPropertyName)
-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)
Aliases SecretAccessKey, SK
-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)
Aliases ST
-Region <String>
The system name of the AWS region in which the operation should be invoked. For example, us-east-1, eu-west-1 etc.
Required? False
Position? Named
Accept pipeline input? True (ByPropertyName)
Aliases RegionToCall
-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)

Inputs

You can pipe a String object to this cmdlet for the BucketName parameter.

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.

Supported Version

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