Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: remove archive_file resource deprecated status #367

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 }}