Skip to content
Merged
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
8 changes: 7 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,7 @@
test
**/.terraform/*
*.tfstate
*.tfstate.*
*.tfvars
yc-key.json
id_rsa
id_rsa.pub
2 changes: 2 additions & 0 deletions labs/app_python/pulumi/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*.pyc
venv/
6 changes: 6 additions & 0 deletions labs/app_python/pulumi/Pulumi.dev.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
encryptionsalt: v1:VOWYF2ib5ug=:v1:BMl6B+O3G1V2TCs2:j4xsbIEdJB7nG4SAFJrtGpT6EFZLsw==
config:
yandex:cloudId: b1gv84qp02od589u3le0
yandex:folderId: b1g9bh9kbc2skuhht2de
yandex:zone: ru-central1-a
yandex:serviceAccountKeyFile: /workspaces/DevOps-Core-Course/labs/yc-key.json
10 changes: 10 additions & 0 deletions labs/app_python/pulumi/Pulumi.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
name: app-python
description: lab04 pulumi part
runtime:
name: python
options:
toolchain: pip
config:
pulumi:tags:
value:
pulumi:template: python
32 changes: 32 additions & 0 deletions labs/app_python/pulumi/__main__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import pulumi
import pulumi_yandex as yandex

network = yandex.VpcNetwork("lab-network")

subnet = yandex.VpcSubnet(
"lab-subnet",
network_id=network.id,
zone="ru-central1-a",
v4_cidr_blocks=["10.0.0.0/24"]
)

vm = yandex.ComputeInstance(
"lab-vm",
resources={
"cores": 2,
"memory": 1,
"core_fraction": 20
},
boot_disk={
"initialize_params": {
"image_id": "fd80qm01ah03dkqb14lc",
"size": 30
}
},
network_interfaces=[{
"subnet_id": subnet.id,
"nat": True
}]
)

pulumi.export("public_ip", vm.network_interfaces[0].nat_ip_address)
2 changes: 2 additions & 0 deletions labs/app_python/pulumi/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
pulumi>=3.0.0,<4.0.0
pulumi-yandex
22 changes: 22 additions & 0 deletions labs/app_python/terraform/.terraform.lock.hcl

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

55 changes: 55 additions & 0 deletions labs/app_python/terraform/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
terraform {
required_providers {
yandex = {
source = "yandex-cloud/yandex"
}
}
}

provider "yandex" {
service_account_key_file = var.service_account_key_file
cloud_id = var.cloud_id
folder_id = var.folder_id
zone = var.zone
}

# --- Network ---
resource "yandex_vpc_network" "lab_network" {
name = "lab-network"
}

# --- Subnet ---
resource "yandex_vpc_subnet" "lab_subnet" {
name = "lab-subnet"
zone = var.zone
network_id = yandex_vpc_network.lab_network.id
v4_cidr_blocks = ["10.0.0.0/24"]
}

# --- VM ---
resource "yandex_compute_instance" "vm" {
name = "lab04-vm"
platform_id = "standard-v2"

resources {
cores = 2
memory = 1
core_fraction = 20
}

boot_disk {
initialize_params {
image_id = "fd80qm01ah03dkqb14lc"
size = 30
}
}

network_interface {
subnet_id = yandex_vpc_subnet.lab_subnet.id
nat = true
}

metadata = {
ssh-keys = "ubuntu:${file(var.ssh_public_key_path)}"
}
}
3 changes: 3 additions & 0 deletions labs/app_python/terraform/outputs.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
output "public_ip" {
value = yandex_compute_instance.vm.network_interface[0].nat_ip_address
}
9 changes: 9 additions & 0 deletions labs/app_python/terraform/variables.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
variable "cloud_id" {}
variable "folder_id" {}

variable "zone" {
default = "ru-central1-a"
}

variable "service_account_key_file" {}
variable "ssh_public_key_path" {}
Loading