Skip to content

Commit

Permalink
chore: add use case for obj storage demo (#70)
Browse files Browse the repository at this point in the history
  • Loading branch information
goncalo-rodrigues authored Jun 28, 2022
1 parent 1cf0e9d commit a006c7f
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 18 deletions.
18 changes: 1 addition & 17 deletions tests/resources/virtual_machine/virtual_machine/main.tf
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
variable "cloud" {
type = string
default = "aws"
default = "azure"
}

variable "location" {
Expand All @@ -26,22 +26,6 @@ resource "multy_network_security_group" nsg {
virtual_network_id = multy_virtual_network.vn.id
cloud = var.cloud
location = var.location
rule {
protocol = "tcp"
priority = 120
from_port = 22
to_port = 22
cidr_block = "0.0.0.0/0"
direction = "both"
}
rule {
protocol = "tcp"
priority = 131
from_port = 443
to_port = 443
cidr_block = "0.0.0.0/0"
direction = "both"
}
rule {
protocol = "tcp"
priority = 132
Expand Down
58 changes: 58 additions & 0 deletions tests/use_case/object_storage/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
terraform {
required_providers {
multy = {
source = "multycloud/multy"
}
}
}

provider "multy" {
api_key = "XXX-YYY-ZZZ"
aws = {}
azure = {}
server_endpoint = "localhost:8000"
}

variable "clouds" {
type = set(string)
default = ["aws", "azure"]
}

resource "random_string" "obj_suffix" {
length = 4
special = false
upper = false
}

resource "multy_object_storage" "obj_storage" {
for_each = var.clouds
name = "multy-test-${random_string.obj_suffix.result}"
cloud = each.key
location = "us_east_1"
versioning = true
}

resource "multy_object_storage_object" "public_obj_storage" {
for_each = var.clouds
name = "hello_world"
object_storage_id = multy_object_storage.obj_storage[each.key].id
content_base64 = base64encode("<h1>hello world from ${each.key}</h1>")
content_type = "text/html"
acl = "public_read"
}

resource "multy_object_storage_object" "private_obj_storage" {
for_each = var.clouds
name = "super-secret-file"
object_storage_id = multy_object_storage.obj_storage[each.key].id
content_base64 = base64encode("<h1>goodbye world from ${each.key}</h1>")
content_type = "text/html"
}

output "aws_object_url" {
value = multy_object_storage_object.public_obj_storage["aws"].url
}

output "azure_object_url" {
value = multy_object_storage_object.public_obj_storage["azure"].url
}
2 changes: 1 addition & 1 deletion tests/use_case/web_app/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ variable "clouds" {

variable "vm_clouds" {
type = set(string)
default = ["aws", "azure"]
default = ["azure"]
}

variable "db_cloud" {
Expand Down

0 comments on commit a006c7f

Please sign in to comment.