Skip to content

Commit

Permalink
Dev (#11)
Browse files Browse the repository at this point in the history
* update TF cli,provider version,oci_images

* Update install.tf

exclude packer directory
exclude terraform.lock files.

* rename to provider.tf.cli to hide from ORM

* update version note

Co-authored-by: Collin Poczatek <[email protected]>
Co-authored-by: J Collin Poczatek <[email protected]>
  • Loading branch information
3 people authored Apr 28, 2021
1 parent 0f94b78 commit bc6a6ed
Show file tree
Hide file tree
Showing 8 changed files with 89 additions and 37 deletions.
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
*.zip*
*.tfvars

# Local .terraform lock files
*.lock.*

# General
.DS_Store
.AppleDouble
Expand All @@ -32,4 +35,4 @@ Icon
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk
.apdisk
67 changes: 41 additions & 26 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

Expand All @@ -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!

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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. <br> `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. <br> `Customize Network Configuration`: Allow user to customize network configuration such as name, dns label, cidr block for VCN and Subnet.|
Expand Down Expand Up @@ -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..<unique_id>"
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..<unique_id>"
# 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.
2 changes: 1 addition & 1 deletion build-orm/install.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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",]
}
6 changes: 6 additions & 0 deletions compute.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
Expand Down
3 changes: 2 additions & 1 deletion marketplace.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -472,4 +473,4 @@ outputs:
title: Private IP
visible: true

primaryOutputButton: instance_https_url
primaryOutputButton: instance_https_url
25 changes: 25 additions & 0 deletions oci_images.tf
Original file line number Diff line number Diff line change
@@ -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..<unique_id>"
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..<unique_id>"
# is_pricing_associated = false
# compatible_shapes = ["VM.Standard2.2", "VM.Standard.E2.1.Micro"]
#}
}
}
7 changes: 1 addition & 6 deletions provider.tf.cli
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -19,4 +14,4 @@ variable "fingerprint" {
}

variable "private_key_path" {
}
}
11 changes: 9 additions & 2 deletions versions.tf
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
#Version Syntax MAYOR.MINOR.PATH, with a Min version ~<MAYOR.MINOR.0 (zero) and a Max tested version MAYOR.MINOR

terraform {
required_version = ">= 0.12"
}
required_version = "~> 0.14.0, < 0.15"
required_providers {
# Recommendation from ORM / OCI provider teams
oci = {
version ="~> 4.21.0"
}
}
}

0 comments on commit bc6a6ed

Please sign in to comment.