Skip to content

Commit

Permalink
create terraform rds
Browse files Browse the repository at this point in the history
  • Loading branch information
Doris-Siu committed Mar 3, 2024
1 parent 16083f4 commit 9a14ecb
Show file tree
Hide file tree
Showing 4 changed files with 128 additions and 0 deletions.
34 changes: 34 additions & 0 deletions terraform-rds/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Local .terraform directories
**/.terraform/*

# .tfstate files
*.tfstate
*.tfstate.*

# Crash log files
crash.log
crash.*.log

# Exclude all .tfvars files, which are likely to contain sensitive data, such as
# password, private keys, and other secrets. These should not be part of version
# control as they are data points which are potentially sensitive and subject
# to change depending on the environment.
*.tfvars
*.tfvars.json

# Ignore override files as they are usually used to override resources locally and so
# are not checked in
override.tf
override.tf.json
*_override.tf
*_override.tf.json

# Include override files you do wish to add to version control using negated pattern
# !example_override.tf

# Include tfplan files to ignore the plan output of command: terraform plan -out=tfplan
# example: *tfplan*

# Ignore CLI configuration files
.terraformrc
terraform.rc
44 changes: 44 additions & 0 deletions terraform-rds/.terraform.lock.hcl

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

29 changes: 29 additions & 0 deletions terraform-rds/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
terraform {
required_providers {
aws = {
source = "hashicorp/aws"
version = "~> 5.0"
}
}
}

provider "aws" {
region = "eu-west-2"
access_key = var.aws_access_key_id
secret_key = var.aws_secret_access_key
}

resource "aws_db_instance" "videosRds" {
identifier = "videos-rds"
allocated_storage = 20
storage_type = "gp2"
engine = "postgres"
engine_version = "16.1"
instance_class = "db.t3.micro"
publicly_accessible = true
parameter_group_name = "default.postgres16"
vpc_security_group_ids = [var.vpc_security_group_id]
username = "postgres123"
password = var.db_password
skip_final_snapshot = true
}
21 changes: 21 additions & 0 deletions terraform-rds/variables.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
variable "aws_access_key_id" {
type = string
description = "AWS Access Key ID"
}

variable "aws_secret_access_key" {
type = string
sensitive = true
description = "AWS Secret Access Key"
}

variable "vpc_security_group_id" {
type = string
description = "AWS RDS vpc_security_group_id"
default = "sg-07e4fcb5547f26caf"
}

variable "db_password" {
type = string
description = "db_password"
}

0 comments on commit 9a14ecb

Please sign in to comment.