Skip to content

Commit

Permalink
#17 add ssm parameter to store list of users
Browse files Browse the repository at this point in the history
  • Loading branch information
kunduso committed Sep 20, 2024
1 parent 1e83d81 commit 272a767
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 0 deletions.
Empty file added create_user_lambda.tf
Empty file.
15 changes: 15 additions & 0 deletions create_user_ssm_parameter.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@

# Read the JSON file
#https://registry.terraform.io/providers/hashicorp/local/latest/docs/data-sources/file
data "local_file" "user_list" {
filename = "${path.module}/user_list.json"
}

# Create SSM Parameter
#https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/ssm_parameter
resource "aws_ssm_parameter" "user_list" {
name = "/${var.name}/db_user_list" # Replace with your desired parameter name
description = "User and database mappings for Amazon RDS for PostgreSQL DB users."
type = "String"
value = data.local_file.user_list.content
}
7 changes: 7 additions & 0 deletions provider.tf
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ terraform {
source = "hashicorp/aws"
version = "5.63.1"
}
local = {
source = "hashicorp/local"
version = "2.5.2"
}
}
}

Expand All @@ -16,4 +20,7 @@ provider "aws" {
Source = "https://github.com/kunduso/rds-secretsmanager-rotation-lambda-terraform"
}
}
}
provider "local" {
# Configuration options
}
19 changes: 19 additions & 0 deletions user_list.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"user_database_mappings": [
{
"username": "user1"
},
{
"username": "user2",
"database": "postgres"
},
{
"username": "user3",
"database": "db1"
},
{
"username": "user4",
"database": "db3"
}
]
}

0 comments on commit 272a767

Please sign in to comment.