diff --git a/.gitignore b/.gitignore index 3784276..40c111b 100644 --- a/.gitignore +++ b/.gitignore @@ -7,6 +7,9 @@ *.zip* *.tfvars +# Local .terraform lock files +*.lock.* + # General .DS_Store .AppleDouble @@ -32,4 +35,4 @@ Icon .AppleDesktop Network Trash Folder Temporary Items -.apdisk \ No newline at end of file +.apdisk diff --git a/README.md b/README.md index 17b369e..ee53887 100644 --- a/README.md +++ b/README.md @@ -15,9 +15,10 @@ This Quick Start uses [OCI Resource Manager](https://docs.cloud.oracle.com/iaas/ [![Deploy to Oracle Cloud](https://oci-resourcemanager-plugin.plugins.oci.oraclecloud.com/latest/deploy-to-oracle-cloud.svg)](https://console.us-ashburn-1.oraclecloud.com/resourcemanager/stacks/create?region=home&zipUrl=https://github.com/oracle-quickstart/oci-quickstart-template/archive/master.zip) -After logging into the console you'll be taken through the same steps described +After logging into the console you'll be taken through the same steps described in the [Deploy](#deploy) section below. + Note, if you use this template to create another repo you'll need to change the link for the button to point at your repo. ## Local Development @@ -29,15 +30,7 @@ If you want to not use ORM and deploy with the terraform CLI you need to rename `provider.tf.cli -> provider.tf`. This is because authentication works slightly differently in ORM vs the CLI. This file is ignored by the build process below. -Make sure you have terraform v0.12+ cli installed and accessible from your terminal. - -```bash -terraform -v - -Terraform v0.12.24 -+ provider.null v2.1.2 -+ provider.oci v3.71.0 -``` +Make sure you have terraform v0.14+ cli installed and accessible from your terminal. ### Build @@ -53,18 +46,14 @@ $ terraform init Initializing the backend... Initializing provider plugins... -- Checking for available provider plugins... -- Downloading plugin for provider "archive" (hashicorp/archive) 1.3.0... - -The following providers do not have any version constraints in configuration, -so the latest version was installed. - -To prevent automatic upgrades to new major versions that may contain breaking -changes, it is recommended to add version = "..." constraints to the -corresponding provider blocks in configuration, with the constraint strings -suggested below. +- Finding latest version of hashicorp/archive... +- Installing hashicorp/archive v2.1.0... +- Installed hashicorp/archive v2.1.0 (signed by HashiCorp) -* provider.archive: version = "~> 1.3" +Terraform has created a lock file .terraform.lock.hcl to record the provider +selections it made above. Include this file in your version control repository +so that Terraform can guarantee to make the same selections by default when +you run "terraform init" in the future. Terraform has been successfully initialized! @@ -94,20 +83,20 @@ $ unzip -l dist/orm.zip Archive: dist/orm.zip Length Date Time Name --------- ---------- ----- ---- - 5324 01-01-2049 00:00 README_simple.md 1140 01-01-2049 00:00 compute.tf 680 01-01-2049 00:00 data_sources.tf 1632 01-01-2049 00:00 image_subscription.tf 1359 01-01-2049 00:00 locals.tf - 13540 01-01-2049 00:00 marketplace.yaml + 13548 01-01-2049 00:00 marketplace.yaml 2001 01-01-2049 00:00 network.tf 2478 01-01-2049 00:00 nsg.tf + 830 01-01-2049 00:00 oci_images.tf 1092 01-01-2049 00:00 outputs.tf 44 01-01-2049 00:00 scripts/example.sh 4848 01-01-2049 00:00 variables.tf - 46 01-01-2049 00:00 versions.tf + 311 01-01-2049 00:00 versions.tf --------- ------- - 34184 12 files + 29963 12 files ``` ### Deploy @@ -136,7 +125,7 @@ Archive: dist/orm.zip | VARIABLE | DESCRIPTION | |----------------------------|-----------------------------------------------------------------------| -|NETWORK COMPARTMENT | Compartment for all Virtual Cloud Nettwork resources| +|NETWORK COMPARTMENT | Compartment for all Virtual Cloud Network resources| |NETWORK STRATEGY | `Create New VCN and Subnet`: Create new network resources during apply.
`Use Existing VCN and Subnet`: Let user select pre-existent network resources.| |CONFIGURATION STRATEGY | `Use Recommended Configuration`: Use default configuration defined by the Terraform template.
`Customize Network Configuration`: Allow user to customize network configuration such as name, dns label, cidr block for VCN and Subnet.| @@ -230,6 +219,32 @@ resource "oci_core_instance" "simple-vm" { source_id = local.compute_image_id } +``` +2. Modify [`oci_images.tf`](./oci_images.tf) set `marketplace_source_images` map variable to refer to the marketplace images your Stack will launch. + +```hcl + +variable "marketplace_source_images" { + type = map(object({ + ocid = string + is_pricing_associated = bool + compatible_shapes = list(string) + })) + default = { + main_mktpl_image = { + ocid = "ocid1.image.oc1.." + is_pricing_associated = true + compatible_shapes = [] + } + #Remove comment and add as many marketplace images that your stack references be replicated to other realms + #supporting_image = { + # ocid = "ocid1.image.oc1.." + # is_pricing_associated = false + # compatible_shapes = ["VM.Standard2.2", "VM.Standard.E2.1.Micro"] + #} + } +} + ``` 2. Run your tests using the Terraform CLI or build a new package and deploy on ORM. diff --git a/build-orm/install.tf b/build-orm/install.tf index 97ef734..82de81e 100644 --- a/build-orm/install.tf +++ b/build-orm/install.tf @@ -6,5 +6,5 @@ data "archive_file" "generate_zip" { type = "zip" output_path = (var.save_to != "" ? "${var.save_to}/orm.zip" : "${path.module}/dist/orm.zip") source_dir = "../" - excludes = ["terraform.tfstate", "terraform.tfvars.template", "terraform.tfvars", "provider.tf", ".terraform", "build-orm", "images", "README.md", "terraform.", "terraform.tfstate.backup", "test", "simple", ".git", "README", ".github", ".gitignore", ".DS_Store", "LICENSE", "diagram"] + excludes = ["packer",".terraform.lock.hcl","terraform.tfstate", "terraform.tfvars.template", "terraform.tfvars", "provider.tf", ".terraform", "build-orm", "images", "README.md", "terraform.", "terraform.tfstate.backup", "test", "simple", ".git", "README", ".github", ".gitignore", ".DS_Store", "LICENSE","diagram",] } diff --git a/compute.tf b/compute.tf index b0bc361..23217b8 100644 --- a/compute.tf +++ b/compute.tf @@ -27,6 +27,12 @@ resource "oci_core_instance" "simple-vm" { #use a marketplace image or custom image: #source_id = local.compute_image_id } + + lifecycle { + ignore_changes = [ + source_details[0].source_id + ] + } lifecycle { ignore_changes = [ diff --git a/marketplace.yaml b/marketplace.yaml index 3b00069..8be4ce8 100644 --- a/marketplace.yaml +++ b/marketplace.yaml @@ -36,6 +36,7 @@ variableGroups: - nsg_config_enum #change compute.tf and move custom_image_id to Compute group in case you want to use a custom_image - custom_image_id + - marketplace_source_images - title: "Compute Configuration" variables: @@ -472,4 +473,4 @@ outputs: title: Private IP visible: true -primaryOutputButton: instance_https_url +primaryOutputButton: instance_https_url \ No newline at end of file diff --git a/oci_images.tf b/oci_images.tf new file mode 100644 index 0000000..a1808f5 --- /dev/null +++ b/oci_images.tf @@ -0,0 +1,25 @@ +#File used only if Stack is a Marketplace Stack +#Update based on Marketplace Listing - App Install Package - Image ocid +#Each element is a single image from Marketpalce Catalog. Elements' name in map is arbitrary + + +variable "marketplace_source_images" { + type = map(object({ + ocid = string + is_pricing_associated = bool + compatible_shapes = list(string) + })) + default = { + main_mktpl_image = { + ocid = "ocid1.image.oc1.." + is_pricing_associated = true + compatible_shapes = [] + } + #Remove comment and add as many marketplace images that your stack references be replicated to other realms + #supporting_image = { + # ocid = "ocid1.image.oc1.." + # is_pricing_associated = false + # compatible_shapes = ["VM.Standard2.2", "VM.Standard.E2.1.Micro"] + #} + } +} diff --git a/provider.tf.cli b/provider.tf.cli index 7f33223..c9cb468 100644 --- a/provider.tf.cli +++ b/provider.tf.cli @@ -1,14 +1,9 @@ -terraform { - required_version = "~> 0.12" -} - provider "oci" { tenancy_ocid = var.tenancy_ocid user_ocid = var.user_ocid fingerprint = var.fingerprint private_key_path = var.private_key_path region = var.region - version = ">= 3.37" } # Variables required by the OCI Provider only when running Terraform CLI with standard user based Authentication @@ -19,4 +14,4 @@ variable "fingerprint" { } variable "private_key_path" { -} \ No newline at end of file +} diff --git a/versions.tf b/versions.tf index ac97c6a..cd653d3 100644 --- a/versions.tf +++ b/versions.tf @@ -1,4 +1,11 @@ +#Version Syntax MAYOR.MINOR.PATH, with a Min version ~