Last active
July 14, 2022 17:07
-
-
Save Ctacfs/51c67a5d4b0f7b1bce1fd269c1059e40 to your computer and use it in GitHub Desktop.
tf-2
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
resource "google_compute_address" "app_ip" { | |
name = "reddit-app-ip" | |
} |
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
network_interface { | |
network = "default" | |
access_config { | |
nat_ip = google_compute_address.app_ip.address | |
} | |
} |
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
variable app_disk_image { | |
description = "Disk image for reddit app" | |
default = "reddit-app-base" | |
} |
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
resource "google_compute_instance" "app" { | |
name = "reddit-app" | |
machine_type = "g1-small" | |
zone = var.zone | |
tags = ["reddit-app"] | |
boot_disk { | |
initialize_params { image = var.app_disk_image } | |
} | |
network_interface { | |
network = "default" | |
access_config { | |
nat_ip = google_compute_address.app_ip.address | |
} | |
} | |
metadata { | |
ssh-keys = "appuser:${file(var.public_key_path)}" | |
} | |
} |
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
resource "google_compute_address" "app_ip" { | |
name = "reddit-app-ip" | |
} | |
resource "google_compute_firewall" "firewall_puma" { | |
name = "allow-puma-default" | |
network = "default" | |
allow { | |
protocol = "tcp", ports = ["9292"] | |
} | |
source_ranges = ["0.0.0.0/0"] | |
target_tags = ["reddit-app"] | |
} |
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
resource "google_compute_instance" "db" { | |
name = "reddit-db" | |
machine_type = "g1-small" | |
zone = var.zone | |
tags = ["reddit-db"] | |
boot_disk { | |
initialize_params { | |
image = var.db_disk_image | |
} | |
} | |
network_interface { | |
network = "default" | |
access_config = {} | |
} | |
metadata { | |
ssh-keys = "appuser:${file(var.public_key_path)}" | |
} | |
} |
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
resource "google_compute_firewall" "firewall_mongo" { | |
name = "allow-mongo-default" | |
network = "default" | |
allow { | |
protocol = "tcp" | |
ports = ["27017"] | |
} | |
target_tags = ["reddit-db"] | |
source_tags = ["reddit-app"] | |
} |
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
variable db_disk_image { | |
description = "Disk image for reddit db" | |
default = "reddit-db-base" | |
} |
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
# vpc.tf | |
resource "google_compute_firewall" "firewall_ssh" { | |
name = "default-allow-ssh" | |
network = "default" | |
allow { | |
protocol = "tcp" | |
ports = ["22"] | |
} | |
source_ranges = ["0.0.0.0/0"] | |
} |
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
provider "google" { | |
version = "~> 2.15" | |
project = var.project | |
region = var.region | |
} |
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
variable public_key_path { | |
description = "Path to the public key used to connect to instance" | |
} | |
variable zone { | |
description = "Zone" | |
} | |
variable db_disk_image { | |
description = "Disk image for reddit db" | |
default = "reddit-db-base" | |
} |
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
variable public_key_path { | |
description = "Path to the public key used to connect to instance" | |
} | |
variable zone { | |
description = "Zone" | |
} | |
variable app_disk_image { | |
description = "Disk image for reddit app" | |
default = "reddit-app-base" | |
} |
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
output "app_external_ip" { | |
value = google_compute_instance.app.network_interface.0.access_config.0.assigned_nat_ip | |
} |
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
provider "google" { | |
version = "~> 2.15" | |
project = var.project | |
region = var.region | |
} | |
module "app" { | |
source = "modules/app" | |
public_key_path = var.public_key_path | |
zone = var.zone | |
app_disk_image = var.app_disk_image | |
} | |
module "db" { | |
source = "modules/db" | |
public_key_path = var.public_key_path | |
zone = var.zone | |
db_disk_image = var.db_disk_image | |
} |
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
output "app_external_ip" { | |
value = module.app.app_external_ip | |
} |
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
resource "google_compute_firewall" "firewall_ssh" { | |
name = "default-allow-ssh" | |
network = "default" | |
allow { | |
protocol = "tcp" | |
ports = ["22"] | |
} | |
source_ranges = var.source_ranges | |
} |
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
variable source_ranges { | |
description = "Allowed IP addresses" | |
default = ["0.0.0.0/0"] | |
} |
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
module "vpc" { | |
source = "modules/vpc" | |
source_ranges = ["80.250.215.124/32"] | |
} |
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
provider "google" { | |
version = "~> 2.15" | |
project = var.project | |
region = var.region | |
} | |
module "app" { | |
source = "../modules/app" | |
public_key_path = var.public_key_path | |
app_disk_image = var.app_disk_image | |
} | |
module "db" { | |
source = "../modules/db" | |
public_key_path = var.public_key_path | |
db_disk_image = var.db_disk_image | |
} | |
module "vpc" { | |
source = "../modules/vpc" | |
source_ranges = ["0.0.0.0/0"] | |
} |
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
provider "google" { | |
version = "~> 2.15" | |
project = var.project | |
region = var.region | |
} | |
module "app" { | |
source = "../modules/app" | |
public_key_path = var.public_key_path | |
app_disk_image = var.app_disk_image | |
} | |
module "db" { | |
source = "../modules/db" | |
public_key_path = var.public_key_path | |
db_disk_image = var.db_disk_image | |
} | |
module "vpc" { | |
source = "../modules/vpc" | |
source_ranges = ["82.155.222.156/32"] | |
} |
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
provider "google" { | |
version = "~> 2.15" | |
project = var.project | |
region = var.region | |
} | |
module "storage-bucket" { | |
source = "SweetOps/storage-bucket/google" | |
version = "0.3.0" | |
# Имя поменяйте на другое | |
name = "storage-bucket-test" | |
} | |
output storage-bucket_url { | |
value = module.storage-bucket.url | |
} |
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
resource "google_compute_firewall" "firewall_ssh" { | |
name = "default-allow-ssh" | |
network = "default" | |
allow { | |
protocol = "tcp" | |
ports = ["22"] | |
} | |
source_ranges = ["0.0.0.0/0"] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment