Skip to content

Commit

Permalink
chore: update CHANGELOG.md for #589
Browse files Browse the repository at this point in the history
  • Loading branch information
changelogbot authored and azrod committed Nov 8, 2023
1 parent 186efbb commit 838957d
Show file tree
Hide file tree
Showing 22 changed files with 1,884 additions and 4 deletions.
11 changes: 11 additions & 0 deletions .changelog/587.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
```release-note:new-resource
`resource/cloudavenue_s3_bucket_website_configuration`- Allow to configure website on your S3 Bucket.
```

```release-note:new-data-source
`datasource/cloudavenue_s3_bucket_website_configuration`- Allow to read website configuration on your S3 Bucket.
```

```release-note:dependency
deps: bumps github.com/FrangipaneTeam/terraform-plugin-framework-superschema from 1.6.0 to 1.6.1
```
2 changes: 1 addition & 1 deletion cmd/types-generator/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -121,4 +121,4 @@ gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33
gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
94 changes: 94 additions & 0 deletions docs/data-sources/s3_bucket_website_configuration.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
---
page_title: "cloudavenue_s3_bucket_website_configuration Data Source - cloudavenue"
subcategory: "S3 (Object Storage)"
description: |-
The cloudavenue_s3_bucket_website_configuration data source allows you to retrieve information about a configuration of static websites content. For more information https://docs.aws.amazon.com/AmazonS3/latest/userguide/WebsiteHosting.html
---

# cloudavenue_s3_bucket_website_configuration (Data Source)

The `cloudavenue_s3_bucket_website_configuration` data source allows you to retrieve information about a configuration of static websites content. [For more information](https://docs.aws.amazon.com/AmazonS3/latest/userguide/WebsiteHosting.html)



<!-- schema generated by tfplugindocs -->
## Schema

### Required

- `bucket` (String) The name of the bucket.

### Optional

- `timeouts` (Attributes) (see [below for nested schema](#nestedatt--timeouts))

### Read-Only

- `error_document` (Attributes) The name of the error document for the website. (see [below for nested schema](#nestedatt--error_document))
- `id` (String) The ID of the bucket website. This is the same as the bucket name.
- `index_document` (Attributes) The name of the index document. (see [below for nested schema](#nestedatt--index_document))
- `redirect_all_requests_to` (Attributes) Redirect behavior for every request to this bucket's website endpoint. [For more information](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_website_configuration#redirect_all_requests_to). (see [below for nested schema](#nestedatt--redirect_all_requests_to))
- `routing_rules` (Attributes Set) Rules that define when a redirect is applied and the redirect behavior. [For more information](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_website_configuration#routing_rule). (see [below for nested schema](#nestedatt--routing_rules))
- `website_endpoint` (String) The website endpoint.

<a id="nestedatt--timeouts"></a>
### Nested Schema for `timeouts`

Optional:

- `read` (String) A string that can be [parsed as a duration](https://pkg.go.dev/time#ParseDuration) consisting of numbers and unit suffixes, such as "30s" or "2h45m". Valid time units are "s" (seconds), "m" (minutes), "h" (hours).


<a id="nestedatt--error_document"></a>
### Nested Schema for `error_document`

Read-Only:

- `key` (String) The key of the error document.


<a id="nestedatt--index_document"></a>
### Nested Schema for `index_document`

Read-Only:

- `suffix` (String) The suffix of the index document.


<a id="nestedatt--redirect_all_requests_to"></a>
### Nested Schema for `redirect_all_requests_to`

Read-Only:

- `hostname` (String) Name of the host where requests will be redirected.
- `protocol` (String) Protocol to use when redirecting requests. The default is the protocol that is used in the original request.


<a id="nestedatt--routing_rules"></a>
### Nested Schema for `routing_rules`

Read-Only:

- `condition` (Attributes) Configuration block for describing a condition that must be met for the specified redirect to apply. [For more information](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_website_configuration#condition). (see [below for nested schema](#nestedatt--routing_rules--condition))
- `redirect` (Attributes) Configuration block for redirecting all requests to another host instead of the original host. [For more information](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_website_configuration#redirect). (see [below for nested schema](#nestedatt--routing_rules--redirect))

<a id="nestedatt--routing_rules--condition"></a>
### Nested Schema for `routing_rules.condition`

Read-Only:

- `http_error_code_returned_equals` (String) The HTTP error code when the redirect is applied. In the event of an error, if the error code equals this value, then the specified redirect is applied. Required when parent element `key_prefix_equals` is specified and parent element `http_redirect` is not.
- `key_prefix_equals` (String) The object key name prefix when the redirect is applied. For example, to redirect requests for `ExamplePage.html`, the key prefix will be `ExamplePage.html`. To redirect request for all pages with the prefix `docs/`, the key prefix will be `docs`, which identifies all objects in the docs/ folder.


<a id="nestedatt--routing_rules--redirect"></a>
### Nested Schema for `routing_rules.redirect`

Read-Only:

- `hostname` (String) Name of the host where requests will be redirected.
- `http_redirect_code` (String) HTTP redirect code to use on the response.
- `protocol` (String) Protocol to use when redirecting requests. The default is the protocol that is used in the original request.
- `replace_key_prefix_with` (String) .
- `replace_key_with` (String) .

183 changes: 183 additions & 0 deletions docs/resources/s3_bucket_website_configuration.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,183 @@
---
page_title: "cloudavenue_s3_bucket_website_configuration Resource - cloudavenue"
subcategory: "S3 (Object Storage)"
description: |-
The cloudavenue_s3_bucket_website_configuration resource allows you to manage a configuration to host static websites content. For more information https://docs.aws.amazon.com/AmazonS3/latest/userguide/WebsiteHosting.html
---

# cloudavenue_s3_bucket_website_configuration (Resource)

The `cloudavenue_s3_bucket_website_configuration` resource allows you to manage a configuration to host static websites content. [For more information](https://docs.aws.amazon.com/AmazonS3/latest/userguide/WebsiteHosting.html)

## Examples Usage

### Simple routing rule

```hcl
resource "cloudavenue_s3_bucket_website_configuration" "example" {
bucket = cloudavenue_s3_bucket.example.name
index_document = {
suffix = "index.html"
}
error_document = {
key = "error.html"
}
routing_rules = [{
condition = {
key_prefix_equals = "docs/"
}
redirect = {
replace_key_prefix_with = "documents/"
}
}]
}
```

### Multiple routing rules

```hcl
resource "cloudavenue_s3_bucket_website_configuration" "example" {
bucket = cloudavenue_s3_bucket.example.name
index_document = {
suffix = "home.html"
}
error_document = {
key = "errors.html"
}
routing_rules = [{
condition = {
key_prefix_equals = "img/"
}
redirect = {
replace_key_prefix_with = "imgs/"
hostname = "www.example.com"
http_redirect_code = "302"
protocol = "https"
}
},
{
condition = {
http_error_code_returned_equals = "404"
}
redirect = {
replace_key_with = "errors.html"
hostname = "www.example.com"
http_redirect_code = "301"
protocol = "https"
}
}]
}
```

### Redirect all requests to a specific hostname

```hcl
resource "cloudavenue_s3_bucket_website_configuration" "example" {
bucket = cloudavenue_s3_bucket.example.name
redirect_all_requests_to = {
hostname = "example.com"
}
}
```

<!-- schema generated by tfplugindocs -->
## Schema

### Required

- `bucket` (String) (ForceNew) The name of the bucket.

### Optional

- `error_document` (Attributes) The name of the error document for the website. (see [below for nested schema](#nestedatt--error_document))
- `index_document` (Attributes) The name of the index document. (see [below for nested schema](#nestedatt--index_document))
- `redirect_all_requests_to` (Attributes) Redirect behavior for every request to this bucket's website endpoint. [For more information](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_website_configuration#redirect_all_requests_to). Ensure that if an attribute is set, these are not set: "[index_document,error_document,routing_rules]". (see [below for nested schema](#nestedatt--redirect_all_requests_to))
- `routing_rules` (Attributes Set) Rules that define when a redirect is applied and the redirect behavior. [For more information](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_website_configuration#routing_rule). Ensure that if an attribute is set, these are not set: "[redirect_all_requests_to]". (see [below for nested schema](#nestedatt--routing_rules))
- `timeouts` (Attributes) (see [below for nested schema](#nestedatt--timeouts))

### Read-Only

- `id` (String) The ID of the bucket website. This is the same as the bucket name.
- `website_endpoint` (String) The website endpoint.

<a id="nestedatt--error_document"></a>
### Nested Schema for `error_document`

Required:

- `key` (String) The key of the error document. Ensure that if an attribute is set, these are not set: "[redirect_all_requests_to]".


<a id="nestedatt--index_document"></a>
### Nested Schema for `index_document`

Required:

- `suffix` (String) The suffix of the index document. Ensure that if an attribute is set, these are not set: "[redirect_all_requests_to]".


<a id="nestedatt--redirect_all_requests_to"></a>
### Nested Schema for `redirect_all_requests_to`

Required:

- `hostname` (String) Name of the host where requests will be redirected.

Optional:

- `protocol` (String) Protocol to use when redirecting requests. The default is the protocol that is used in the original request. Value must be one of : `http`, `https`.


<a id="nestedatt--routing_rules"></a>
### Nested Schema for `routing_rules`

Required:

- `redirect` (Attributes) Configuration block for redirecting all requests to another host instead of the original host. [For more information](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_website_configuration#redirect). (see [below for nested schema](#nestedatt--routing_rules--redirect))

Optional:

- `condition` (Attributes) Configuration block for describing a condition that must be met for the specified redirect to apply. [For more information](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_website_configuration#condition). (see [below for nested schema](#nestedatt--routing_rules--condition))

<a id="nestedatt--routing_rules--redirect"></a>
### Nested Schema for `routing_rules.redirect`

Optional:

- `hostname` (String) Name of the host where requests will be redirected.
- `http_redirect_code` (String) HTTP redirect code to use on the response. Value must be one of : `301`, `302`.
- `protocol` (String) Protocol to use when redirecting requests. The default is the protocol that is used in the original request. Value must be one of : `http`, `https`.
- `replace_key_prefix_with` (String) .
- `replace_key_with` (String) . Ensure that if an attribute is set, these are not set: "[<.replace_key_prefix_with]".


<a id="nestedatt--routing_rules--condition"></a>
### Nested Schema for `routing_rules.condition`

Optional:

- `http_error_code_returned_equals` (String) The HTTP error code when the redirect is applied. In the event of an error, if the error code equals this value, then the specified redirect is applied. Required when parent element `key_prefix_equals` is specified and parent element `http_redirect` is not. Ensure that if an attribute is set, these are not set: "[redirect_all_requests_to]".
- `key_prefix_equals` (String) The object key name prefix when the redirect is applied. For example, to redirect requests for `ExamplePage.html`, the key prefix will be `ExamplePage.html`. To redirect request for all pages with the prefix `docs/`, the key prefix will be `docs`, which identifies all objects in the docs/ folder. Ensure that if an attribute is set, these are not set: "[redirect_all_requests_to]".



<a id="nestedatt--timeouts"></a>
### Nested Schema for `timeouts`

Optional:

- `create` (String) A string that can be [parsed as a duration](https://pkg.go.dev/time#ParseDuration) consisting of numbers and unit suffixes, such as "30s" or "2h45m". Valid time units are "s" (seconds), "m" (minutes), "h" (hours).
- `delete` (String) A string that can be [parsed as a duration](https://pkg.go.dev/time#ParseDuration) consisting of numbers and unit suffixes, such as "30s" or "2h45m". Valid time units are "s" (seconds), "m" (minutes), "h" (hours). Setting a timeout for a Delete operation is only applicable if changes are saved into state before the destroy operation occurs.
- `read` (String) A string that can be [parsed as a duration](https://pkg.go.dev/time#ParseDuration) consisting of numbers and unit suffixes, such as "30s" or "2h45m". Valid time units are "s" (seconds), "m" (minutes), "h" (hours). Read operations occur during any refresh or planning operation when refresh is enabled.
- `update` (String) A string that can be [parsed as a duration](https://pkg.go.dev/time#ParseDuration) consisting of numbers and unit suffixes, such as "30s" or "2h45m". Valid time units are "s" (seconds), "m" (minutes), "h" (hours).

## Import

Import is supported using the following syntax:
```shell
terraform import cloudavenue_s3_bucket_website_configuration.example bucket-name
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
data "cloudavenue_s3_bucket_website_configuration" "example" {
bucket = cloudavenue_s3_bucket.example.name
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
terraform import cloudavenue_s3_bucket_website_configuration.example bucket-name
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ go 1.20
require (
github.com/FrangipaneTeam/terraform-analytic-tool v0.0.12
github.com/FrangipaneTeam/terraform-plugin-framework-planmodifiers v1.3.4
github.com/FrangipaneTeam/terraform-plugin-framework-superschema v1.6.0
github.com/FrangipaneTeam/terraform-plugin-framework-superschema v1.6.1
github.com/FrangipaneTeam/terraform-plugin-framework-supertypes v0.2.0
github.com/FrangipaneTeam/terraform-plugin-framework-validators v1.8.1
github.com/antihax/optional v1.0.0
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ github.com/FrangipaneTeam/terraform-analytic-tool v0.0.12 h1:rbh0EtyILnuyu07RuOh
github.com/FrangipaneTeam/terraform-analytic-tool v0.0.12/go.mod h1:j3TxedNm9WrKKseOSBKxnNtquuXa0FQChO/QdcvPKtg=
github.com/FrangipaneTeam/terraform-plugin-framework-planmodifiers v1.3.4 h1:FGb+DIj8AtUehYLt7b0t1rjqK/7sggkoZwR4tqdQjcc=
github.com/FrangipaneTeam/terraform-plugin-framework-planmodifiers v1.3.4/go.mod h1:ngKE3iJWLWPLZ64umTr5ndnqd9mvMxHUZPk9pCkGSJY=
github.com/FrangipaneTeam/terraform-plugin-framework-superschema v1.6.0 h1:G2StO1BSiYMAVVynB6Vsy64rn+UZa0VpZwOvDk9IQ+g=
github.com/FrangipaneTeam/terraform-plugin-framework-superschema v1.6.0/go.mod h1:Rro2AUhgh2SHp3P8cu+pQinotCbkohb7MM4nZ15nP8M=
github.com/FrangipaneTeam/terraform-plugin-framework-superschema v1.6.1 h1:pg4u5vnX84idlUY390sp0Qy0WfRq5Es2ppxe9Bbit9c=
github.com/FrangipaneTeam/terraform-plugin-framework-superschema v1.6.1/go.mod h1:Rro2AUhgh2SHp3P8cu+pQinotCbkohb7MM4nZ15nP8M=
github.com/FrangipaneTeam/terraform-plugin-framework-supertypes v0.2.0 h1:lcJY8AEbpbYp/M/jPUdYZArsZKAkM2LECSYDfKOiIiQ=
github.com/FrangipaneTeam/terraform-plugin-framework-supertypes v0.2.0/go.mod h1:Aux7edspqsudNKr9YFgCkAgUwFj44RyOV123XolOzjY=
github.com/FrangipaneTeam/terraform-plugin-framework-validators v1.8.1 h1:C17IEM0/4sxsTN0IpwDdgncea/cxfZVlWESIWvlEuBo=
Expand Down
1 change: 1 addition & 0 deletions internal/provider/provider_datasources.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,5 +90,6 @@ func (p *cloudavenueProvider) DataSources(_ context.Context) []func() datasource
s3.NewBucketVersioningConfigurationDatasource,
s3.NewBucketCorsConfigurationDatasource,
s3.NewBucketLifecycleConfigurationDataSource,
s3.NewBucketWebsiteConfigurationDataSource,
}
}
1 change: 1 addition & 0 deletions internal/provider/provider_resources.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,5 +83,6 @@ func (p *cloudavenueProvider) Resources(_ context.Context) []func() resource.Res
s3.NewBucketResource,
s3.NewBucketCorsConfigurationResource,
s3.NewBucketLifecycleConfigurationResource,
s3.NewBucketWebsiteConfigurationResource,
}
}
9 changes: 9 additions & 0 deletions internal/provider/s3/base.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ const (
defaultUpdateTimeout = 5 * time.Minute
// defaultDeleteTimeout is the default timeout for delete operations.
defaultDeleteTimeout = 5 * time.Minute

// General timeout for S3 bucket changes to propagate.
// See https://docs.aws.amazon.com/AmazonS3/latest/userguide/Welcome.html#ConsistencyModel.
s3BucketPropagationTimeout = 2 * time.Minute // nosemgrep:ci.s3-in-const-name, ci.s3-in-var-name
)

// Error code constants missing from AWS Go SDK:
Expand Down Expand Up @@ -127,3 +131,8 @@ func retryWhenAWSErrCodeNotEquals[T any](ctx context.Context, codes []string, co
return !tfawserr.ErrCodeEquals(err, codes...)
})
}

// RetryWhenNotFound retries the specified function when it returns a retry.NotFoundError.
func retryWhenNotFound(ctx context.Context, timeout time.Duration, f func() (interface{}, error)) (interface{}, error) { //nolint: ireturn
return retryWhen(ctx, &RetryWhenConfig[interface{}]{Timeout: timeout, Function: f}, NotFound)
}
Loading

0 comments on commit 838957d

Please sign in to comment.