Skip to content

Commit

Permalink
Upgrade AWS provide version to 5+, remove overwrite option (potential…
Browse files Browse the repository at this point in the history
…ly breaking change), add variable descriptions, update README.md
  • Loading branch information
AutomationD committed Sep 25, 2024
1 parent 18ea0ee commit 548d01e
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 19 deletions.
21 changes: 12 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
# Terraform AWS Serverless App Module
Terraform module to create AWS Serverless application.


## How to use:
```terraform
```hcl
module "pecan" {
name = "pecan"
source = "hazelops/sls-app/aws"
env = var.env
vpc_id = module.vpc.vpc_id
public_subnets = module.vpc.public_subnets
private_subnets = module.vpc.private_subnets
security_groups = [aws_security_group.default_permissive.id]
security_groups = ["sg-xxxxxxxxxxxxxxxxx"]
parameters = {
"API_KEY": "demo"
Expand All @@ -26,18 +25,19 @@ module "pecan" {
}
```


<!-- BEGIN_TF_DOCS -->
## Requirements

| Name | Version |
|------|---------|
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.0 |
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | ~> 5.0 |

## Providers

| Name | Version |
|------|---------|
| <a name="provider_aws"></a> [aws](#provider\_aws) | n/a |
| <a name="provider_aws"></a> [aws](#provider\_aws) | ~> 5.0 |

## Modules

Expand All @@ -59,15 +59,18 @@ module "pecan" {
|------|-------------|------|---------|:--------:|
| <a name="input_app_secrets"></a> [app\_secrets](#input\_app\_secrets) | List of SSM ParameterStore secret parameters - by default, /$var.env/$var.name/* | `list(any)` | `[]` | no |
| <a name="input_env"></a> [env](#input\_env) | n/a | `any` | n/a | yes |
| <a name="input_global_parameters"></a> [global\_parameters](#input\_global\_parameters) | n/a | `map(string)` | `{}` | no |
| <a name="input_global_parameters"></a> [global\_parameters](#input\_global\_parameters) | Map of SSM ParameterStore global parameters to store - by default, /$var.env/global/* | `map(string)` | `{}` | no |
| <a name="input_global_secrets"></a> [global\_secrets](#input\_global\_secrets) | List of SSM ParameterStore global secrets - by default, /$var.env/global/* | `list(any)` | `[]` | no |
| <a name="input_join_lists"></a> [join\_lists](#input\_join\_lists) | Whether to join lists like subnets and security groups into a one SSM parameter string with comma separator | `bool` | `false` | no |
| <a name="input_name"></a> [name](#input\_name) | n/a | `any` | n/a | yes |
| <a name="input_parameters"></a> [parameters](#input\_parameters) | n/a | `map(string)` | n/a | yes |
| <a name="input_parameters"></a> [parameters](#input\_parameters) | Map of SSM ParameterStore parameters to store - by default, /$var.env/$var.name/* | `map(string)` | n/a | yes |
| <a name="input_private_subnets"></a> [private\_subnets](#input\_private\_subnets) | VPC Private subnets to place SLS resources | `list(any)` | `[]` | no |
| <a name="input_public_subnets"></a> [public\_subnets](#input\_public\_subnets) | VPC Public subnets to place SLS resources | `list(any)` | `[]` | no |
| <a name="input_security_groups"></a> [security\_groups](#input\_security\_groups) | Security groups to assign to SLS | `list(any)` | `[]` | no |
| <a name="input_vpc_id"></a> [vpc\_id](#input\_vpc\_id) | AWS VPC ID | `string` | `""` | no |
| <a name="input_serialize_lists"></a> [serialize\_lists](#input\_serialize\_lists) | Whether to serialize lists like subnets and security groups into a one SSM parameter | `bool` | `true` | no |
| <a name="input_vpc_id"></a> [vpc\_id](#input\_vpc\_id) | AWS VPC ID | `string` | `"-"` | no |

## Outputs

No outputs.
No outputs.
<!-- END_TF_DOCS -->
10 changes: 4 additions & 6 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,17 @@ resource "aws_ssm_parameter" "sls_parameter" {

name = "/${var.env}/${var.name}/${each.key}"

value = each.value
type = "String"
overwrite = true
value = each.value
type = "String"
}

resource "aws_ssm_parameter" "sls_global_parameter" {
for_each = var.global_parameters

name = "/${var.env}/global/${each.key}"

value = each.value
type = "String"
overwrite = true
value = each.value
type = "String"
}

module "secrets" {
Expand Down
8 changes: 5 additions & 3 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@ variable "name" {}
variable "env" {}

variable "parameters" {
type = map(string)
type = map(string)
description = "Map of SSM ParameterStore parameters to store - by default, /$var.env/$var.name/*"
}

variable "global_parameters" {
type = map(string)
default = {}
type = map(string)
description = "Map of SSM ParameterStore global parameters to store - by default, /$var.env/global/*"
default = {}
}

variable "app_secrets" {
Expand Down
3 changes: 2 additions & 1 deletion versions.tf
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
terraform {
required_providers {
aws = {
source = "hashicorp/aws"
source = "hashicorp/aws"
version = "~> 5.0"
}
}
required_version = ">= 1.0"
Expand Down

0 comments on commit 548d01e

Please sign in to comment.