-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
118 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,3 +9,4 @@ test.txt | |
python.zip | ||
backend.tf | ||
.DS_Store | ||
.env |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,3 +13,4 @@ data "aws_subnets" "default_subnets" { | |
values = [data.aws_vpc.default.id] | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import sql from "k6/x/sql"; | ||
import { check } from "k6"; | ||
import { loadEnv } from "k6/x/dotenv"; | ||
import driver from "k6/x/sql/driver/postgres"; | ||
|
||
export const options = { | ||
vus: 10, // Number of Virtual Users | ||
duration: "30s", // Total test duration | ||
}; | ||
|
||
// Load environment variables | ||
const env = loadEnv(".env"); | ||
|
||
// Replace with your PostgreSQL connection string | ||
const db = sql.open( | ||
driver, | ||
`postgres://${env.DB_USER}:${env.DB_PASSWORD}@${env.DB_HOST}:${env.DB_PORT}/${env.DB_NAME}` | ||
); | ||
|
||
export function setup() { | ||
db.exec(`CREATE TABLE IF NOT EXISTS person ( | ||
id SERIAL PRIMARY KEY, | ||
email VARCHAR NOT NULL, | ||
first_name VARCHAR, | ||
last_name VARCHAR);`); | ||
|
||
db.exec( | ||
"INSERT INTO person (email, first_name, last_name) VALUES('[email protected]', 'John', 'Doe');" | ||
); | ||
db.exec( | ||
"INSERT INTO person (email, first_name, last_name) VALUES('[email protected]', 'Mary', 'Sue');" | ||
); | ||
db.exec( | ||
"INSERT INTO person (email, first_name, last_name) VALUES('[email protected]', 'Dory', 'Doe');" | ||
); | ||
} | ||
|
||
export function teardown() { | ||
db.exec("DELETE FROM person;"); | ||
db.exec("DROP TABLE person;"); | ||
db.close(); | ||
} | ||
|
||
export default function () { | ||
const results = sql.query(db, "SELECT * FROM person;"); | ||
check(results, { | ||
"is length 3": (r) => r.length === 3, | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
output "endpoint" { | ||
description = "RDS Endpoint" | ||
value = aws_rds_cluster.primary.endpoint | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# Security Group | ||
resource "aws_security_group" "rds_postgresql_sg" { | ||
name = "rds-postgresql-sg" | ||
description = "Security group for RDS PostgreSQL cluster" | ||
|
||
ingress { | ||
from_port = 5432 | ||
to_port = 5432 | ||
protocol = "tcp" | ||
cidr_blocks = ["0.0.0.0/0"] # Replace with your IP range or VPC CIDR | ||
} | ||
|
||
egress { | ||
from_port = 0 | ||
to_port = 0 | ||
protocol = "-1" | ||
cidr_blocks = ["0.0.0.0/0"] | ||
} | ||
|
||
tags = { | ||
Name = "rds-postgresql-sg" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,9 +2,17 @@ variable "db_type" { | |
default = "db.t3.medium" | ||
description = "Database Instance Type" | ||
} | ||
variable "db_name" { | ||
default = "test" | ||
description = "Default DB Name" | ||
} | ||
|
||
variable "publicly_accessible" { | ||
default = true | ||
description = "Access from public or not" | ||
} | ||
variable "availability_zones" { | ||
default = ["us-east-1a", "us-east-1b"] | ||
default = ["us-east-1a", "us-east-1b", "us-east-1c"] | ||
type = list(string) | ||
description = "RDS AZs" | ||
} | ||
|
@@ -23,3 +31,14 @@ variable "emails" { | |
description = "List notification emails" | ||
default = ["[email protected]"] | ||
} | ||
variable "skip_final_snapshot" { | ||
type = bool | ||
description = "Skip Final Snapshot or not" | ||
default = true | ||
} | ||
|
||
variable "ignore_changes_behavior" { | ||
type = list(any) | ||
default = [] | ||
} | ||
|