Skip to content

Commit 84ef43b

Browse files
codymaustSBGoods
andauthored
feat: remove archive_file resource deprecated status (hashicorp#367)
* 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: 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 * docs: notes for `archive_file` `resource` versus `data` source * docs: changie release notes for hashicorp#218 * docs: changie formatting Co-authored-by: Selena Goods <[email protected]> --------- Co-authored-by: Selena Goods <[email protected]>
1 parent b320c74 commit 84ef43b

File tree

10 files changed

+110
-11
lines changed

10 files changed

+110
-11
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
kind: FEATURES
2+
body: 'resource/archive_file: Remove `deprecated` status'
3+
time: 2024-09-12T14:01:36.373922-04:00
4+
custom:
5+
Issue: "218"

DESIGN.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
# Archive Provider Design
22

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

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

99
## Goals
1010

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

1414
General to development:
1515

docs/data-sources/file.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22
page_title: "archive_file Data Source - terraform-provider-archive"
33
subcategory: ""
44
description: |-
5-
Generates an archive from content, a file, or directory of files.
5+
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.
66
---
77

88
# archive_file (Data Source)
99

10-
Generates an archive from content, a file, or directory of files.
10+
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.
1111

1212
## Example Usage
1313

docs/resources/file.md

Lines changed: 43 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,56 @@
11
---
2-
# generated by https://github.com/hashicorp/terraform-plugin-docs
32
page_title: "archive_file Resource - terraform-provider-archive"
43
subcategory: ""
54
description: |-
6-
NOTE: This resource is deprecated, use data source instead.
5+
Generates an archive from content, a file, or directory of files.
76
---
87

98
# archive_file (Resource)
109

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

12+
## Example Usage
1313

14+
```terraform
15+
# Archive a single file.
16+
17+
resource "archive_file" "init" {
18+
type = "zip"
19+
source_file = "${path.module}/init.tpl"
20+
output_path = "${path.module}/files/init.zip"
21+
}
22+
```
23+
24+
```terraform
25+
# Archive multiple files and exclude file.
26+
27+
resource "archive_file" "dotfiles" {
28+
type = "zip"
29+
output_path = "${path.module}/files/dotfiles.zip"
30+
excludes = ["${path.module}/unwanted.zip"]
31+
32+
source {
33+
content = data.template_file.vimrc.rendered
34+
filename = ".vimrc"
35+
}
36+
37+
source {
38+
content = data.template_file.ssh_config.rendered
39+
filename = ".ssh/config"
40+
}
41+
}
42+
```
43+
44+
```terraform
45+
# Archive a file to be used with Lambda using consistent file mode
46+
47+
resource "archive_file" "lambda_my_function" {
48+
type = "zip"
49+
source_file = "${path.module}/../lambda/my-function/index.js"
50+
output_file_mode = "0666"
51+
output_path = "${path.module}/files/lambda-my-function.js.zip"
52+
}
53+
```
1454

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

examples/resources/file/lambda.tf

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Archive a file to be used with Lambda using consistent file mode
2+
3+
resource "archive_file" "lambda_my_function" {
4+
type = "zip"
5+
source_file = "${path.module}/../lambda/my-function/index.js"
6+
output_file_mode = "0666"
7+
output_path = "${path.module}/files/lambda-my-function.js.zip"
8+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Archive multiple files and exclude file.
2+
3+
resource "archive_file" "dotfiles" {
4+
type = "zip"
5+
output_path = "${path.module}/files/dotfiles.zip"
6+
excludes = ["${path.module}/unwanted.zip"]
7+
8+
source {
9+
content = data.template_file.vimrc.rendered
10+
filename = ".vimrc"
11+
}
12+
13+
source {
14+
content = data.template_file.ssh_config.rendered
15+
filename = ".ssh/config"
16+
}
17+
}

examples/resources/file/resource.tf

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Archive a single file.
2+
3+
resource "archive_file" "init" {
4+
type = "zip"
5+
source_file = "${path.module}/init.tpl"
6+
output_path = "${path.module}/files/init.zip"
7+
}

internal/provider/data_source_archive_file.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,10 @@ func (d *archiveFileDataSource) ConfigValidators(context.Context) []datasource.C
4646

4747
func (d *archiveFileDataSource) Schema(ctx context.Context, req datasource.SchemaRequest, resp *datasource.SchemaResponse) {
4848
resp.Schema = schema.Schema{
49-
Description: "Generates an archive from content, a file, or directory of files.",
49+
Description: "Generates an archive from content, a file, or directory of files. " +
50+
"The archive is built during the terraform plan, so you must persist the archive through to the terraform apply. " +
51+
"See the `archive_file` resource for an alternative if you cannot persist the file, " +
52+
"such as in a multi-phase CI or build server context.",
5053
Blocks: map[string]schema.Block{
5154
"source": schema.SetNestedBlock{
5255
Description: "Specifies attributes of a single source file to include into the archive. " +

internal/provider/resource_archive_file.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,7 @@ func (d *archiveFileResource) ConfigValidators(context.Context) []resource.Confi
4444

4545
func (d *archiveFileResource) Schema(ctx context.Context, req resource.SchemaRequest, resp *resource.SchemaResponse) {
4646
resp.Schema = schema.Schema{
47-
Description: `**NOTE**: This resource is deprecated, use data source instead.`,
48-
DeprecationMessage: `**NOTE**: This resource is deprecated, use data source instead.`,
47+
Description: "Generates an archive from content, a file, or directory of files.",
4948
Blocks: map[string]schema.Block{
5049
"source": schema.SetNestedBlock{
5150
Description: "Specifies attributes of a single source file to include into the archive. " +

templates/resources/file.md.tmpl

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
---
2+
page_title: "{{.Name}} {{.Type}} - {{.ProviderName}}"
3+
subcategory: ""
4+
description: |-
5+
{{ .Description | plainmarkdown | trimspace | prefixlines " " }}
6+
---
7+
8+
# {{.Name}} ({{.Type}})
9+
10+
{{ .Description | trimspace }}
11+
12+
## Example Usage
13+
14+
{{ tffile "examples/resources/file/resource.tf" }}
15+
16+
{{ tffile "examples/resources/file/multiple-files.tf" }}
17+
18+
{{ tffile "examples/resources/file/lambda.tf" }}
19+
20+
{{ .SchemaMarkdown | trimspace }}

0 commit comments

Comments
 (0)