Created
December 11, 2020 17:31
-
-
Save a1git/1fddc213d030901051564fb01039a13e to your computer and use it in GitHub Desktop.
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
providers.tf | |
------------ | |
provider "openstack" {} | |
------------ | |
osa.tf | |
------------ | |
data "openstack_identity_project_v3" "admin-project-id" { | |
name = "admin" | |
} | |
resource "openstack_images_image_v2" "cirros" { | |
name = "cirros" | |
image_source_url = "http://download.cirros-cloud.net/0.5.1/cirros-0.5.1-x86_64-disk.img" | |
container_format = "bare" | |
disk_format = "qcow2" | |
properties = { | |
key = "value" | |
} | |
} | |
resource "openstack_compute_keypair_v2" "admin0" { | |
name = "admin0" | |
public_key = "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACgQCuEPLNMPmjR3Uos0mn1CNONnXYiCGRT7XsChgt8guQTHS+dY4/CwJawO+cNl3HXxF2VSlQT8SxCqpkAX3/fXWDRnm0LYnwEZUkasJrD2UHh2Im2nlkyarHT65kR8bIGhl9Gc/APG+mXSAWp+Qdc9S0j8A/UeftusQxHERtAgOnZKfU7T5seIy8YSRJN2bQOZjCdLqFegpJlGosRFQYuOfooEAnSIeaAw7jrGrfkJg315qaWY5sOG+G3YtVKxBAA7IGAogfhA+nLfGGwXxzh0JQiJPKmtjWbdxkS9hM0a/AXLyNc0F6daT+/8EEugm2Lk8ON8BrjREYerXBntWMwYVUsV22RDEMGhJOJIONBC2dGk9gFI4LAzlWfsTKaRVH41R3pikrJbF+WVRPQ+AeF/x2TzWx17/tEJb/CAffRyAAisCZfbwdBjQJA6KUcPUP6Gu3HEZbvVpPhJemWjTS7z866reqaKBFWrvkhd1BBpV3pgrq3JkA8qrrOIBZ+VKhLf8emKBOjguGy11I42yMFNXtxbG3GSspWSPFQf0kZ65TFbjUqXwlXAgzoklOvDDVvpgbVBWW9eUVKEA11rtXsH+EsmtyUWfYWRqfOLkQmFA+SxkIIrofVs1bduCcHgMNRrfGaDJHW1oE6iTa2TTz6eednEahE8idDijW6XyVPUfeBg4njCtog0nrlbjab5VY7MY9X+szftp6Z0jg2AV52Lxwsye6FhwzpfqLc5drBu2LiN4TZtzMhkMgLa3dzZ5qKbGagy9QgxtrCVbXfmeqFzuKswMKedM4fy8k+j/tUKiWRi0QFIx618Q1sUf0R0kG8z0rMjgOf0rJaMCW+SGFqC4d shashi@" | |
} | |
resource "openstack_networking_network_v2" "admin-net-01" { | |
name = "admin-net-01" | |
admin_state_up = "true" | |
} | |
resource "openstack_networking_subnet_v2" "admin-subnet-01" { | |
name = "admin-subnet-01" | |
network_id = openstack_networking_network_v2.admin-net-01.id | |
cidr = "10.100.200.0/24" | |
ip_version = 4 | |
} | |
resource "openstack_compute_secgroup_v2" "icmp-ssh-web" { | |
name = "icmp-ssh-web" | |
description = "basic firewall" | |
rule { | |
from_port = 22 | |
to_port = 22 | |
ip_protocol = "tcp" | |
cidr = "0.0.0.0/0" | |
} | |
rule { | |
from_port = 80 | |
to_port = 80 | |
ip_protocol = "tcp" | |
cidr = "0.0.0.0/0" | |
} | |
rule { | |
from_port = 443 | |
to_port = 443 | |
ip_protocol = "tcp" | |
cidr = "0.0.0.0/0" | |
} | |
rule { | |
from_port = "8" | |
to_port = "0" | |
ip_protocol = "icmp" | |
cidr = "0.0.0.0/0" | |
} | |
} | |
resource "openstack_compute_flavor_v2" "s1-tiny" { | |
name = "s1.tiny" | |
ram = "256" | |
vcpus = "1" | |
disk = "5" | |
is_public = false | |
} | |
resource "openstack_compute_flavor_access_v2" "admin-access-01" { | |
tenant_id = data.openstack_identity_project_v3.admin-project-id.id | |
flavor_id = openstack_compute_flavor_v2.s1-tiny.id | |
} | |
resource "openstack_blockstorage_volume_v2" "admin-volume-1" { | |
name = "admin-volume-1" | |
size = 1 | |
} | |
resource "openstack_compute_instance_v2" "admin-vm-1" { | |
name = "admin-vm-1" | |
image_id = openstack_images_image_v2.cirros.id | |
flavor_id = openstack_compute_flavor_v2.s1-tiny.id | |
key_pair = "admin0" | |
security_groups = ["icmp-ssh-web"] | |
network { | |
name = "admin-net-01" | |
} | |
} | |
resource "openstack_compute_volume_attach_v2" "attached" { | |
instance_id = openstack_compute_instance_v2.admin-vm-1.id | |
volume_id = openstack_blockstorage_volume_v2.admin-volume-1.id | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment