Skip to content

Commit

Permalink
feat: remove archive_file resource deprecation notice
Browse files Browse the repository at this point in the history
- 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: hashicorp#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
  • Loading branch information
codymaust committed Nov 19, 2024
1 parent b320c74 commit a372159
Show file tree
Hide file tree
Showing 7 changed files with 99 additions and 8 deletions.
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
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"
}
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 a372159

Please sign in to comment.