Skip to content

Commit dd05dc3

Browse files
committed
feat(outputs): add local file
Signed-off-by: Frederic Leger <frederic@webofmars.com>
1 parent bac9a13 commit dd05dc3

7 files changed

Lines changed: 110 additions & 0 deletions

File tree

outputs/local-file/.tflint.hcl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
plugin "terraform" {
2+
enabled = true
3+
preset = "recommended"
4+
}

outputs/local-file/README.md

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# local-file module
2+
3+
A terraform module to create local files.
4+
Please, keep in mind that the file content will be persisted in the terraform state.
5+
So it's not intended to pass sensitive file content.
6+
7+
<!-- BEGIN_TF_DOCS -->
8+
## Requirements
9+
10+
| Name | Version |
11+
|------|---------|
12+
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | ~> 1.3 |
13+
| <a name="requirement_local"></a> [local](#requirement\_local) | >= 2.2.3, < 3.0.0 |
14+
| <a name="requirement_time"></a> [time](#requirement\_time) | ~> 0.9.1 |
15+
16+
## Providers
17+
18+
| Name | Version |
19+
|------|---------|
20+
| <a name="provider_local"></a> [local](#provider\_local) | >= 2.2.3, < 3.0.0 |
21+
| <a name="provider_time"></a> [time](#provider\_time) | ~> 0.9.1 |
22+
23+
## Modules
24+
25+
No modules.
26+
27+
## Resources
28+
29+
| Name | Type |
30+
|------|------|
31+
| [local_file.main](https://registry.terraform.io/providers/hashicorp/local/latest/docs/resources/file) | resource |
32+
| [time_static.last_update](https://registry.terraform.io/providers/hashicorp/time/latest/docs/resources/static) | resource |
33+
34+
## Inputs
35+
36+
| Name | Description | Type | Default | Required |
37+
|------|-------------|------|---------|:--------:|
38+
| <a name="input_content"></a> [content](#input\_content) | content to be written in the local file | `string` | n/a | yes |
39+
| <a name="input_customer"></a> [customer](#input\_customer) | Customer for the current deployment | `string` | `""` | no |
40+
| <a name="input_filename"></a> [filename](#input\_filename) | full filepath to be used | `string` | n/a | yes |
41+
| <a name="input_name"></a> [name](#input\_name) | The name of the template resource | `string` | `"my-template"` | no |
42+
| <a name="input_tags"></a> [tags](#input\_tags) | Default tags to add to resources | `map(any)` | `{}` | no |
43+
44+
## Outputs
45+
46+
No outputs.
47+
<!-- END_TF_DOCS -->

outputs/local-file/local-file.tf

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
resource "local_file" "main" {
2+
content = var.content
3+
filename = var.filename
4+
}

outputs/local-file/main.tf

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
locals {
2+
# tflint-ignore: terraform_unused_declarations
3+
interpolated_tags = merge({
4+
"Name" = var.name,
5+
"Customer" = var.customer,
6+
"ManagedBy" = "Terraform",
7+
"LastModifiedAt" = time_static.last_update.rfc3339,
8+
},
9+
var.tags
10+
)
11+
}
12+
13+
resource "time_static" "last_update" {
14+
}

outputs/local-file/outputs.tf

Whitespace-only changes.

outputs/local-file/providers.tf

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
terraform {
2+
required_version = "~> 1.3"
3+
required_providers {
4+
local = {
5+
source = "hashicorp/local",
6+
version = ">= 2.2.3, < 3.0.0"
7+
}
8+
time = {
9+
source = "hashicorp/time",
10+
version = "~> 0.9.1"
11+
}
12+
}
13+
}

outputs/local-file/variables.tf

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
variable "name" {
2+
description = "The name of the template resource"
3+
type = string
4+
default = "my-template"
5+
}
6+
7+
variable "customer" {
8+
description = "Customer for the current deployment"
9+
type = string
10+
default = ""
11+
}
12+
13+
variable "tags" {
14+
description = "Default tags to add to resources"
15+
type = map(any)
16+
default = {}
17+
}
18+
19+
# module specific variables
20+
variable "filename" {
21+
type = string
22+
description = "full filepath to be used"
23+
}
24+
25+
variable "content" {
26+
type = string
27+
description = "content to be written in the local file"
28+
}

0 commit comments

Comments
 (0)