Skip to content

Commit b3fceca

Browse files
authored
(mushop-basic-stack-v1.1.3) Merge pull request #181 from junior/always-free-atp-version-update
Always free (mushop-basic) stack update
2 parents 4a43939 + 1c07ed9 commit b3fceca

File tree

12 files changed

+126
-92
lines changed

12 files changed

+126
-92
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,10 @@ The repository contains the application code as well as the [Terraform][tf] code
2727

2828
The steps below guide you through deploying the application on your tenancy using the OCI Resource Manager.
2929

30-
1. Download the latest [`mushop-basic-stack-v1.1.0.zip`](../../releases/download/v1.1.0/mushop-basic-stack-v1.1.0.zip) file.
30+
1. Download the latest [`mushop-basic-stack-v1.1.3.zip`](../../releases/download/v1.1.3/mushop-basic-stack-v1.1.3.zip) file.
3131
2. [Login](https://console.us-ashburn-1.oraclecloud.com/resourcemanager/stacks/create) to Oracle Cloud Infrastructure to import the stack
3232
> `Home > Solutions & Platform > Resource Manager > Stacks > Create Stack`
33-
3. Upload the `mushop-basic-stack-v1.1.0.zip` file that was downloaded earlier, and provide a name and description for the stack
33+
3. Upload the `mushop-basic-stack-v1.1.3.zip` file that was downloaded earlier, and provide a name and description for the stack
3434
4. Configure the stack
3535
1. **Database Name** - You can choose to provide a database name (optional)
3636
2. **Node Count** - Select if you want to deploy one or two application instances.

deploy/basic/VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.1.1
1+
1.1.3

deploy/basic/terraform/atp.tf

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,17 @@
1-
# Copyright (c) 2019 Oracle and/or its affiliates. All rights reserved.
1+
# Copyright (c) 2019, 2020 Oracle and/or its affiliates. All rights reserved.
22
# Licensed under the Universal Permissive License v 1.0 as shown at http://oss.oracle.com/licenses/upl.
33
#
44

55
# creates an ATP database
66
resource "oci_database_autonomous_database" "mushop_autonomous_database" {
7-
#Required
87
admin_password = random_string.autonomous_database_wallet_password.result
98
compartment_id = var.compartment_ocid
109
cpu_core_count = 1
1110
data_storage_size_in_tbs = 1
12-
db_name = var.database_name
11+
db_name = var.autonomous_database_name
12+
db_version = var.autonomous_database_db_version
13+
display_name = "${var.autonomous_database_name}${random_id.mushop_id.dec}"
1314
freeform_tags = local.common_tags
14-
is_free_tier = true
15-
16-
#Optional
17-
db_version = "19c"
18-
db_workload = "OLTP"
19-
display_name = "${var.database_name}${random_id.mushop_id.dec}"
20-
is_auto_scaling_enabled = false
21-
is_dedicated = false
22-
is_preview_version_with_service_terms_accepted = false
23-
15+
is_free_tier = var.autonomous_database_is_free_tier
16+
license_model = var.autonomous_database_license_model
2417
}
Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,37 @@
1-
# Copyright (c) 2019 Oracle and/or its affiliates. All rights reserved.
1+
# Copyright (c) 2019, 2020 Oracle and/or its affiliates. All rights reserved.
22
# Licensed under the Universal Permissive License v 1.0 as shown at http://oss.oracle.com/licenses/upl.
33
#
44

55
# Gets a list of Availability Domains
66
data "oci_identity_availability_domains" "ADs" {
7-
87
compartment_id = var.tenancy_ocid
9-
108
}
119

12-
1310
data "oci_objectstorage_namespace" "user_namespace" {
14-
1511
compartment_id = var.compartment_ocid
16-
1712
}
1813

19-
2014
resource "random_string" "autonomous_database_wallet_password" {
21-
2215
length = 16
2316
special = true
2417
min_upper = 3
2518
min_lower = 3
2619
min_numeric = 3
2720
min_special = 3
2821
override_special = "{}#^*<>[]%~"
29-
3022
}
3123

3224
resource "random_id" "mushop_id" {
3325
byte_length = 2
3426
}
3527

3628
data "oci_database_autonomous_database_wallet" "autonomous_database_wallet" {
37-
3829
autonomous_database_id = oci_database_autonomous_database.mushop_autonomous_database.id
3930
password = random_string.autonomous_database_wallet_password.result
4031
base64_encode_content = "true"
41-
4232
}
4333

4434
data "oci_limits_services" "test_services" {
45-
#Required
4635
compartment_id = var.tenancy_ocid
4736

4837
filter {
@@ -60,3 +49,13 @@ data "oci_limits_limit_values" "test_limit_values" {
6049
name = "vm-standard-e2-1-micro-count"
6150
scope_type = "AD"
6251
}
52+
53+
# Gets a list of supported images based on the shape, operating_system and operating_system_version provided
54+
data "oci_core_images" "compute_images" {
55+
compartment_id = var.compartment_ocid
56+
operating_system = var.image_operating_system
57+
operating_system_version = var.image_operating_system_version
58+
shape = var.instance_shape
59+
sort_by = "TIMECREATED"
60+
sort_order = "DESC"
61+
}

deploy/basic/terraform/loadbalancer.tf

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
# Copyright (c) 2019 Oracle and/or its affiliates. All rights reserved.
1+
# Copyright (c) 2019, 2020 Oracle and/or its affiliates. All rights reserved.
22
# Licensed under the Universal Permissive License v 1.0 as shown at http://oss.oracle.com/licenses/upl.
33
#
44

55
resource "oci_load_balancer_load_balancer" "mushop_lb" {
66

77
compartment_id = var.compartment_ocid
88
display_name = "mushop-${random_id.mushop_id.dec}"
9-
shape = local.lb_shape
9+
shape = var.lb_shape
1010
subnet_ids = [oci_core_subnet.mushopLBSubnet.id]
1111
is_private = "false"
1212
freeform_tags = local.common_tags
@@ -34,7 +34,7 @@ resource "oci_load_balancer_backend" "mushop-be" {
3434
count = var.num_nodes
3535
load_balancer_id = oci_load_balancer_load_balancer.mushop_lb.id
3636
backendset_name = oci_load_balancer_backend_set.mushop-bes.name
37-
ip_address = element(oci_core_instance.app-instance.*.private_ip, count.index)
37+
ip_address = element(oci_core_instance.app_instance.*.private_ip, count.index)
3838
port = 80
3939
backup = false
4040
drain = false

deploy/basic/terraform/main.tf

Lines changed: 15 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
1-
# Copyright (c) 2019 Oracle and/or its affiliates. All rights reserved.
1+
# Copyright (c) 2019, 2020 Oracle and/or its affiliates. All rights reserved.
22
# Licensed under the Universal Permissive License v 1.0 as shown at http://oss.oracle.com/licenses/upl.
33
#
44

55
terraform {
6-
required_version = ">= 0.12.0"
6+
required_version = ">= 0.12.16"
77
}
88
data "template_file" "mushop" {
99
template = "${file("./scripts/node.sh")}"
1010
}
1111

12-
resource "oci_core_instance" "app-instance" {
12+
resource "oci_core_instance" "app_instance" {
1313
count = var.num_nodes
1414
availability_domain = local.availability_domain[0]
1515
compartment_id = var.compartment_ocid
1616
display_name = "mushop-${random_id.mushop_id.dec}-${count.index}"
17-
shape = local.instance_shape
17+
shape = var.instance_shape
1818
freeform_tags = local.common_tags
1919

2020
create_vnic_details {
@@ -26,11 +26,11 @@ resource "oci_core_instance" "app-instance" {
2626

2727
source_details {
2828
source_type = "image"
29-
source_id = local.images[var.region]
29+
source_id = lookup(data.oci_core_images.compute_images.images[0], "id")
3030
}
3131

3232
metadata = {
33-
ssh_authorized_keys = var.ssh_public_key
33+
ssh_authorized_keys = var.generate_public_ssh_key ? tls_private_key.compute_ssh_key.public_key_openssh : var.public_ssh_key
3434
user_data = base64encode(data.template_file.mushop.rendered)
3535
db_name = oci_database_autonomous_database.mushop_autonomous_database.db_name
3636
atp_pw = random_string.autonomous_database_wallet_password.result
@@ -42,39 +42,20 @@ resource "oci_core_instance" "app-instance" {
4242
assets_par = "https://objectstorage.${var.region}.oraclecloud.com${oci_objectstorage_preauthrequest.mushop_media_preauth.access_uri}"
4343
assets_url = "https://objectstorage.${var.region}.oraclecloud.com/n/${oci_objectstorage_bucket.mushop_media.namespace}/b/${oci_objectstorage_bucket.mushop_media.name}/o/"
4444
}
45-
46-
}
47-
48-
// https://docs.cloud.oracle.com/iaas/images/image/4e74174f-0b44-4447-bb09-dc05b23cf3ee/
49-
// Oracle-Linux-7.7-2019.08.28-0
50-
locals {
51-
images = {
52-
ap-mumbai-1 = "ocid1.image.oc1.ap-mumbai-1.aaaaaaaanqnm77gq2dpmc2aih2ddlwlahuv2qwmokufb7zbi52v67pzkzycq"
53-
ap-seoul-1 = "ocid1.image.oc1.ap-seoul-1.aaaaaaaav3lc5w7cvz5yr6hpjdubxupjeduzd5xvaroyhjg6vwqzsdvgus6q"
54-
ap-sydney-1 = "ocid1.image.oc1.ap-sydney-1.aaaaaaaagtfumjxhosxrkgfci3dgwvsmp35ip5nbhy2rypxfh3rwtqsozkcq"
55-
ap-tokyo-1 = "ocid1.image.oc1.ap-tokyo-1.aaaaaaaajousbvplzyrh727e3d4sb6bam5d2fomwhbtzatoun5sqcuvvfjnq"
56-
ca-toronto-1 = "ocid1.image.oc1.ca-toronto-1.aaaaaaaavr35ze44lkflxffkhmt4xyamkfjpbjhsm5awxjwlnp3gpx7h7fgq"
57-
eu-frankfurt-1 = "ocid1.image.oc1.eu-frankfurt-1.aaaaaaaa7gj6uot6tz6t34qjzvkldxtwse7gr5m7xvnh6xfm53ddxp3w37ja"
58-
eu-zurich-1 = "ocid1.image.oc1.eu-zurich-1.aaaaaaaasl3mlhvgzhfglqqkwdbppmmgomkz6iyi42wjkceldqcpecg7jzgq"
59-
sa-saopaulo-1 = "ocid1.image.oc1.sa-saopaulo-1.aaaaaaaawamujpmwxbjgrfeb66zpew5sgz4bimzb4wgcwhqdjyct53bucvoq"
60-
uk-london-1 = "ocid1.image.oc1.uk-london-1.aaaaaaaa6trfxqtp5ib7yfgj725js3o6agntmv6vckarebsmacrhdxqojeya"
61-
us-ashburn-1 = "ocid1.image.oc1.iad.aaaaaaaayuihpsm2nfkxztdkottbjtfjqhgod7hfuirt2rqlewxrmdlgg75q"
62-
us-langley-1 = "ocid1.image.oc2.us-langley-1.aaaaaaaaazlspcasnl4ibjwu7g5ukiaqjp6xcbk5lqgtdsazd7v6evbkwxcq"
63-
us-luke-1 = "ocid1.image.oc2.us-luke-1.aaaaaaaa73qnm5jktrwmkutf6iaigib4msieymk2s5r5iweq5yvqublgcx5q"
64-
us-phoenix-1 = "ocid1.image.oc1.phx.aaaaaaaadtmpmfm77czi5ghi5zh7uvkguu6dsecsg7kuo3eigc5663und4za"
65-
}
66-
67-
68-
instance_shape = "VM.Standard.E2.1.Micro"
6945

70-
availability_domain = [for limit in data.oci_limits_limit_values.test_limit_values : limit.limit_values[0].availability_domain if limit.limit_values[0].value > 0 ]
71-
72-
num_nodes = 2
46+
}
7347

74-
lb_shape = "10Mbps-Micro"
48+
locals {
49+
availability_domain = [for limit in data.oci_limits_limit_values.test_limit_values : limit.limit_values[0].availability_domain if limit.limit_values[0].value > 0]
7550

7651
common_tags = {
7752
Reference = "Created by OCI QuickStart for Free Tier"
7853
}
7954

8055
}
56+
57+
# Generate ssh keys to access Compute Nodes, if generate_public_ssh_key=true, applies to the Compute
58+
resource "tls_private_key" "compute_ssh_key" {
59+
algorithm = "RSA"
60+
rsa_bits = 2048
61+
}

deploy/basic/terraform/outputs.tf

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,19 @@
1-
# Copyright (c) 2019 Oracle and/or its affiliates. All rights reserved.
1+
# Copyright (c) 2019, 2020 Oracle and/or its affiliates. All rights reserved.
22
# Licensed under the Universal Permissive License v 1.0 as shown at http://oss.oracle.com/licenses/upl.
33
#
44

55
output "lb_public_url" {
6-
value = format("http://%s", lookup(oci_load_balancer_load_balancer.mushop_lb.ip_address_details[0],"ip_address"))
6+
value = format("http://%s", lookup(oci_load_balancer_load_balancer.mushop_lb.ip_address_details[0], "ip_address"))
77
}
88

99
output "autonomous_database_password" {
1010
value = random_string.autonomous_database_wallet_password.result
1111
}
1212

13+
output "generated_public_ssh_key" {
14+
value = var.generate_public_ssh_key ? tls_private_key.compute_ssh_key.public_key_openssh : "No Keys Auto Generated"
15+
}
16+
1317
output "dev" {
1418
value = "Made with \u2764 by Oracle A-Team"
1519
}

deploy/basic/terraform/provider.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
#
44

55
provider "oci" {
6-
tenancy_ocid = var.tenancy_ocid
6+
tenancy_ocid = var.tenancy_ocid
77
# user_ocid = "${var.user_ocid}"
88
# fingerprint = "${var.fingerprint}"
99
# private_key_path = "${var.private_key_path}"

deploy/basic/terraform/schema.yaml

Lines changed: 40 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (c) 2019 Oracle and/or its affiliates. All rights reserved.
1+
# Copyright (c) 2019, 2020 Oracle and/or its affiliates. All rights reserved.
22
# Licensed under the Universal Permissive License v 1.0 as shown at http://oss.oracle.com/licenses/upl.
33
#
44

@@ -9,7 +9,7 @@ version: "20190304"
99
locale: "en"
1010

1111
groupings:
12-
- title: "General Configuration"
12+
- title: "Basic Hidden"
1313
visible: false
1414
variables:
1515
- compartment_ocid
@@ -18,12 +18,26 @@ groupings:
1818

1919
- title: "General Configuration"
2020
variables:
21-
- database_name
21+
- autonomous_database_name
2222
- num_nodes
2323

2424
- title: "Optional Configuration"
2525
variables:
26-
- ssh_public_key
26+
- generate_public_ssh_key
27+
- public_ssh_key
28+
29+
- title: "Extras Hidden"
30+
variables:
31+
- user_ocid
32+
- fingerprint
33+
- autonomous_database_db_version
34+
- autonomous_database_license_model
35+
- autonomous_database_is_free_tier
36+
- instance_shape
37+
- lb_shape
38+
- image_operating_system
39+
- image_operating_system_version
40+
visible: false
2741

2842
variables:
2943
compartment_ocid:
@@ -43,32 +57,41 @@ variables:
4357
description: "Choose the number of compute instances to deploy"
4458
required: true
4559

46-
database_name:
60+
autonomous_database_name:
4761
type: string
4862
required: true
4963
title: "Database Name"
5064
description: "The name for the Autonomous Database instance"
51-
default: "MuShopDB"
5265
minLength: 1
5366
maxLength: 14
5467
pattern: "^[a-zA-Z][a-zA-Z0-9]+$"
5568

56-
ssh_public_key:
69+
generate_public_ssh_key:
70+
type: boolean
71+
title: "Auto generate public ssh key?"
72+
description: "Auto generate a public key and assign to the compute instances"
73+
required: true
74+
75+
public_ssh_key:
5776
type: oci:core:ssh:publickey
5877
required: false
5978
title: "SSH Public Key"
6079
description: "The public SSH key for the key-pair that you want to use, if you wish to login to the instances over SSH"
6180
additionalProps:
6281
allowMultiple: true
6382
pattern: "((^(ssh-rsa AAAAB3NzaC1yc2|ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNT|ecdsa-sha2-nistp384 AAAAE2VjZHNhLXNoYTItbmlzdHAzODQAAAAIbmlzdHAzOD|ecdsa-sha2-nistp521 AAAAE2VjZHNhLXNoYTItbmlzdHA1MjEAAAAIbmlzdHA1Mj|ssh-ed25519 AAAAC3NzaC1lZDI1NTE5|ssh-dss AAAAB3NzaC1kc3)[0-9A-Za-z+\/]+[=]{0,3})( [^,]*)?)(,((ssh-rsa AAAAB3NzaC1yc2|ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNT|ecdsa-sha2-nistp384 AAAAE2VjZHNhLXNoYTItbmlzdHAzODQAAAAIbmlzdHAzOD|ecdsa-sha2-nistp521 AAAAE2VjZHNhLXNoYTItbmlzdHA1MjEAAAAIbmlzdHA1Mj|ssh-ed25519 AAAAC3NzaC1lZDI1NTE5|ssh-dss AAAAB3NzaC1kc3)[0-9A-Za-z+\/]+[=]{0,3})( [^,]*)?)*$"
83+
visible:
84+
not:
85+
- generate_public_ssh_key
6486

6587
outputGroups:
6688
- title: "MuShop App details"
6789
outputs:
68-
- ${lb_public_url}
69-
- ${autonomous_database_password}
70-
- ${dev}
71-
- ${comments}
90+
- lb_public_url
91+
- autonomous_database_password
92+
- generated_public_ssh_key
93+
- dev
94+
- comments
7295

7396
outputs:
7497
lb_public_url:
@@ -82,6 +105,12 @@ outputs:
82105
displayText: "Autonomous Database Password"
83106
visible: true
84107

108+
generated_public_ssh_key:
109+
type: string
110+
title: "Generated Public SSH key"
111+
displayText: "Generated public ssh key to access compute nodes"
112+
visible: true
113+
85114
dev:
86115
type: string
87116
title: "Message"

deploy/basic/terraform/security-lists.tf

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ resource "oci_core_security_list" "mushopLBSecurityList" {
99
freeform_tags = local.common_tags
1010

1111
egress_security_rules {
12-
protocol = "6"
13-
destination = "0.0.0.0/0"
14-
}
12+
protocol = "6"
13+
destination = "0.0.0.0/0"
14+
}
1515

1616
ingress_security_rules {
1717
protocol = "6"

0 commit comments

Comments
 (0)