Skip to content

Commit

Permalink
feat: remove archive_file resource deprecated status (#367)
Browse files Browse the repository at this point in the history
* feat: remove `archive_file` resource deprecation notice

- from what i gathered from the git history, this resource was
introduced in `v2.3.0` in a deprecated state

- discussion with the community involving @bendbennett resulted in the
consideration of this deprecation being removed (see: #218)

- since `v2.x` there has been a strong focus on keeping this provider
limited to the `data` source, so some of this proposed change is taking
a best guess at what makes sense while trying not to depart from the
overall approach

- i acknowledge that this appears to be in some ways orthogonal to the
goal of the project, but there has been little movement in regards to
this widely-requested feature (understandably so, based on reasons
mentioned above).

- there are cases, primarily in a remote build server context, where the
design decisions/limitations of the `data` source makes the adoption and
usage of this provider much more challenging.

this change is proposed as a stop-gap until a larger focus is able to
put on this project by the primary contributing team

* docs: notes for `archive_file` `resource` versus `data` source

* docs: changie release notes for #218

* docs: changie formatting

Co-authored-by: Selena Goods <[email protected]>

---------

Co-authored-by: Selena Goods <[email protected]>
  • Loading branch information
codymaust and SBGoods authored Nov 19, 2024
1 parent b320c74 commit 84ef43b
Show file tree
Hide file tree
Showing 10 changed files with 110 additions and 11 deletions.
5 changes: 5 additions & 0 deletions .changes/unreleased/FEATURES-20240912-140136.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
kind: FEATURES
body: 'resource/archive_file: Remove `deprecated` status'
time: 2024-09-12T14:01:36.373922-04:00
custom:
Issue: "218"
6 changes: 3 additions & 3 deletions DESIGN.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
# Archive Provider Design

The Archive Provider offers focussed functionality specifically geared towards archiving files. Specifically,
the provider data source generates zip archives of individual or multiple files.
The Archive Provider offers focussed functionality specifically geared towards archiving files. The provider generates
zip archives of individual or multiple files.

Below we have a collection of _Goals_ and _Patterns_: they represent the guiding principles applied during the
development of this provider. Some are in place, others are ongoing processes, others are still just inspirational.

## Goals

* [_Stability over features_](.github/CONTRIBUTING.md)
* Provide data source for generating zip archives.
* Provide a mechanism for generating zip archives.

General to development:

Expand Down
4 changes: 2 additions & 2 deletions docs/data-sources/file.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
page_title: "archive_file Data Source - terraform-provider-archive"
subcategory: ""
description: |-
Generates an archive from content, a file, or directory of files.
Generates an archive from content, a file, or directory of files. The archive is built during the terraform plan, so you must persist the archive through to the terraform apply. See the archive_file resource for an alternative if you cannot persist the file, such as in a multi-phase CI or build server context.
---

# archive_file (Data Source)

Generates an archive from content, a file, or directory of files.
Generates an archive from content, a file, or directory of files. The archive is built during the terraform plan, so you must persist the archive through to the terraform apply. See the `archive_file` resource for an alternative if you cannot persist the file, such as in a multi-phase CI or build server context.

## Example Usage

Expand Down
46 changes: 43 additions & 3 deletions docs/resources/file.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,56 @@
---
# generated by https://github.com/hashicorp/terraform-plugin-docs
page_title: "archive_file Resource - terraform-provider-archive"
subcategory: ""
description: |-
NOTE: This resource is deprecated, use data source instead.
Generates an archive from content, a file, or directory of files.
---

# archive_file (Resource)

**NOTE**: This resource is deprecated, use data source instead.
Generates an archive from content, a file, or directory of files.

## Example Usage

```terraform
# Archive a single file.
resource "archive_file" "init" {
type = "zip"
source_file = "${path.module}/init.tpl"
output_path = "${path.module}/files/init.zip"
}
```

```terraform
# Archive multiple files and exclude file.
resource "archive_file" "dotfiles" {
type = "zip"
output_path = "${path.module}/files/dotfiles.zip"
excludes = ["${path.module}/unwanted.zip"]
source {
content = data.template_file.vimrc.rendered
filename = ".vimrc"
}
source {
content = data.template_file.ssh_config.rendered
filename = ".ssh/config"
}
}
```

```terraform
# Archive a file to be used with Lambda using consistent file mode
resource "archive_file" "lambda_my_function" {
type = "zip"
source_file = "${path.module}/../lambda/my-function/index.js"
output_file_mode = "0666"
output_path = "${path.module}/files/lambda-my-function.js.zip"
}
```

<!-- schema generated by tfplugindocs -->
## Schema
Expand Down
8 changes: 8 additions & 0 deletions examples/resources/file/lambda.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Archive a file to be used with Lambda using consistent file mode

resource "archive_file" "lambda_my_function" {
type = "zip"
source_file = "${path.module}/../lambda/my-function/index.js"
output_file_mode = "0666"
output_path = "${path.module}/files/lambda-my-function.js.zip"
}
17 changes: 17 additions & 0 deletions examples/resources/file/multiple-files.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Archive multiple files and exclude file.

resource "archive_file" "dotfiles" {
type = "zip"
output_path = "${path.module}/files/dotfiles.zip"
excludes = ["${path.module}/unwanted.zip"]

source {
content = data.template_file.vimrc.rendered
filename = ".vimrc"
}

source {
content = data.template_file.ssh_config.rendered
filename = ".ssh/config"
}
}
7 changes: 7 additions & 0 deletions examples/resources/file/resource.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Archive a single file.

resource "archive_file" "init" {
type = "zip"
source_file = "${path.module}/init.tpl"
output_path = "${path.module}/files/init.zip"
}
5 changes: 4 additions & 1 deletion internal/provider/data_source_archive_file.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,10 @@ func (d *archiveFileDataSource) ConfigValidators(context.Context) []datasource.C

func (d *archiveFileDataSource) Schema(ctx context.Context, req datasource.SchemaRequest, resp *datasource.SchemaResponse) {
resp.Schema = schema.Schema{
Description: "Generates an archive from content, a file, or directory of files.",
Description: "Generates an archive from content, a file, or directory of files. " +
"The archive is built during the terraform plan, so you must persist the archive through to the terraform apply. " +
"See the `archive_file` resource for an alternative if you cannot persist the file, " +
"such as in a multi-phase CI or build server context.",
Blocks: map[string]schema.Block{
"source": schema.SetNestedBlock{
Description: "Specifies attributes of a single source file to include into the archive. " +
Expand Down
3 changes: 1 addition & 2 deletions internal/provider/resource_archive_file.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,7 @@ func (d *archiveFileResource) ConfigValidators(context.Context) []resource.Confi

func (d *archiveFileResource) Schema(ctx context.Context, req resource.SchemaRequest, resp *resource.SchemaResponse) {
resp.Schema = schema.Schema{
Description: `**NOTE**: This resource is deprecated, use data source instead.`,
DeprecationMessage: `**NOTE**: This resource is deprecated, use data source instead.`,
Description: "Generates an archive from content, a file, or directory of files.",
Blocks: map[string]schema.Block{
"source": schema.SetNestedBlock{
Description: "Specifies attributes of a single source file to include into the archive. " +
Expand Down
20 changes: 20 additions & 0 deletions templates/resources/file.md.tmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
page_title: "{{.Name}} {{.Type}} - {{.ProviderName}}"
subcategory: ""
description: |-
{{ .Description | plainmarkdown | trimspace | prefixlines " " }}
---

# {{.Name}} ({{.Type}})

{{ .Description | trimspace }}

## Example Usage

{{ tffile "examples/resources/file/resource.tf" }}

{{ tffile "examples/resources/file/multiple-files.tf" }}

{{ tffile "examples/resources/file/lambda.tf" }}

{{ .SchemaMarkdown | trimspace }}

0 comments on commit 84ef43b

Please sign in to comment.