Skip to content

Commit 94fd8c0

Browse files
authored
feat: Initial release. (#1)
1 parent c527704 commit 94fd8c0

File tree

5 files changed

+53
-35
lines changed

5 files changed

+53
-35
lines changed

README.md

Lines changed: 24 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,27 @@
1-
# Code for America OpenTofu Module Template
1+
# AWS SSM Inputs Module
22

33
[![Main Checks][badge-checks]][code-checks] [![GitHub Release][badge-release]][latest-release]
44

5-
Use this template repository to create new OpenTofu modules. Follow the steps
6-
below to use this repository:
7-
8-
1. Click the "Use this template" button to create a new repository
9-
1. Name your new repository using the format `todu-modules-<provider>-<module>`
10-
1. Add the files necessary to support your module to the root of your new
11-
repository
12-
1. Update the `README.md` file with the appropriate information for your module.
13-
Make sure you update any references to this template repository with your new
14-
repository
15-
1. Update the [codeforamerica/tofu-modules][tofu-modules] repository to include
16-
your new module in the main `README.md` and the documentation
5+
This module provides an interface for retrieving input parameters from AWS
6+
Systems Manager (SSM) Parameter Store. Along with the [aws_ssm_outputs] module,
7+
it allows you to easily manage and access configuration parameters stored in
8+
SSM.
179

1810
## Usage
1911

12+
> [!WARNING]
13+
> The values looked up by this module are assumed to be insecure. Care should be
14+
> used when using the values retrieved by this module in secure contexts.
15+
2016
Add this module to your `main.tf` (or appropriate) file and configure the inputs
2117
to match your desired configuration. For example:
2218

23-
[//]: # (TODO: Update to match your module's name and inputs)
24-
2519
```hcl
2620
module "module_name" {
27-
source = "github.com/codeforamerica/tofu-modules-template?ref=1.0.0"
21+
source = "github.com/codeforamerica/tofu-modules-aws-ssm-inputs?ref=1.0.0"
2822
29-
project = "my-project"
30-
environment = "development"
23+
prefix = "/my-project/environment"
24+
inputs = ["logging/key", "vpc/id", "vpc/private-subnets"]
3125
}
3226
```
3327

@@ -46,31 +40,26 @@ tofu init -upgrade
4640

4741
## Inputs
4842

49-
[//]: # (TODO: Replace the following with your own inputs)
50-
51-
| Name | Description | Type | Default | Required |
52-
|-------------|-----------------------------------------------|----------|---------|----------|
53-
| project | Name of the project. | `string` | n/a | yes |
54-
| environment | Environment for the project. | `string` | `"dev"` | no |
55-
| tags | Optional tags to be applied to all resources. | `list` | `[]` | no |
43+
| Name | Description | Type | Default | Required |
44+
|--------|---------------------------------------------------------------------|----------|---------|----------|
45+
| inputs | List of parameters to be read. | `list` | `"dev"` | yes |
46+
| prefix | Prefix for all parameters. Should start with a forward slash (`/`). | `string` | `null` | no |
5647

5748
## Outputs
5849

59-
[//]: # (TODO: Replace the following with your own outputs)
60-
61-
| Name | Description | Type |
62-
|----------|-----------------------------------|----------|
63-
| id | Id of the newly created resource. | `string` |
50+
| Name | Description | Type |
51+
|--------|-----------------------------------------------|-------|
52+
| values | Map of retrieved parameters and their values. | `map` |
6453

6554

6655
## Contributing
6756

6857
Follow the [contributing guidelines][contributing] to contribute to this
6958
repository.
7059

71-
[badge-checks]: https://github.com/codeforamerica/tofu-modules-template/actions/workflows/main.yaml/badge.svg
72-
[badge-release]: https://img.shields.io/github/v/release/codeforamerica/tofu-modules-template?logo=github&label=Latest%20Release
73-
[code-checks]: https://github.com/codeforamerica/tofu-modules-template/actions/workflows/main.yaml
60+
[aws_ssm_outputs]: https://github.com/codeforamerica/tofu-modules-aws-ssm-outputs
61+
[badge-checks]: https://github.com/codeforamerica/tofu-modules-aws-ssm-inputs/actions/workflows/main.yaml/badge.svg
62+
[badge-release]: https://img.shields.io/github/v/release/codeforamerica/tofu-modules-aws-ssm-inputs?logo=github&label=Latest%20Release
63+
[code-checks]: https://github.com/codeforamerica/tofu-modules-aws-ssm-inputs/actions/workflows/main.yaml
7464
[contributing]: CONTRIBUTING.md
75-
[latest-release]: https://github.com/codeforamerica/tofu-modules-template/releases/latest
76-
[tofu-modules]: https://github.com/codeforamerica/tofu-modules
65+
[latest-release]: https://github.com/codeforamerica/tofu-modules-aws-ssm-inputs/releases/latest

main.tf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
data "aws_ssm_parameter" "this" {
2+
for_each = toset(var.inputs)
3+
4+
name = join("/", compact([var.prefix, each.value]))
5+
}

outputs.tf

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
output "values" {
2+
description = "Map of input names to their values."
3+
value = { for k, v in data.aws_ssm_parameter.this : k => v.insecure_value }
4+
}

variables.tf

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
variable "inputs" {
2+
type = list(string)
3+
description = "Inputs to be read from SSM Parameter Store."
4+
}
5+
6+
variable "prefix" {
7+
type = string
8+
description = "Prefix to prepend to all input names."
9+
default = null
10+
}

versions.tf

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
terraform {
2+
required_version = ">= 1.9"
3+
4+
required_providers {
5+
aws = {
6+
source = "hashicorp/aws"
7+
version = "~> 6.0"
8+
}
9+
}
10+
}

0 commit comments

Comments
 (0)