Browse Source

fix/ terraform precompute issue

tags/2.0.0^2
Quentin Vallin 7 months ago
parent
commit
2af87c6ac0
Signed by: quentin.vallin <quentin.vallin@fxinnovation.com> GPG Key ID: 96D1C2CDC50558C3
14 changed files with 65 additions and 9 deletions
  1. +1
    -1
      .pre-commit-config.yaml
  2. +4
    -0
      CHANGELOG.md
  3. +8
    -1
      README.md
  4. +8
    -1
      examples/disable/README.md
  5. +8
    -1
      examples/external_kms_no_policy/README.md
  6. +1
    -0
      examples/external_kms_no_policy/main.tf
  7. +8
    -1
      examples/no_kms/README.md
  8. +1
    -0
      examples/no_kms/main.tf
  9. +8
    -1
      examples/overwrite/README.md
  10. +1
    -0
      examples/overwrite/main.tf
  11. +8
    -1
      examples/standard/README.md
  12. +1
    -0
      examples/standard/main.tf
  13. +2
    -2
      main.tf
  14. +6
    -0
      variables.tf

+ 1
- 1
.pre-commit-config.yaml View File

@@ -1,6 +1,6 @@
repos:
- repo: git://github.com/antonbabenko/pre-commit-terraform
rev: v1.27.0
rev: v1.29.0
hooks:
- id: terraform_fmt
- id: terraform_docs


+ 4
- 0
CHANGELOG.md View File

@@ -1,5 +1,9 @@
# CHANGELOG

## 2.0.0

* fix: Add `parameters_count` variable. You must update you module with this variable, otherwise, no SSM paramters will be created. This fix a terraform 0.12 pre-processor issue.

## 1.1.0

* feat: allow default KMS key


+ 8
- 1
README.md View File

@@ -8,6 +8,12 @@ Very important:
It's not possible to convert `SecureString` into a `String`/`StringList` a value. To do so, SSM parameter resource must be taint/destroy first.

<!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
## Requirements

| Name | Version |
|------|---------|
| terraform | >= 0.12 |

## Providers

| Name | Version |
@@ -17,7 +23,7 @@ It's not possible to convert `SecureString` into a `String`/`StringList` a value
## Inputs

| Name | Description | Type | Default | Required |
|------|-------------|------|---------|:-----:|
|------|-------------|------|---------|:--------:|
| allowed\_patterns | List of regular expression used to validate the parameter value. | `list` | `[]` | no |
| descriptions | List of descriptions for parameters. | `list` | `[]` | no |
| enabled | Enable this module | `bool` | `true` | no |
@@ -33,6 +39,7 @@ It's not possible to convert `SecureString` into a `String`/`StringList` a value
| kms\_tags | Tags that will be merged with variable tags for the kms key | `map` | `{}` | no |
| names | List of names for parameters. | `list(string)` | n/a | yes |
| overwrite | Overwrite an existing parameter | `bool` | `false` | no |
| parameters\_count | Number of parameters. This value cannot be automaticly computed in terraform 0.12.x. | `number` | `0` | no |
| prefix | The prefix to be used for every SSM Parameters. The prefix must match [A-Za-z0-9/] | `string` | n/a | yes |
| tags | Global tags for resources | `map` | `{}` | no |
| types | List of types for parameters. | `list(string)` | n/a | yes |


+ 8
- 1
examples/disable/README.md View File

@@ -13,6 +13,13 @@ $ terraform apply
```

<!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
## Requirements

| Name | Version |
|------|---------|
| terraform | >= 0.12 |
| aws | ~> 2 |

## Providers

No provider.
@@ -20,7 +27,7 @@ No provider.
## Inputs

| Name | Description | Type | Default | Required |
|------|-------------|------|---------|:-----:|
|------|-------------|------|---------|:--------:|
| access\_key | Credentials: AWS access key. | `string` | n/a | yes |
| secret\_key | Credentials: AWS secret key. Pass this as a variable, never write password in the code. | `string` | n/a | yes |



+ 8
- 1
examples/external_kms_no_policy/README.md View File

@@ -13,6 +13,13 @@ $ terraform apply
```

<!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
## Requirements

| Name | Version |
|------|---------|
| terraform | >= 0.12 |
| aws | ~> 2 |

## Providers

| Name | Version |
@@ -23,7 +30,7 @@ $ terraform apply
## Inputs

| Name | Description | Type | Default | Required |
|------|-------------|------|---------|:-----:|
|------|-------------|------|---------|:--------:|
| access\_key | Credentials: AWS access key. | `string` | n/a | yes |
| secret\_key | Credentials: AWS secret key. Pass this as a variable, never write password in the code. | `string` | n/a | yes |



+ 1
- 0
examples/external_kms_no_policy/main.tf View File

@@ -28,6 +28,7 @@ module "external_kms_no_policy" {
source = "../../"

prefix = "tftestSsmParam${random_string.this.result}"
parameters_count = 3
names = ["/foo", "/bar", "/baz"]
types = ["String", "SecureString", "StringList"]
values = ["foo was here", "bar was here", "baz was here"]


+ 8
- 1
examples/no_kms/README.md View File

@@ -13,6 +13,13 @@ $ terraform apply
```

<!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
## Requirements

| Name | Version |
|------|---------|
| terraform | >= 0.12 |
| aws | ~> 2 |

## Providers

| Name | Version |
@@ -22,7 +29,7 @@ $ terraform apply
## Inputs

| Name | Description | Type | Default | Required |
|------|-------------|------|---------|:-----:|
|------|-------------|------|---------|:--------:|
| access\_key | Credentials: AWS access key. | `string` | n/a | yes |
| secret\_key | Credentials: AWS secret key. Pass this as a variable, never write password in the code. | `string` | n/a | yes |



+ 1
- 0
examples/no_kms/main.tf View File

@@ -15,6 +15,7 @@ module "no_kms" {
source = "../../"

prefix = "tftestSsmParam/${random_string.this.result}"
parameters_count = 2
names = ["/foo", "/bar"]
types = ["String", "SecureString"]
values = ["foo was here", "bar was here"]


+ 8
- 1
examples/overwrite/README.md View File

@@ -13,6 +13,13 @@ $ terraform apply
```

<!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
## Requirements

| Name | Version |
|------|---------|
| terraform | >= 0.12 |
| aws | ~> 2 |

## Providers

| Name | Version |
@@ -22,7 +29,7 @@ $ terraform apply
## Inputs

| Name | Description | Type | Default | Required |
|------|-------------|------|---------|:-----:|
|------|-------------|------|---------|:--------:|
| access\_key | Credentials: AWS access key. | `string` | n/a | yes |
| secret\_key | Credentials: AWS secret key. Pass this as a variable, never write password in the code. | `string` | n/a | yes |



+ 1
- 0
examples/overwrite/main.tf View File

@@ -15,6 +15,7 @@ module "overwrite" {
source = "../../"

prefix = "tftestSsmParam/${random_string.this.result}"
parameters_count = 3
names = ["/foo", "/bar", "/baz"]
types = ["String", "SecureString", "StringList"]
values = ["foo was here", "bar war here", "baz was here"]


+ 8
- 1
examples/standard/README.md View File

@@ -13,6 +13,13 @@ $ terraform apply
```

<!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
## Requirements

| Name | Version |
|------|---------|
| terraform | >= 0.12 |
| aws | ~> 2 |

## Providers

| Name | Version |
@@ -22,7 +29,7 @@ $ terraform apply
## Inputs

| Name | Description | Type | Default | Required |
|------|-------------|------|---------|:-----:|
|------|-------------|------|---------|:--------:|
| access\_key | Credentials: AWS access key. | `string` | n/a | yes |
| secret\_key | Credentials: AWS secret key. Pass this as a variable, never write password in the code. | `string` | n/a | yes |



+ 1
- 0
examples/standard/main.tf View File

@@ -15,6 +15,7 @@ module "standard" {
source = "../../"

prefix = "tftestSsmParam/${random_string.this.result}"
parameters_count = 3
names = ["/foo", "/bar", "/baz"]
types = ["String", "SecureString", "StringList"]
values = ["foo was here", "bar war here", "baz was here"]


+ 2
- 2
main.tf View File

@@ -3,7 +3,7 @@
####

resource "aws_ssm_parameter" "overwrite" {
count = var.enabled && var.overwrite ? length(var.names) : 0
count = var.enabled && var.overwrite ? var.parameters_count : 0

name = "/${var.prefix}${element(var.names, count.index)}"
description = element(concat(var.descriptions, [""]), count.index)
@@ -23,7 +23,7 @@ resource "aws_ssm_parameter" "overwrite" {
}

resource "aws_ssm_parameter" "no_overwrite" {
count = var.enabled && false == var.overwrite ? length(var.names) : 0
count = var.enabled && false == var.overwrite ? var.parameters_count : 0

name = "/${var.prefix}${element(var.names, count.index)}"
description = element(concat(var.descriptions, [""]), count.index)


+ 6
- 0
variables.tf View File

@@ -21,6 +21,12 @@ variable "prefix" {
type = string
}

variable "parameters_count" {
description = "Number of parameters. This value cannot be automaticly computed in terraform 0.12.x."
type = number
default = 0
}

variable "names" {
description = "List of names for parameters."
type = list(string)


Loading…
Cancel
Save