Skip to content

Commit

Permalink
single compartment, version to 1.0, tag fix
Browse files Browse the repository at this point in the history
  • Loading branch information
cpoczatek committed Dec 1, 2021
1 parent ddf1384 commit 95a4b68
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 26 deletions.
4 changes: 2 additions & 2 deletions compute.tf
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
resource "oci_core_instance" "simple-vm" {
availability_domain = local.availability_domain
compartment_id = var.compute_compartment_ocid
compartment_id = var.compartment_ocid
display_name = var.vm_display_name
shape = var.vm_compute_shape

Expand Down Expand Up @@ -39,5 +39,5 @@ resource "oci_core_instance" "simple-vm" {
user_data = base64encode(file("./scripts/example.sh"))
}

freeform_tags = map(var.tag_key_name, var.tag_value)
freeform_tags = {(var.tag_key_name) = (var.tag_value)}
}
2 changes: 1 addition & 1 deletion data_sources.tf
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ data "oci_identity_availability_domain" "ad" {
}

data "oci_core_images" "autonomous_ol7" {
compartment_id = var.compute_compartment_ocid
compartment_id = var.compartment_ocid
operating_system = "Oracle Autonomous Linux"
sort_by = "TIMECREATED"
sort_order = "DESC"
Expand Down
4 changes: 2 additions & 2 deletions image_subscription.tf
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ resource "oci_core_app_catalog_listing_resource_version_agreement" "mp_image_agr
resource "oci_core_app_catalog_subscription" "mp_image_subscription" {
count = local.mp_subscription_enabled

compartment_id = var.compute_compartment_ocid
compartment_id = var.compartment_ocid
eula_link = oci_core_app_catalog_listing_resource_version_agreement.mp_image_agreement[0].eula_link
listing_id = oci_core_app_catalog_listing_resource_version_agreement.mp_image_agreement[0].listing_id
listing_resource_version = oci_core_app_catalog_listing_resource_version_agreement.mp_image_agreement[0].listing_resource_version
Expand All @@ -27,7 +27,7 @@ resource "oci_core_app_catalog_subscription" "mp_image_subscription" {
data "oci_core_app_catalog_subscriptions" "mp_image_subscription" {
count = local.mp_subscription_enabled

compartment_id = var.compute_compartment_ocid
compartment_id = var.compartment_ocid
listing_id = local.listing_id

filter {
Expand Down
18 changes: 9 additions & 9 deletions network.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,39 +2,39 @@ resource "oci_core_vcn" "simple" {
count = local.use_existing_network ? 0 : 1
cidr_block = var.vcn_cidr_block
dns_label = substr(var.vcn_dns_label, 0, 15)
compartment_id = var.network_compartment_ocid
compartment_id = var.compartment_ocid
display_name = var.vcn_display_name

freeform_tags = map(var.tag_key_name, var.tag_value)
freeform_tags = {(var.tag_key_name) = (var.tag_value)}
}

#IGW
resource "oci_core_internet_gateway" "simple_internet_gateway" {
count = local.use_existing_network ? 0 : 1
compartment_id = var.network_compartment_ocid
compartment_id = var.compartment_ocid
vcn_id = oci_core_vcn.simple[count.index].id
enabled = "true"
display_name = "${var.vcn_display_name}-igw"

freeform_tags = map(var.tag_key_name, var.tag_value)
freeform_tags = {(var.tag_key_name) = (var.tag_value)}
}

#simple subnet
resource "oci_core_subnet" "simple_subnet" {
count = local.use_existing_network ? 0 : 1
cidr_block = var.subnet_cidr_block
compartment_id = var.network_compartment_ocid
compartment_id = var.compartment_ocid
vcn_id = oci_core_vcn.simple[count.index].id
display_name = var.subnet_display_name
dns_label = substr(var.subnet_dns_label, 0, 15)
prohibit_public_ip_on_vnic = ! local.is_public_subnet

freeform_tags = map(var.tag_key_name, var.tag_value)
freeform_tags = {(var.tag_key_name) = (var.tag_value)}
}

resource "oci_core_route_table" "simple_route_table" {
count = local.use_existing_network ? 0 : 1
compartment_id = var.network_compartment_ocid
compartment_id = var.compartment_ocid
vcn_id = oci_core_vcn.simple[count.index].id
display_name = "${var.subnet_display_name}-rt"

Expand All @@ -44,11 +44,11 @@ resource "oci_core_route_table" "simple_route_table" {
destination_type = "CIDR_BLOCK"
}

freeform_tags = map(var.tag_key_name, var.tag_value)
freeform_tags = {(var.tag_key_name) = (var.tag_value)}
}

resource "oci_core_route_table_attachment" "route_table_attachment" {
count = local.use_existing_network ? 0 : 1
subnet_id = oci_core_subnet.simple_subnet[count.index].id
route_table_id = oci_core_route_table.simple_route_table[count.index].id
}
}
6 changes: 3 additions & 3 deletions nsg.tf
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
resource "oci_core_network_security_group" "simple_nsg" {
#Required
compartment_id = var.network_compartment_ocid
compartment_id = var.compartment_ocid
vcn_id = local.use_existing_network ? var.vcn_id : oci_core_vcn.simple.0.id

#Optional
display_name = var.nsg_display_name

freeform_tags = map(var.tag_key_name, var.tag_value)
freeform_tags = {(var.tag_key_name) = (var.tag_value)}
}

# Allow Egress traffic to all networks
Expand Down Expand Up @@ -74,4 +74,4 @@ resource "oci_core_network_security_group_security_rule" "simple_rule_all_simple
direction = "INGRESS"
source = var.vcn_cidr_block
stateless = false
}
}
6 changes: 1 addition & 5 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -170,14 +170,10 @@ variable "nsg_http_port" {
# Additional Configuration #
############################

variable "compute_compartment_ocid" {
variable "compartment_ocid" {
description = "Compartment where Compute and Marketplace subscription resources will be created"
}

variable "network_compartment_ocid" {
description = "Compartment where Network resources will be created"
}

variable "tag_key_name" {
description = "Free-form tag key name"
default = "oracle-quickstart"
Expand Down
5 changes: 1 addition & 4 deletions versions.tf
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
# Pesimistic ~> opoerator allows only 0.14.x, current max version supported by ORM
# https://www.terraform.io/docs/language/expressions/version-constraints.html

terraform {
required_version = "~> 0.14.0"
required_version = "> 1.0.0"
required_providers {
# Recommendation from ORM / OCI provider teams
oci = {
Expand Down

0 comments on commit 95a4b68

Please sign in to comment.