"The IndexDocument Suffix is not well formed" during "Host a static website locally" tutorial

I’m trying to learn LocalStack using the tutorials, specifically “Host a static website locally”. I’m using localstack 3.0.2.

The initial steps succeed:

  1. awslocal s3api create-bucket --bucket testwebsite
  2. awslocal s3api put-bucket-policy --bucket testwebsite --policy file://bucket_policy.json
  3. awslocal s3 sync ./ s3://testwebsite

…but the fourth step returns an error.

  1. awslocal s3 website s3://testwebsite/ --index-document www/index.html --error-document www/error.html

An error occurred (InvalidArgument) when calling the PutBucketWebsite operation: The IndexDocument Suffix is not well formed

The error disappears if I cd into the www directory and remove “www/” from --index-document and --error-document, but is that the expected outcome?

Hi @stephenwithav,

Thanks for pointing that out. It seems that this issue comes from a misinterpretation of the AWS CLI tool. If you run awslocal s3 website help you’ll see:

NAME
       website -

DESCRIPTION
       Set the website configuration for a bucket.

SYNOPSIS

          website
          <S3Uri>
          [--index-document <value>]
          [--error-document <value>]
......
OPTIONS
       paths (string)

       --index-document (string) 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.
........

The value for --index-document should be the key of the file in the bucket, and it should not contain a slash character, which is the cause of the error message.
We’ll have a look into that and fix the tutorial. Also, we’re glad that you managed to get past this small inconvenience.

Thanks again,
Anca

Hi,

The fix has been merged. Please have a look at the new tutorial — Host a static website locally using Simple Storage Service (S3) and Terraform with LocalStack | Docs