Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update rds_snapshot #288

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions scenarios/rds_snapshot/terraform/ec2.tf
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ resource "aws_instance" "cg-ec2-instance" {
}
}

// https://developer.hashicorp.com/terraform/language/v1.5.x/resources/provisioners/remote-exec
provisioner "remote-exec" {
inline = [
"sudo apt-get update -y",
Expand Down
24 changes: 23 additions & 1 deletion scenarios/rds_snapshot/terraform/provider.tf
Original file line number Diff line number Diff line change
@@ -1,4 +1,26 @@
terraform {
required_version = ">= 1.5"

required_providers {
aws = {
source = "hashicorp/aws"
version = ">= 5.0.0"
}
archive = {
source = "hashicorp/archive"
version = ">= 2.4"
}
}
}

provider "aws" {
profile = var.profile
region = var.region
}

default_tags {
tags = {
Stack = var.stack-name
Scenario = var.scenario-name
}
}
}
4 changes: 3 additions & 1 deletion scenarios/rds_snapshot/terraform/rds.tf
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// https://registry.terraform.io/providers/hashicorp/aws/5.0.0/docs/resources/db_instance
resource "aws_db_instance" "cg-rds-db_instance" {
allocated_storage = 20
engine = "mysql"
Expand All @@ -14,13 +15,14 @@ resource "aws_db_instance" "cg-rds-db_instance" {

vpc_security_group_ids = [aws_security_group.allow_mysql.id]

publicly_accessible = true
publicly_accessible = false
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whats the reason behind this change?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The database does not need to be (nor should it be) publicly accessible.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool, makes sense.
I think --publicly-accessible might need to be specified on the restore-db-instance-from-db-snapshot command in the cheat sheet?


tags = {
Name = "cg-rds-db_instance-${var.cgid}"
}
}

// https://registry.terraform.io/providers/hashicorp/aws/5.0.0/docs/resources/db_snapshot
resource "aws_db_snapshot" "cg-rds_snapshot" {
db_instance_identifier = aws_db_instance.cg-rds-db_instance.identifier
db_snapshot_identifier = "cg-rds-snapshot"
Expand Down
14 changes: 13 additions & 1 deletion scenarios/rds_snapshot/terraform/variable.tf
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,16 @@ variable "rds-password" {
description = "RDS Mysql instance password"
default = "cgoat9562!"
type = string
}
}

variable "stack-name" {
description = "Name of the stack."
default = "CloudGoat"
type = string
}

variable "scenario-name" {
description = "Name of the scenario."
default = "rds_snapshot"
type = string
}