Skip to content

Commit d0fe6fe

Browse files
committed
Initial commit
0 parents  commit d0fe6fe

27 files changed

+1642
-0
lines changed
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
name: 'simple-orm-stack'
2+
3+
on: [push, pull_request]
4+
env:
5+
PROJECT_WORKING_DIR: '/build-orm/'
6+
7+
jobs:
8+
terraform_generate_orm_zip:
9+
name: 'Generate Stack Package'
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v1
13+
- name: 'Terraform Init'
14+
uses: hashicorp/terraform-github-actions@master
15+
with:
16+
tf_actions_version: 0.12.17
17+
tf_actions_subcommand: 'init'
18+
tf_actions_working_dir: ${{ env.PROJECT_WORKING_DIR }}
19+
env:
20+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
21+
- name: 'Terraform Validate'
22+
uses: hashicorp/terraform-github-actions@master
23+
with:
24+
tf_actions_version: 0.12.17
25+
tf_actions_subcommand: 'validate'
26+
tf_actions_working_dir: ${{ env.PROJECT_WORKING_DIR }}
27+
env:
28+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
29+
- name: 'Terraform Apply'
30+
uses: hashicorp/terraform-github-actions@master
31+
with:
32+
tf_actions_version: 0.12.17
33+
tf_actions_subcommand: 'apply'
34+
tf_actions_working_dir: ${{ env.PROJECT_WORKING_DIR }}
35+
args: '-var="save_to"="export-dist"'
36+
env:
37+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
38+
- name: Create Release
39+
id: create_release
40+
uses: actions/create-release@v1
41+
env:
42+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token
43+
with:
44+
tag_name: ${{ github.ref }}
45+
release_name: Release ${{ github.ref }}
46+
body: |
47+
Changes in this Release
48+
- New ORM Stack template ${{ github.ref }}
49+
draft: true
50+
prerelease: true
51+
- name: Upload Release Asset
52+
id: upload-release-asset
53+
uses: actions/[email protected]
54+
env:
55+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
56+
with:
57+
upload_url: ${{ steps.create_release.outputs.upload_url }}
58+
asset_path: ${{ github.workspace }}${{ env.PROJECT_WORKING_DIR }}export-dist/orm.zip
59+
asset_name: orm-stack.zip
60+
asset_content_type: application/zip

.gitignore

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# Local .terraform directories
2+
**/.terraform/*
3+
4+
# .tfstate files
5+
*.tfstate
6+
*.tfstate.*
7+
*.zip*
8+
*.tfvars
9+
10+
# General
11+
.DS_Store
12+
.AppleDouble
13+
.LSOverride
14+
15+
# Icon must end with two \r
16+
Icon
17+
18+
# Thumbnails
19+
._*
20+
21+
# Files that might appear in the root of a volume
22+
.DocumentRevisions-V100
23+
.fseventsd
24+
.Spotlight-V100
25+
.TemporaryItems
26+
.Trashes
27+
.VolumeIcon.icns
28+
.com.apple.timemachine.donotpresent
29+
30+
# Directories potentially created on remote AFP share
31+
.AppleDB
32+
.AppleDesktop
33+
Network Trash Folder
34+
Temporary Items
35+
.apdisk

LICENSE

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
Copyright (c) 2018-2020 Oracle and/or its affiliates. All rights reserved.
2+
3+
The Universal Permissive License (UPL), Version 1.0
4+
5+
Subject to the condition set forth below, permission is hereby granted to any person obtaining a copy of this
6+
software, associated documentation and/or data (collectively the "Software"), free of charge and under any and
7+
all copyright rights in the Software, and any and all patent rights owned or freely licensable by each licensor
8+
hereunder covering either (i) the unmodified Software as contributed to or provided by such licensor, or
9+
(ii) the Larger Works (as defined below), to deal in both
10+
11+
(a) the Software, and
12+
(b) any piece of software and/or hardware listed in the lrgrwrks.txt file if one is included with the Software
13+
(each a “Larger Work” to which the Software is contributed by such licensors),
14+
15+
without restriction, including without limitation the rights to copy, create derivative works of, display,
16+
perform, and distribute the Software and make, use, sell, offer for sale, import, export, have made, and have
17+
sold the Software and the Larger Work(s), and to sublicense the foregoing rights on either these or other terms.
18+
19+
This license is subject to the following condition:
20+
The above copyright notice and either this complete permission notice or at a minimum a reference to the UPL must
21+
be included in all copies or substantial portions of the Software.
22+
23+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
24+
THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
25+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
26+
CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
27+
IN THE SOFTWARE.

README.md

Lines changed: 235 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,235 @@
1+
# oci-quickstart-template
2+
3+
The [Oracle Cloud Infrastructure (OCI) Quick Start](https://github.com/oracle-quickstart?q=oci-quickstart) is a collection of examples that allow Oracle Cloud Infrastructure users to get a quick start deploying advanced infrastructure on OCI.
4+
5+
The oci-quickstart-template repository contains the template that can be used for accelerating the construction of quickstarts that runs from local Terraform CLI, [OCI Resource Manager](https://docs.cloud.oracle.com/en-us/iaas/Content/ResourceManager/Concepts/resourcemanager.htm) and [OCI Cloud Shell](https://docs.cloud.oracle.com/en-us/iaas/Content/API/Concepts/cloudshellintro.htm).
6+
7+
Simple is a sample quickstart terraform template that deploys a virtual machine on a Virtual Cloud Network.
8+
Simple can be customized to subscribe and launch Marketplace images, Platform images or Custom images.
9+
10+
This repo is under active development. Building open source software is a community effort. We're excited to engage with the community building this.
11+
12+
## Resource Manager Deployment
13+
14+
This Quick Start uses [OCI Resource Manager](https://docs.cloud.oracle.com/iaas/Content/ResourceManager/Concepts/resourcemanager.htm) to make deployment easy, sign up for an [OCI account](https://cloud.oracle.com/en_US/tryit) if you don't have one, and just click the button below:
15+
16+
[![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)
17+
18+
After logging into the console you'll be taken through the same steps described
19+
in the [Deploy](#deploy) section below.
20+
21+
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.
22+
23+
## Local Development
24+
25+
First off we'll need to do some pre deploy setup. That's all detailed [here](https://github.com/oracle/oci-quickstart-prerequisites).
26+
27+
Note, the instructions below build a `.zip` file from you local copy for use in ORM.
28+
If you want to not use ORM and deploy with the terraform CLI you need to rename
29+
`provider.tf.cli -> provider.tf`. This is because authentication works slightly
30+
differently in ORM vs the CLI. This file is ignored by the build process below.
31+
32+
Make sure you have terraform v0.12+ cli installed and accessible from your terminal.
33+
34+
```bash
35+
terraform -v
36+
37+
Terraform v0.12.24
38+
+ provider.null v2.1.2
39+
+ provider.oci v3.71.0
40+
```
41+
42+
### Build
43+
44+
Simply `build` your package and follow the [Resource Manager instructions](https://docs.cloud.oracle.com/en-us/iaas/Content/ResourceManager/Tasks/managingstacksandjobs.htm#console) for how to create a stack. Prior to building the Stack, you may want to modify some parts of the deployment detailed below.
45+
46+
In order to `build` the zip file with the latest changes you made to this code, you can simply go to [build-orm](./build-orm) folder and use terraform to generate a new zip file:
47+
48+
At first time, you are required to initialize the terraform modules used by the template with `terraform init` command:
49+
50+
```bash
51+
$ terraform init
52+
53+
Initializing the backend...
54+
55+
Initializing provider plugins...
56+
- Checking for available provider plugins...
57+
- Downloading plugin for provider "archive" (hashicorp/archive) 1.3.0...
58+
59+
The following providers do not have any version constraints in configuration,
60+
so the latest version was installed.
61+
62+
To prevent automatic upgrades to new major versions that may contain breaking
63+
changes, it is recommended to add version = "..." constraints to the
64+
corresponding provider blocks in configuration, with the constraint strings
65+
suggested below.
66+
67+
* provider.archive: version = "~> 1.3"
68+
69+
Terraform has been successfully initialized!
70+
71+
You may now begin working with Terraform. Try running "terraform plan" to see
72+
any changes that are required for your infrastructure. All Terraform commands
73+
should now work.
74+
75+
If you ever set or change modules or backend configuration for Terraform,
76+
rerun this command to reinitialize your working directory. If you forget, other
77+
commands will detect it and remind you to do so if necessary.
78+
```
79+
80+
Once terraform is initialized, just run `terraform apply` to generate ORM zip file.
81+
82+
```bash
83+
$ terraform apply
84+
85+
data.archive_file.generate_zip: Refreshing state...
86+
87+
Apply complete! Resources: 0 added, 0 changed, 0 destroyed.
88+
```
89+
90+
This command will package the content of `simple` folder into a zip and will store it in the `build-orm\dist` folder. You can check the content of the file by running `unzip -l dist/orm.zip`:
91+
92+
```bash
93+
$ unzip -l dist/orm.zip
94+
Archive: dist/orm.zip
95+
Length Date Time Name
96+
--------- ---------- ----- ----
97+
5324 01-01-2049 00:00 README_simple.md
98+
1140 01-01-2049 00:00 compute.tf
99+
680 01-01-2049 00:00 data_sources.tf
100+
1632 01-01-2049 00:00 image_subscription.tf
101+
1359 01-01-2049 00:00 locals.tf
102+
13540 01-01-2049 00:00 marketplace.yaml
103+
2001 01-01-2049 00:00 network.tf
104+
2478 01-01-2049 00:00 nsg.tf
105+
1092 01-01-2049 00:00 outputs.tf
106+
44 01-01-2049 00:00 scripts/example.sh
107+
4848 01-01-2049 00:00 variables.tf
108+
46 01-01-2049 00:00 versions.tf
109+
--------- -------
110+
34184 12 files
111+
```
112+
113+
### Deploy
114+
115+
1. [Login](https://console.us-ashburn-1.oraclecloud.com/resourcemanager/stacks/create) to Oracle Cloud Infrastructure to import the stack
116+
> `Home > Solutions & Platform > Resource Manager > Stacks > Create Stack`
117+
118+
2. Upload the `orm.zip` and provide a name and description for the stack
119+
![Create Stack](./images/create_orm_stack.png)
120+
121+
3. Configure the Stack. The UI will present the variables to the user dynamically, based on their selections. These are the configuration options:
122+
123+
> Compute Configuration
124+
125+
| VARIABLE | DESCRIPTION |
126+
|----------------------------|-----------------------------------------------------------------------|
127+
|COMPUTE COMPARTMENT | Compartment for Compute resources, including Marketplace subscription |
128+
|INSTANCE NAME | Compute instance name|
129+
|DNS HOSTNAME LABEL | DNS Hostname|
130+
|COMPUTE SHAPE | Compatible Compute shape|
131+
|FLEX SHAPE OCPUS | Number of OCPUs, only available for VM.Standard.E3.Flex compute shape|
132+
|AVAILABILITY DOMAIN | Availability Domain|
133+
|PUBLIC SSH KEY STRING | RSA PUBLIC SSH key string used for sign in to the OS|
134+
135+
> Virtual Cloud Network
136+
137+
| VARIABLE | DESCRIPTION |
138+
|----------------------------|-----------------------------------------------------------------------|
139+
|NETWORK COMPARTMENT | Compartment for all Virtual Cloud Nettwork resources|
140+
|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.|
141+
|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.|
142+
143+
> Virtual Cloud Network - Customize Network Configuration
144+
145+
| VARIABLE | DESCRIPTION |
146+
|----------------------------|-----------------------------------------------------------------------|
147+
|NAME | VCN Display Name|
148+
|DNS LABEL | VCN DNS LABEL|
149+
|CIDR BLOCK | The CIDR of the new Virtual Cloud Network (VCN). If you plan to peer this VCN with another VCN, the VCNs must not have overlapping CIDRs.|
150+
151+
> Simple Subnet (visible only when `Customize Network Configuration` is selected)
152+
153+
| VARIABLE | DESCRIPTION |
154+
|----------------------------|-----------------------------------------------------------------------|
155+
|SUBNET TYPE | `Public Subnet` or `Private Subnet`|
156+
|NAME | Subnet Display Name|
157+
|DNS LABEL | Subnet DNS LABEL|
158+
|CIDR BLOCK | The CIDR of the Subnet. Should not overlap with any other subnet CIDRs|
159+
|NETWORK SECURITY GROUP CONFIGURATION| `Use Recommended Configuration`: Use default configuration defined by the Terraform template. <br> `Customize Network Security Group`: Allow user to customize some basic network security group settings.|
160+
161+
> Network Security Group (visible only when `Customize Network Security Group` is selected)
162+
163+
| VARIABLE | DESCRIPTION |
164+
|----------------------------|-----------------------------------------------------------------------|
165+
|NAME | NSG Display Name|
166+
|ALLOWED INGRESS TRAFFIC (CIDR BLOCK)| WHITELISTED CIDR BLOCK for ingress traffic|
167+
|SSH PORT NUMBER | Default SSH PORT for ingress traffic|
168+
|HTTP PORT NUMBER | Default HTTP PORT for ingress traffic|
169+
|HTTPS PORT NUMBER | Default HTTPS PORT for ingress traffic|
170+
171+
> Additional Configuration Options
172+
173+
| VARIABLE | DESCRIPTION |
174+
|----------------------------|-----------------------------------------------------------------------|
175+
|TAG KEY NAME | Free-form tag key name|
176+
|TAG VALUE | Free-form tag value|
177+
178+
4. Click Next and Review the configuration.
179+
5. Click Create button to confirm and create your ORM Stack.
180+
6. On Stack Details page, you can now run `Terraform` commands to manage your infrastructure. You typically start with a plan then run apply to create and make changes to the infrastructure. More details below:
181+
182+
| TERRAFORM ACTIONS | DESCRIPTION |
183+
|----------------------------|-----------------------------------------------------------------------|
184+
|Plan | `terraform plan` is used to create an execution plan. This command is a convenient way to check the execution plan prior to make any changes to the infrastructure resources.|
185+
|Apply | `terraform apply` is used to apply the changes required to reach the desired state of the configuration described by the template.|
186+
|Destroy | `terraform destroy` is used to destroy the Terraform-managed infrastructure.|
187+
188+
## Customize for Marketplace
189+
190+
In case you wanted to make changes to this template to use a Marketplace image rather than a platform image or custom image, you need to make the following changes.
191+
192+
1. Configure Marketplace listing variables on [`variables.tf`](./variables.tf).
193+
194+
| VARIABLES | DESCRIPTION |
195+
|----------------------------|-----------------------------------------------------------------------|
196+
|mp_subscription_enabled | Enable subscription to Marketplace.|
197+
|mp_listing_id | Marketplace App Catalog Listing OCID.|
198+
|mp_listing_resource_id | Marketplace Listing Image OCID.|
199+
|mp_listing_resource_version | Marketplace Listing Package/Resource Version (Reference value)|
200+
201+
2. Modify [`compute.tf`](./compute.tf) set `source_details` to refer to `local.compute_image_id` rather than `platform_image_id`. The `local.compute_image_id` holds the logic to either refer to the marketplace image or a custom image, based on the `mp_subscription_enabled` flag.
202+
203+
```hcl
204+
resource "oci_core_instance" "simple-vm" {
205+
availability_domain = local.availability_domain
206+
compartment_id = var.compute_compartment_ocid
207+
display_name = var.vm_display_name
208+
shape = var.vm_compute_shape
209+
210+
dynamic "shape_config" {
211+
for_each = local.is_flex_shape
212+
content {
213+
ocpus = shape_config.value
214+
}
215+
}
216+
217+
218+
create_vnic_details {
219+
subnet_id = local.use_existing_network ? var.subnet_id : oci_core_subnet.simple_subnet[0].id
220+
display_name = var.subnet_display_name
221+
assign_public_ip = local.is_public_subnet
222+
hostname_label = var.hostname_label
223+
skip_source_dest_check = false
224+
nsg_ids = [oci_core_network_security_group.simple_nsg.id]
225+
}
226+
227+
source_details {
228+
source_type = "image"
229+
#use a marketplace image or custom image:
230+
source_id = local.compute_image_id
231+
}
232+
233+
```
234+
235+
2. Run your tests using the Terraform CLI or build a new package and deploy on ORM.

build-orm/install.tf

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
variable "save_to" {
2+
default = ""
3+
}
4+
5+
data "archive_file" "generate_zip" {
6+
type = "zip"
7+
output_path = (var.save_to != "" ? "${var.save_to}/orm.zip" : "${path.module}/dist/orm.zip")
8+
source_dir = "../"
9+
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"]
10+
}

0 commit comments

Comments
 (0)