├── examples
├── opc
│ ├── bastion-host-provisioning
│ │ ├── .gitignore
│ │ ├── README.md
│ │ ├── modules
│ │ │ └── bastion
│ │ │ │ ├── outputs.tf
│ │ │ │ ├── variables.tf
│ │ │ │ ├── bastion.tf
│ │ │ │ └── README.md
│ │ └── main.tf
│ ├── README.md
│ ├── loadbalancer-classic
│ │ ├── network
│ │ │ ├── variables.tf
│ │ │ ├── main.tf
│ │ │ └── output.tf
│ │ ├── webapp
│ │ │ ├── outputs.tf
│ │ │ ├── variables.tf
│ │ │ └── main.tf
│ │ ├── load_balancer
│ │ │ ├── outputs.tf
│ │ │ ├── variables.tf
│ │ │ └── main.tf
│ │ ├── variables.tf
│ │ ├── certificates
│ │ │ ├── outputs.tf
│ │ │ ├── variables.tf
│ │ │ └── main.tf
│ │ ├── server_pool
│ │ │ ├── variables.tf
│ │ │ ├── outputs.tf
│ │ │ └── main.tf
│ │ ├── security_rules
│ │ │ ├── all_egress
│ │ │ │ └── main.tf
│ │ │ └── main.tf
│ │ ├── outputs.tf
│ │ ├── README.md
│ │ └── main.tf
│ ├── instance-from-storage-snapshot
│ │ ├── variables.tf
│ │ ├── main.tf
│ │ └── README.md
│ ├── instance-from-colocated-snapshot
│ │ ├── variables.tf
│ │ ├── main.tf
│ │ └── README.md
│ ├── instance-with-persistent-boot-volume
│ │ ├── variables.tf
│ │ ├── README.md
│ │ └── main.tf
│ ├── instance-with-public-ip-on-ip-network-interface
│ │ ├── variables.tf
│ │ ├── README.md
│ │ └── main.tf
│ ├── instance-with-ssh
│ │ ├── variables.tf
│ │ ├── main.tf
│ │ └── README.md
│ ├── windows-instance-with-rdp
│ │ ├── variables.tf
│ │ ├── windows-server.tf
│ │ └── README.md
│ ├── marketplace-bitnami-elk
│ │ ├── access-log.conf
│ │ ├── main.tf
│ │ └── README.md
│ ├── ipnetworks
│ │ ├── variables.tf
│ │ ├── modules
│ │ │ └── install_ssh_keys
│ │ │ │ └── main.tf
│ │ ├── README.md
│ │ └── main.tf
│ └── orchestrated-instance
│ │ └── main.tf
├── oraclepaas
│ ├── accs-php-app
│ │ ├── php-app
│ │ │ ├── index.php
│ │ │ └── manifest.json
│ │ ├── README.md
│ │ └── main.tf
│ ├── accs-go-app
│ │ ├── go-service
│ │ │ ├── manifest.json
│ │ │ ├── start.sh
│ │ │ └── rest-service.go
│ │ ├── README.md
│ │ └── main.tf
│ ├── accs-python-app
│ │ ├── python-app
│ │ │ ├── manifest.json
│ │ │ └── app.py
│ │ ├── README.md
│ │ └── main.tf
│ ├── accs-nodejs-app
│ │ ├── node-app
│ │ │ ├── manifest.json
│ │ │ └── myapp.js
│ │ ├── README.md
│ │ └── main.tf
│ ├── accs-nodejs-app-from-git-repo
│ │ ├── manifest.json
│ │ ├── main.tf
│ │ └── README.md
│ ├── full-db-jcs-oci
│ │ ├── variables.tf
│ │ ├── providers.tf
│ │ ├── README.md
│ │ ├── identity.tf
│ │ └── main.tf
│ ├── dbcs-instance-classic
│ │ ├── README.md
│ │ └── main.tf
│ ├── full-dbcs-jcs-otd-classic
│ │ ├── README.md
│ │ └── main.tf
│ ├── jcs-instance-classic
│ │ ├── README.md
│ │ └── main.tf
│ ├── mysqlcs-instance-classic
│ │ ├── README.md
│ │ └── main.tf
│ ├── accs-java-app
│ │ ├── README.md
│ │ └── main.tf
│ ├── accs-ruby-app
│ │ ├── README.md
│ │ └── main.tf
│ ├── mysqlcs-instance-oci
│ │ ├── README.md
│ │ └── main.tf
│ ├── dbcs-instance-oci
│ │ ├── README.md
│ │ ├── vcn.tf
│ │ └── main.tf
│ └── jcs-instance-oci
│ │ └── main.tf
├── oci
│ └── connect_vcns_using_multiple_vnics
│ │ ├── images
│ │ └── connect_vcns_using_multiple_vnics.png
│ │ ├── provider.tf
│ │ ├── user_data.tpl
│ │ ├── env-vars
│ │ ├── output.tf
│ │ ├── variables.tf
│ │ ├── datasources.tf
│ │ ├── bridge.tf
│ │ ├── README.md
│ │ ├── vcn2.tf
│ │ └── vcn1.tf
└── README.md
├── .gitignore
├── README.md
└── LICENSE.txt
/examples/opc/bastion-host-provisioning/.gitignore:
--------------------------------------------------------------------------------
1 | *id_rsa
2 | *id_rsa.pub
3 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | terraform.tfstate
2 | terraform.tfstate.backup
3 | terraform.tfvars
4 | .terraform
5 | id_rsa
6 | id_rsa.pub
7 | .DS_Store
8 | *.zip
9 | *.iml
10 | .idea
11 |
--------------------------------------------------------------------------------
/examples/oraclepaas/accs-php-app/php-app/index.php:
--------------------------------------------------------------------------------
1 | Welcome to my page";
3 | echo "
Testing PHP on Oracle Application Container Cloud Service.
";
4 | ?>
5 |
--------------------------------------------------------------------------------
/examples/oraclepaas/accs-php-app/php-app/manifest.json:
--------------------------------------------------------------------------------
1 | {
2 | "runtime":{
3 | "majorVersion":"7.1"
4 | },
5 | "release": {},
6 | "notes": "Hello World PHP application"
7 | }
8 |
--------------------------------------------------------------------------------
/examples/oraclepaas/accs-go-app/go-service/manifest.json:
--------------------------------------------------------------------------------
1 | {
2 | "runtime": {
3 | "majorVersion": "1.8.3"
4 | },
5 | "command": "sh ./start.sh",
6 | "notes": "Go Application Sample"
7 | }
8 |
--------------------------------------------------------------------------------
/examples/oraclepaas/accs-python-app/python-app/manifest.json:
--------------------------------------------------------------------------------
1 | {
2 | "runtime": {
3 | "majorVersion": "3.6.0"
4 | },
5 | "command": "python app.py",
6 | "notes": "Simple REST Service"
7 | }
8 |
--------------------------------------------------------------------------------
/examples/oraclepaas/accs-nodejs-app/node-app/manifest.json:
--------------------------------------------------------------------------------
1 | {
2 | "runtime":{
3 | "majorVersion":"6"
4 | },
5 | "command": "node myapp.js",
6 | "release": {},
7 | "notes": "Hello World application"
8 | }
9 |
--------------------------------------------------------------------------------
/examples/oci/connect_vcns_using_multiple_vnics/images/connect_vcns_using_multiple_vnics.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oracle/terraform-examples/HEAD/examples/oci/connect_vcns_using_multiple_vnics/images/connect_vcns_using_multiple_vnics.png
--------------------------------------------------------------------------------
/examples/oraclepaas/accs-nodejs-app-from-git-repo/manifest.json:
--------------------------------------------------------------------------------
1 | {
2 | "runtime":{
3 | "majorVersion":"8"
4 | },
5 | "command": "node server.js",
6 | "release": {},
7 | "notes": "",
8 | "type":"web",
9 | "home": "/employees"
10 | }
11 |
--------------------------------------------------------------------------------
/examples/opc/README.md:
--------------------------------------------------------------------------------
1 | Terraform examples for the built-in Oracle OPC Provider
2 | =======================================================
3 |
4 | These examples work with the built-in Oracle Public Cloud `opc` provider included in Terraform release 0.9.4 and above.
5 |
--------------------------------------------------------------------------------
/examples/opc/loadbalancer-classic/network/variables.tf:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved.
2 | // Licensed under the Universal Permissive License v 1.0 as shown at http://oss.oracle.com/licenses/upl.
3 |
4 | variable "name" {}
5 | variable "cidr" {}
6 |
--------------------------------------------------------------------------------
/examples/opc/loadbalancer-classic/webapp/outputs.tf:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved.
2 | // Licensed under the Universal Permissive License v 1.0 as shown at http://oss.oracle.com/licenses/upl.
3 |
4 | output "port" {
5 | value = "${local.web_app_port}"
6 | }
7 |
--------------------------------------------------------------------------------
/examples/oraclepaas/accs-go-app/go-service/start.sh:
--------------------------------------------------------------------------------
1 | # Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved.
2 | # Licensed under the Universal Permissive License v 1.0 as shown at http://oss.oracle.com/licenses/upl.
3 | go get github.com/ant0ine/go-json-rest/rest
4 | go run rest-service.go
5 |
--------------------------------------------------------------------------------
/examples/README.md:
--------------------------------------------------------------------------------
1 | Examples
2 | ========
3 |
4 | - [`opc`](./opc) examples for the Oracle Cloud Infrastructure Classic `opc` provider
5 | - [`oraclepaas`](./oraclepaas) examples for the Oracle Cloud Platform `oraclepaas` provider
6 |
7 |
8 | - [`oci`](./oci) examples for the Oracle Cloud Infrastructure `oci` provider
9 |
--------------------------------------------------------------------------------
/examples/opc/instance-from-storage-snapshot/variables.tf:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved.
2 | // Licensed under the Universal Permissive License v 1.0 as shown at http://oss.oracle.com/licenses/upl.
3 |
4 | variable user {}
5 | variable password {}
6 | variable domain {}
7 | variable endpoint {}
8 |
--------------------------------------------------------------------------------
/examples/opc/instance-from-colocated-snapshot/variables.tf:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved.
2 | // Licensed under the Universal Permissive License v 1.0 as shown at http://oss.oracle.com/licenses/upl.
3 |
4 | variable user {}
5 | variable password {}
6 | variable domain {}
7 | variable endpoint {}
8 |
--------------------------------------------------------------------------------
/examples/opc/instance-with-persistent-boot-volume/variables.tf:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2017, 2019, Oracle and/or its affiliates. All rights reserved.
2 | // Licensed under the Universal Permissive License v 1.0 as shown at http://oss.oracle.com/licenses/upl.
3 |
4 | variable user {}
5 | variable password {}
6 | variable domain {}
7 | variable endpoint {}
8 |
--------------------------------------------------------------------------------
/examples/opc/loadbalancer-classic/load_balancer/outputs.tf:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved.
2 | // Licensed under the Universal Permissive License v 1.0 as shown at http://oss.oracle.com/licenses/upl.
3 |
4 | output "canonical_host_name" {
5 | value = "${opc_lbaas_load_balancer.lb1.canonical_host_name}"
6 | }
7 |
--------------------------------------------------------------------------------
/examples/opc/loadbalancer-classic/network/main.tf:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved.
2 | // Licensed under the Universal Permissive License v 1.0 as shown at http://oss.oracle.com/licenses/upl.
3 |
4 | resource "opc_compute_ip_network" "ipnetwork" {
5 | name = "${var.name}"
6 | ip_address_prefix = "${var.cidr}"
7 | }
8 |
--------------------------------------------------------------------------------
/examples/opc/loadbalancer-classic/network/output.tf:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved.
2 | // Licensed under the Universal Permissive License v 1.0 as shown at http://oss.oracle.com/licenses/upl.
3 |
4 | output "ipnetwork" {
5 | value = "${opc_compute_ip_network.ipnetwork.name}"
6 | }
7 |
8 | output "cidr" {
9 | value = "${opc_compute_ip_network.ipnetwork.ip_address_prefix}"
10 | }
11 |
--------------------------------------------------------------------------------
/examples/opc/instance-with-public-ip-on-ip-network-interface/variables.tf:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved.
2 | // Licensed under the Universal Permissive License v 1.0 as shown at http://oss.oracle.com/licenses/upl.
3 |
4 | variable "user" {}
5 | variable "password" {}
6 | variable "domain" {}
7 | variable "endpoint" {}
8 |
9 | variable "public_ssh_key" {
10 | default = "~/.ssh/id_rsa.pub"
11 | }
12 |
--------------------------------------------------------------------------------
/examples/opc/instance-with-ssh/variables.tf:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2017, 2019, Oracle and/or its affiliates. All rights reserved.
2 | // Licensed under the Universal Permissive License v 1.0 as shown at http://oss.oracle.com/licenses/upl.
3 |
4 | variable user {}
5 | variable password {}
6 | variable domain {}
7 | variable endpoint {}
8 |
9 | variable ssh_public_key_file {
10 | description = "ssh public key"
11 | default = "./id_rsa.pub"
12 | }
13 |
--------------------------------------------------------------------------------
/examples/opc/loadbalancer-classic/variables.tf:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved.
2 | // Licensed under the Universal Permissive License v 1.0 as shown at http://oss.oracle.com/licenses/upl.
3 |
4 | variable "user" {}
5 | variable "password" {}
6 | variable "domain" {}
7 | variable "endpoint" {}
8 | variable "lbaas_endpoint" {}
9 | variable "region" {}
10 |
11 | variable "dns_name" {
12 | default = "mywebapp.example.com"
13 | }
14 |
--------------------------------------------------------------------------------
/examples/opc/windows-instance-with-rdp/variables.tf:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2017, 2019, Oracle and/or its affiliates. All rights reserved.
2 | // Licensed under the Universal Permissive License v 1.0 as shown at http://oss.oracle.com/licenses/upl.
3 |
4 | variable user {}
5 | variable password {}
6 | variable domain {}
7 | variable endpoint {}
8 |
9 | variable administrator_password {
10 | description = "initial administrator password to the set when launching the windows instance"
11 | }
12 |
--------------------------------------------------------------------------------
/examples/opc/loadbalancer-classic/webapp/variables.tf:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved.
2 | // Licensed under the Universal Permissive License v 1.0 as shown at http://oss.oracle.com/licenses/upl.
3 |
4 | variable "name" {}
5 |
6 | variable "servers" {
7 | type = "list"
8 | }
9 |
10 | variable "server_acl" {}
11 | variable "server_count" {}
12 | variable "ssh_user" {}
13 | variable "private_ssh_key_file" {}
14 | variable "public_ssh_key_file" {}
15 |
--------------------------------------------------------------------------------
/examples/opc/loadbalancer-classic/certificates/outputs.tf:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved.
2 | // Licensed under the Universal Permissive License v 1.0 as shown at http://oss.oracle.com/licenses/upl.
3 |
4 | output "ca_cert_pem" {
5 | value = "${tls_self_signed_cert.ca.cert_pem}"
6 | }
7 |
8 | output "cert_pem" {
9 | value = "${tls_locally_signed_cert.example.cert_pem}"
10 | }
11 |
12 | output "private_key_pem" {
13 | value = "${tls_private_key.example.private_key_pem}"
14 | }
15 |
--------------------------------------------------------------------------------
/examples/opc/marketplace-bitnami-elk/access-log.conf:
--------------------------------------------------------------------------------
1 | input {
2 | file {
3 | path => "/opt/bitnami/apache2/logs/access_log"
4 | start_position => beginning
5 | }
6 | }
7 |
8 | filter {
9 | grok {
10 | match => { "message" => "%{COMBINEDAPACHELOG}" }
11 | }
12 | date {
13 | match => [ "timestamp" , "dd/MMM/yyyy:HH:mm:ss Z" ]
14 | }
15 | }
16 |
17 | output {
18 | elasticsearch {
19 | hosts => [ "127.0.0.1:9200" ]
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/examples/opc/loadbalancer-classic/load_balancer/variables.tf:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved.
2 | // Licensed under the Universal Permissive License v 1.0 as shown at http://oss.oracle.com/licenses/upl.
3 |
4 | variable "name" {}
5 | variable "region" {}
6 | variable "ip_network" {}
7 | variable "vnic_set" {}
8 |
9 | variable "servers" {
10 | type = "list"
11 | }
12 |
13 | variable "dns_name" {}
14 |
15 | variable "cert_pem" {}
16 | variable "ca_cert_pem" {}
17 | variable "private_key_pem" {}
18 |
--------------------------------------------------------------------------------
/examples/opc/loadbalancer-classic/server_pool/variables.tf:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved.
2 | // Licensed under the Universal Permissive License v 1.0 as shown at http://oss.oracle.com/licenses/upl.
3 |
4 | variable "public_ssh_key" {}
5 |
6 | variable "server_count" {
7 | default = 1
8 | }
9 |
10 | variable "name" {}
11 |
12 | variable "shape" {
13 | default = "oc3"
14 | }
15 |
16 | variable "image_list" {
17 | default = "/oracle/public/OL_7.2_UEKR4_x86_64"
18 | }
19 |
20 | variable "ip_network" {}
21 |
--------------------------------------------------------------------------------
/examples/opc/loadbalancer-classic/certificates/variables.tf:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved.
2 | // Licensed under the Universal Permissive License v 1.0 as shown at http://oss.oracle.com/licenses/upl.
3 |
4 | variable "dns_names" {
5 | type = "list"
6 | }
7 |
8 | variable "organization" {}
9 | variable "common_name" {}
10 | variable "province" {}
11 | variable "country" {}
12 |
13 | variable "validity_period_hours" {
14 | default = "8760" // 365 days
15 | }
16 |
17 | variable "early_renewal_hours" {
18 | default = "720" // 30 days
19 | }
20 |
--------------------------------------------------------------------------------
/examples/oraclepaas/accs-go-app/go-service/rest-service.go:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved.
2 |
3 | package main
4 |
5 | import (
6 | "log"
7 | "net/http"
8 | "os"
9 |
10 | "github.com/ant0ine/go-json-rest/rest"
11 | )
12 |
13 | func main() {
14 | api := rest.NewApi()
15 | api.Use(rest.DefaultDevStack...)
16 | api.SetApp(rest.AppSimple(func(w rest.ResponseWriter, r *rest.Request) {
17 | w.WriteJson(map[string]string{"Body": "Hello World!"})
18 | }))
19 | log.Fatal(http.ListenAndServe(":"+os.Getenv("PORT"), api.MakeHandler()))
20 | }
21 |
--------------------------------------------------------------------------------
/examples/oraclepaas/accs-nodejs-app/node-app/myapp.js:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved.
2 | // Licensed under the Universal Permissive License v 1.0 as shown at http://oss.oracle.com/licenses/upl.
3 | var http = require('http');
4 | // Read Environment Parameters
5 | var port = Number(process.env.PORT || 8080);
6 | var greeting = process.env.GREETING || 'Hello World!';
7 | var server = http.createServer(function (request, response) {
8 | response.writeHead(200, {"Content-Type": "text/plain"});
9 | response.end(greeting + "\n");
10 | });
11 | server.listen(port);
12 |
--------------------------------------------------------------------------------
/examples/oci/connect_vcns_using_multiple_vnics/provider.tf:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved
2 | // Licensed under the Universal Permissive License v 1.0 as shown at http://oss.oracle.com/licenses/upl.
3 | provider "oci" {
4 | version = ">= 3.14"
5 | tenancy_ocid = "${var.tenancy_ocid}"
6 | user_ocid = "${var.user_ocid}"
7 | fingerprint = "${var.fingerprint}"
8 | private_key_path = "${var.private_key_path}"
9 | private_key_password = "${var.private_key_password}"
10 | region = "${var.region}"
11 | }
12 |
--------------------------------------------------------------------------------
/examples/oci/connect_vcns_using_multiple_vnics/user_data.tpl:
--------------------------------------------------------------------------------
1 | #cloud-config
2 |
3 | write_files:
4 | # Create file to be used when enabling ip forwarding
5 | - path: /etc/sysctl.d/98-ip-forward.conf
6 | content: |
7 | net.ipv4.ip_forward = 1
8 |
9 | runcmd:
10 | # Run firewall commands to enable masquerading and port forwarding
11 | # Enable ip forwarding by setting sysctl kernel parameter
12 | - firewall-offline-cmd --direct --add-rule ipv4 filter FORWARD 0 -i ens3 -j ACCEPT
13 | - firewall-offline-cmd --direct --add-rule ipv4 filter FORWARD 0 -i ens4 -j ACCEPT
14 | - /bin/systemctl restart firewalld
15 | - sysctl -p /etc/sysctl.d/98-ip-forward.conf
16 |
17 |
--------------------------------------------------------------------------------
/examples/opc/loadbalancer-classic/security_rules/all_egress/main.tf:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved.
2 | // Licensed under the Universal Permissive License v 1.0 as shown at http://oss.oracle.com/licenses/upl.
3 |
4 | variable "name" {}
5 | variable "acl" {}
6 |
7 | resource "opc_compute_security_rule" "egress" {
8 | name = "${var.name}-all-egress"
9 | flow_direction = "egress"
10 | acl = "${var.acl}"
11 | security_protocols = ["${opc_compute_security_protocol.all.name}"]
12 | }
13 |
14 | resource "opc_compute_security_protocol" "all" {
15 | name = "${var.name}-all"
16 | ip_protocol = "all"
17 | }
18 |
--------------------------------------------------------------------------------
/examples/opc/bastion-host-provisioning/README.md:
--------------------------------------------------------------------------------
1 | Bastion Module and Provisioning through a Bastion Host
2 | ======================================================
3 |
4 | This example demonstrates
5 |
6 | 1. a sub module for creating a bastion host instance with public ip and private ip network connection, enabled for ssh
7 | 2. provisioning to the private instance through the bastion host
8 | 3. separate ssh key pairs for the bastion host and private instance
9 |
10 | Prerequisites
11 | -------------
12 |
13 | Create separate ssh key pairs for the bastion host and the private instances
14 |
15 | ```
16 | $ ssh-keygen -f ./bastion_id_rsa -N "" -q
17 |
18 | $ ssh-keygen -f ./instance_id_rsa -N "" -q
19 | ```
20 |
--------------------------------------------------------------------------------
/examples/opc/ipnetworks/variables.tf:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2017, 2019, Oracle and/or its affiliates. All rights reserved.
2 | // Licensed under the Universal Permissive License v 1.0 as shown at http://oss.oracle.com/licenses/upl.
3 |
4 | variable user {}
5 | variable password {}
6 | variable domain {}
7 | variable endpoint {}
8 |
9 | variable ssh_user {
10 | description = "User account for ssh access to the image"
11 | default = "opc"
12 | }
13 |
14 | variable ssh_private_key {
15 | description = "File location of the ssh private key"
16 | default = "./id_rsa"
17 | }
18 |
19 | variable ssh_public_key {
20 | description = "File location of the ssh public key"
21 | default = "./id_rsa.pub"
22 | }
23 |
--------------------------------------------------------------------------------
/examples/opc/loadbalancer-classic/server_pool/outputs.tf:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved.
2 | // Licensed under the Universal Permissive License v 1.0 as shown at http://oss.oracle.com/licenses/upl.
3 |
4 | output "public_ip_addresses" {
5 | value = "${opc_compute_ip_address_reservation.ipres.*.ip_address}"
6 | }
7 |
8 | output "private_ip_addresses" {
9 | value = "${opc_compute_instance.server.*.ip_address}"
10 | }
11 |
12 | output "hostnames" {
13 | value = "${opc_compute_instance.server.*.hostname}"
14 | }
15 |
16 | output "vnicset" {
17 | value = "${opc_compute_vnic_set.vnicset.name}"
18 | }
19 |
20 | output "server_acl" {
21 | value = "${opc_compute_acl.acl.name}"
22 | }
23 |
--------------------------------------------------------------------------------
/examples/opc/loadbalancer-classic/outputs.tf:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved.
2 | // Licensed under the Universal Permissive License v 1.0 as shown at http://oss.oracle.com/licenses/upl.
3 |
4 | output "server_ip_address" {
5 | value = "${module.server_pool.public_ip_addresses}"
6 | }
7 |
8 | output "server_hostnames" {
9 | value = "${module.server_pool.hostnames}"
10 | }
11 |
12 | output "dns_instructions" {
13 | value = "Follow your DNS providers guidelines to create/update the CNAME record to redirect the domain `${var.dns_name}` to load balancers `canonical_host_name`"
14 | }
15 |
16 | output "canonical_host_name" {
17 | value = "${module.load_balancer.canonical_host_name}"
18 | }
19 |
--------------------------------------------------------------------------------
/examples/oraclepaas/full-db-jcs-oci/variables.tf:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
2 | // Licensed under the Universal Permissive License v 1.0 as shown at http://oss.oracle.com/licenses/upl.
3 |
4 | variable user {}
5 | variable password {}
6 | variable identity_service_id {}
7 |
8 | variable tenancy {}
9 | variable tenancy_ocid {}
10 | variable user_ocid {}
11 | variable fingerprint {}
12 | variable private_key_path {}
13 | variable region {}
14 | variable home_region {}
15 |
16 | variable compartment_ocid {}
17 | variable subnet_ocid {}
18 |
19 | variable psm_backup_group_name {
20 | default = "psm_backup_group"
21 | }
22 |
23 | variable ssh_public_key_file {
24 | default = "~/.ssh/id_rsa.pub"
25 | }
26 |
--------------------------------------------------------------------------------
/examples/oci/connect_vcns_using_multiple_vnics/env-vars:
--------------------------------------------------------------------------------
1 | ## Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved
2 | ## Licensed under the Universal Permissive License v 1.0 as shown at http://oss.oracle.com/licenses/upl.
3 | ### Provider credentials
4 | export TF_VAR_tenancy_ocid=""
5 | export TF_VAR_user_ocid=""
6 | export TF_VAR_fingerprint=""
7 | export TF_VAR_private_key_path=""
8 | export TF_VAR_private_key_password="$(cat .../passwd)"
9 |
10 | ### Instance credentials
11 | export TF_VAR_ssh_public_key_path=""
12 | export TF_VAR_ssh_private_key_path=""
13 |
14 | ### Region
15 | export TF_VAR_region=""
16 |
17 | ### AD
18 | # Possible values are 1, 2, 3
19 | export TF_VAR_AD=""
20 |
21 | ### Compartment
22 | export TF_VAR_compartment_ocid=""
23 |
--------------------------------------------------------------------------------
/examples/opc/bastion-host-provisioning/modules/bastion/outputs.tf:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2017, 2019, Oracle and/or its affiliates. All rights reserved.
2 | // Licensed under the Universal Permissive License v 1.0 as shown at http://oss.oracle.com/licenses/upl.
3 |
4 | output "bastion_public_ip" {
5 | description = "Bastion host Public IP address"
6 | value = "${opc_compute_ip_reservation.bastion.ip}"
7 | }
8 |
9 | output "bastion_public_key" {
10 | description = "Bastion ssh key resource"
11 | value = "${var.ssh_public_key}"
12 | }
13 |
14 | output "bastion_private_key" {
15 | description = "Bastion private ssh key"
16 | value = "${var.ssh_private_key}"
17 | }
18 |
19 | output "bastion_user" {
20 | description = "Bastion user"
21 | value = "${var.ssh_user}"
22 | }
23 |
--------------------------------------------------------------------------------
/examples/opc/instance-with-persistent-boot-volume/README.md:
--------------------------------------------------------------------------------
1 | Create instance with a bootable storage volume
2 | ==============================================
3 |
4 | This example demonstrates creation of an instance with a persistent (block storage) bootable storage volume
5 |
6 | The `opc_compute_storage_volume` resource is created from an existing image
7 |
8 | ```
9 | bootable = true
10 | image_list = "/oracle/public/OL_6.8_UEKR3_x86_64"
11 | image_list_entry = 3
12 | ```
13 |
14 | The `opc_compute_instance resource` is attached to the bootable storage volume and the `bootOrder` identifies the index of the specific storage attachement to boot from.
15 |
16 | ```
17 | storage {
18 | index = 1
19 | volume = "${opc_compute_storage_volume.server-1-boot.name}"
20 | }
21 | bootOrder = [ 1 ]
22 | ```
23 |
--------------------------------------------------------------------------------
/examples/oraclepaas/dbcs-instance-classic/README.md:
--------------------------------------------------------------------------------
1 | Example Database Cloud Service Configuration
2 | ============================================
3 |
4 | This example creates an Oracle Database Cloud Service Instance on Oracle Cloud Infrastructure Classic
5 |
6 | Create a local `terraform.tfvars` with your account credentials
7 |
8 | ```
9 | domain="idcs-5bb188b5460045f3943c57b783db7ffa"
10 | user="user@example.com"
11 | password="Pa55_Word"
12 | ```
13 |
14 | Update the `main.tf` configuration to set the appropriate `ssh_public_key`
15 |
16 | ```
17 | ssh_public_key = "ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQ..."
18 | ```
19 |
20 | To create the database instance
21 |
22 | ```
23 | $ terraform init
24 | $ terraform apply
25 | ```
26 |
27 | To delete the database instance
28 |
29 | ```
30 | $ terraform destroy
31 | ```
32 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | Terraform Examples for Oracle Cloud
2 | ===================================
3 |
4 | This repository provides sample/example terraform configurations and modules for the Oracle Cloud Infrastructure and Oracle Cloud Platform Services, intended for use with the following Terraform Providers:
5 |
6 | - [Terraform Provider for Oracle Cloud Infrastructure](https://github.com/oracle/terraform-provider-oci)
7 | - [Terraform Provider for Oracle Cloud Infrastructure Classic](https://github.com/terraform-providers/terraform-provider-opc)
8 | - [Terraform Provider for Oracle Cloud Platform](https://github.com/terraform-providers/terraform-provider-oraclepaas)
9 |
10 | Examples
11 | --------
12 |
13 | - [Oracle Cloud Infrastructure](examples/oci)
14 | - [Oracle Cloud Infrastructure Classic](examples/opc)
15 | - [Oracle Cloud Platform](examples/oraclepaas)
16 |
--------------------------------------------------------------------------------
/examples/oraclepaas/full-dbcs-jcs-otd-classic/README.md:
--------------------------------------------------------------------------------
1 | Example DBCS and JCS Service Configuration with OTD
2 | ===================================================
3 |
4 | This example creates an Oracle Database Cloud Service Instance and Oracle Java Cloud Service instance on Oracle Cloud Infrastructure Classic with multiple WebLogic servers and Oracle Traffic Director load balancer
5 |
6 | Create a local `terraform.tfvars` with your account credentials
7 |
8 | ```
9 | domain="idcs-5bb188b5460045f3943c57b783db7ffa"
10 | user="user@example.com"
11 | password="Pa55_Word"
12 | ```
13 |
14 | Update the `main.tf` configuration to set the appropriate `ssh_public_key`
15 |
16 | ```
17 | ssh_public_key = "ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQ..."
18 | ```
19 |
20 | To create the database instance
21 |
22 | ```
23 | $ terraform init
24 | $ terraform apply
25 | ```
26 |
27 | To delete the database instance
28 |
29 | ```
30 | $ terraform destroy
31 | ```
32 |
--------------------------------------------------------------------------------
/examples/opc/loadbalancer-classic/security_rules/main.tf:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved.
2 | // Licensed under the Universal Permissive License v 1.0 as shown at http://oss.oracle.com/licenses/upl.
3 |
4 | variable "name_prefix" {}
5 | variable "acl" {}
6 | variable "protocol_name" {}
7 | variable "ip_protocol" {}
8 | variable "direction" {}
9 | variable "port" {}
10 |
11 | resource "opc_compute_security_rule" "rule" {
12 | name = "${var.name_prefix}-${var.protocol_name}-${var.direction}"
13 | flow_direction = "${var.direction}"
14 | acl = "${var.acl}"
15 | security_protocols = ["${opc_compute_security_protocol.protocol.name}"]
16 | }
17 |
18 | resource "opc_compute_security_protocol" "protocol" {
19 | name = "${var.name_prefix}-${var.protocol_name}"
20 | dst_ports = ["${var.port}"]
21 | ip_protocol = "${var.ip_protocol}"
22 | }
23 |
24 | output "name" {
25 | value = "${opc_compute_security_rule.rule.name}"
26 | }
27 |
--------------------------------------------------------------------------------
/examples/opc/bastion-host-provisioning/modules/bastion/variables.tf:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2017, 2019, Oracle and/or its affiliates. All rights reserved.
2 | // Licensed under the Universal Permissive License v 1.0 as shown at http://oss.oracle.com/licenses/upl.
3 |
4 | variable "ssh_public_key" {
5 | description = "(Required) Name of existing SSH Key resource"
6 | }
7 |
8 | variable "ssh_private_key" {
9 | description = "(Required) SSH private key."
10 | }
11 |
12 | variable "ssh_user" {
13 | description = "(Optional) SSH user to connect to bastion host. Default is `opc`"
14 | default = "opc"
15 | }
16 |
17 | variable "hostname" {
18 | description = "(Optional) name of the host. Default is `bastion`"
19 | default = "bastion"
20 | }
21 |
22 | variable "image" {
23 | description = "(Optional) Machine image. Default is Oracle Linux 7.2 R4"
24 | default = "/oracle/public/OL_7.2_UEKR4_x86_64"
25 | }
26 |
27 | variable "private_ip_network" {
28 | description = "(Required) Name of the IP Network for private interface"
29 | }
30 |
--------------------------------------------------------------------------------
/examples/opc/ipnetworks/modules/install_ssh_keys/main.tf:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2017, 2019, Oracle and/or its affiliates. All rights reserved.
2 | // Licensed under the Universal Permissive License v 1.0 as shown at http://oss.oracle.com/licenses/upl.
3 |
4 | variable "trigger" {}
5 | variable "public_ip" {}
6 | variable "ssh_private_key" {}
7 | variable "ssh_public_key" {}
8 | variable "ssh_user" {}
9 |
10 | // Install the private ssh key used to access the other hosts
11 | resource "null_resource" "install_ssh_keys" {
12 | triggers = {
13 | compute_instance = "${var.trigger}"
14 | }
15 |
16 | connection {
17 | type = "ssh"
18 | host = "${var.public_ip}"
19 | private_key = "${file(var.ssh_private_key)}"
20 | user = "${var.ssh_user}"
21 | timeout = "5m"
22 | }
23 |
24 | provisioner "file" {
25 | source = "${var.ssh_private_key}"
26 | destination = "./.ssh/id_rsa"
27 | }
28 |
29 | provisioner "remote-exec" {
30 | inline = [
31 | "chmod go-r ~/.ssh/id_rsa",
32 | ]
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/examples/oraclepaas/jcs-instance-classic/README.md:
--------------------------------------------------------------------------------
1 | Example Java Cloud Service Configuration
2 | ========================================
3 |
4 | This example creates an Oracle Java Cloud Service Instance on Oracle Cloud Infrastructure Classic
5 |
6 | Create a local `terraform.tfvars` with your account credentials
7 |
8 | ```
9 | domain="idcs-5bb188b5460045f3943c57b783db7ffa"
10 | user="user@example.com"
11 | password="Pa55_Word"
12 | ```
13 |
14 | Update the `main.tf` configuration to set the appropriate `ssh_public_key`
15 |
16 | ```
17 | ssh_public_key = "ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQ..."
18 | ```
19 |
20 | Ensure the `database` configuration is set correctly with the details of an existing database cloud service instance.
21 |
22 | ```hcl
23 | database {
24 | name = "my-terraformed-database"
25 | username = "sys"
26 | password = "Pa55_Word"
27 | }
28 | ```
29 |
30 | To create the java service instance
31 |
32 | ```
33 | $ terraform init
34 | $ terraform apply
35 | ```
36 |
37 | To delete the java service instance
38 |
39 | ```
40 | $ terraform destroy
41 | ```
42 |
--------------------------------------------------------------------------------
/examples/oraclepaas/accs-nodejs-app-from-git-repo/main.tf:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved.
2 | // Licensed under the Universal Permissive License v 1.0 as shown at http://oss.oracle.com/licenses/upl.
3 |
4 | variable user {}
5 | variable password {}
6 | variable domain {}
7 | variable git_repository {}
8 |
9 | provider "oraclepaas" {
10 | version = "~> 1.3"
11 | user = "${var.user}"
12 | password = "${var.password}"
13 | identity_domain = "${var.domain}"
14 | application_endpoint = "https://apaas.us.oraclecloud.com"
15 | }
16 |
17 | resource "oraclepaas_application_container" "example-node-app" {
18 | name = "nodeWebApp"
19 | runtime = "node"
20 | git_repository = "${var.git_repository}"
21 | subscription_type = "HOURLY"
22 |
23 | deployment {
24 | memory = "1G"
25 | instances = 1
26 | }
27 |
28 | manifest_file = "./manifest.json"
29 | }
30 |
31 | output "web_url" {
32 | value = "${oraclepaas_application_container.example-node-app.web_url}"
33 | }
34 |
--------------------------------------------------------------------------------
/examples/oraclepaas/full-db-jcs-oci/providers.tf:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
2 | // Licensed under the Universal Permissive License v 1.0 as shown at http://oss.oracle.com/licenses/upl.
3 |
4 | // OCI provider (for service deployment)
5 | provider "oci" {
6 | tenancy_ocid = "${var.tenancy_ocid}"
7 | user_ocid = "${var.user_ocid}"
8 | fingerprint = "${var.fingerprint}"
9 | private_key_path = "${var.private_key_path}"
10 | region = "${var.region}"
11 | }
12 |
13 | // OCI provider for home region (for policy creation)
14 | provider "oci" {
15 | alias = "home"
16 | tenancy_ocid = "${var.tenancy_ocid}"
17 | user_ocid = "${var.user_ocid}"
18 | fingerprint = "${var.fingerprint}"
19 | private_key_path = "${var.private_key_path}"
20 | region = "${var.home_region}"
21 | }
22 |
23 | // Oracle PaaS provider
24 | provider "oraclepaas" {
25 | user = "${var.user}"
26 | password = "${var.password}"
27 | identity_domain = "${var.identity_service_id}"
28 | java_endpoint = "https://jaas.oraclecloud.com"
29 | }
30 |
--------------------------------------------------------------------------------
/examples/opc/instance-from-storage-snapshot/main.tf:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved.
2 | // Licensed under the Universal Permissive License v 1.0 as shown at http://oss.oracle.com/licenses/upl.
3 |
4 | provider "opc" {
5 | user = "${var.user}"
6 | password = "${var.password}"
7 | identity_domain = "${var.domain}"
8 | endpoint = "${var.endpoint}"
9 | }
10 |
11 | data "opc_compute_storage_volume_snapshot" "snapshot1" {
12 | name = "my-bootable-storage-volume/my-storage-volume-snapshot"
13 | }
14 |
15 | resource "opc_compute_storage_volume" "volume1" {
16 | name = "volume-from-storage-snapshot"
17 | snapshot_id = "${data.opc_compute_storage_volume_snapshot.snapshot1.snapshot_id}"
18 | size = "${data.opc_compute_storage_volume_snapshot.snapshot1.size}"
19 | bootable = true
20 | }
21 |
22 | resource "opc_compute_instance" "instance1" {
23 | name = "instance1"
24 | label = "instance1"
25 | shape = "oc3"
26 |
27 | storage {
28 | index = 1
29 | volume = "${opc_compute_storage_volume.volume1.name}"
30 | }
31 |
32 | boot_order = [1]
33 | }
34 |
--------------------------------------------------------------------------------
/examples/opc/loadbalancer-classic/webapp/main.tf:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved.
2 | // Licensed under the Universal Permissive License v 1.0 as shown at http://oss.oracle.com/licenses/upl.
3 |
4 | locals {
5 | web_app_port = "80"
6 | }
7 |
8 | module "security_web_ingress" {
9 | source = "../security_rules"
10 | name_prefix = "${var.name}"
11 | port = "${local.web_app_port}"
12 | protocol_name = "web"
13 | ip_protocol = "tcp"
14 | direction = "ingress"
15 | acl = "${var.server_acl}"
16 | }
17 |
18 | resource "null_resource" "install_httpd" {
19 | count = "${var.server_count}"
20 |
21 | connection {
22 | type = "ssh"
23 | host = "${element(var.servers,count.index)}"
24 | user = "${var.ssh_user}"
25 | private_key = "${file(var.private_ssh_key_file)}"
26 | timeout = "30m"
27 | }
28 |
29 | provisioner "remote-exec" {
30 | inline = [
31 | "sudo yum -y install httpd",
32 | "sudo systemctl enable httpd",
33 | "sudo systemctl start httpd",
34 | "echo 'Hello from server${count.index}
' | sudo tee /var/www/html/index.html",
35 | ]
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/examples/opc/instance-with-public-ip-on-ip-network-interface/README.md:
--------------------------------------------------------------------------------
1 | Compute Instance with Public IP Address Reservation on an IP Network Interface
2 | ==============================================================================
3 |
4 | This example demonstrates the creation of a compute instance with the Public IP address assigned to the IP Network interface.
5 |
6 | The Terraform configuration creates the following resources:
7 |
8 | - **IP Network** `my-ip-network`
9 | - **IP Address Reservation** `my-ip-address` for an public IP address reservation on the IP Network
10 | - **Compute Instance** `my-instance` OL 7.2 UEK4 instance with one interface on the IP Network associated to the Public IP Address reservation.
11 | - **SSH Key** `my-ssh-key` for SSH access the instance (defaults to `~/.ssh/id_rsa.pub`\)
12 | - **Access Control List** `my-acl` for associating the security rules to the Virtual NIC Set
13 | - **Security Rule** `Allow-ssh-ingress` to allow ingress SSH traffic
14 | - **Security Rule** `Allow-all-egress` to allow all outbound traffic
15 | - **Security Protocol** `all` to match all traffic
16 | - **Security Protocol** `ssh` to match ssh traffic to TCP port 22
17 | - **Virtual NIC Set** `my-vnic-set` to associate instance interfaces to the ACL
18 |
--------------------------------------------------------------------------------
/examples/oci/connect_vcns_using_multiple_vnics/output.tf:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved
2 | // Licensed under the Universal Permissive License v 1.0 as shown at http://oss.oracle.com/licenses/upl.
3 | # Outputing required info for users
4 | output "Bridge_Instance_Public_IP" {
5 | value = "${data.oci_core_instance.bridge_instance.public_ip}"
6 | }
7 |
8 | output "PrivateInstance1_Private_IP" {
9 | value = "${oci_core_instance.PrivateInstance.private_ip}"
10 | }
11 |
12 | output "PrivateInstance2_Private_IP" {
13 | value = "${oci_core_instance.PrivateInstance2.private_ip}"
14 | }
15 |
16 | output "SSH_login_to_the_Bridge_Instance" {
17 | value = "ssh -A opc@${data.oci_core_instance.bridge_instance.public_ip}"
18 | }
19 |
20 | output "SSH_login_to_the_Private_Instance-1_after_logging_into_Bridge_Instance_as_shown_above" {
21 | value = "ssh -A opc@${oci_core_instance.PrivateInstance.private_ip}"
22 | }
23 |
24 | output "SSH_login_to_the_Private_Instance-2_after_logging_into_Bridge_Instance_as_shown_above" {
25 | value = "ssh -A opc@${oci_core_instance.PrivateInstance2.private_ip}"
26 | }
27 |
28 | output "Ping_from_PrivateInstance-1_to_PrivateInstance-2" {
29 | value = "ping ${oci_core_instance.PrivateInstance2.private_ip} "
30 | }
31 |
--------------------------------------------------------------------------------
/examples/opc/instance-from-colocated-snapshot/main.tf:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved.
2 | // Licensed under the Universal Permissive License v 1.0 as shown at http://oss.oracle.com/licenses/upl.
3 |
4 | provider "opc" {
5 | user = "${var.user}"
6 | password = "${var.password}"
7 | identity_domain = "${var.domain}"
8 | endpoint = "${var.endpoint}"
9 | }
10 |
11 | data "opc_compute_storage_volume_snapshot" "snapshot1" {
12 | name = "my-bootable-storage-volume/my-colocated-snapshot"
13 | }
14 |
15 | resource "opc_compute_storage_volume" "volume1" {
16 | name = "volume-from-storage-snapshot"
17 | snapshot = "/Compute-${var.domain}/${var.user}/${data.opc_compute_storage_volume_snapshot.snapshot1.name}"
18 | size = "${data.opc_compute_storage_volume_snapshot.snapshot1.size}"
19 | storage_type = "/oracle/public/storage/default"
20 | bootable = "${data.opc_compute_storage_volume_snapshot.snapshot1.parent_volume_bootable}"
21 | }
22 |
23 | resource "opc_compute_instance" "instance1" {
24 | name = "instance1"
25 | label = "instance1"
26 | shape = "oc3"
27 |
28 | storage {
29 | index = 1
30 | volume = "${opc_compute_storage_volume.volume1.name}"
31 | }
32 |
33 | boot_order = [1]
34 | }
35 |
--------------------------------------------------------------------------------
/examples/oraclepaas/accs-go-app/README.md:
--------------------------------------------------------------------------------
1 | Example Go Application Deployment to Oracle Application Container Cloud Service
2 | ===============================================================================
3 |
4 | This example demonstrates how to package and deploy a sample Go Language application to Oracle Application Container Cloud Service using Terraform
5 |
6 | The sample application is based the example ["Deploy a Go Application to Oracle Cloud"](http://www.oracle.com/webfolder/technetwork/tutorials/obe/cloud/apaas/go/getting-started-go-accs/getting-started-go-accs.html)
7 |
8 | The Terraform configuration:
9 |
10 | - Packages the Go sample application in the `./go-service` directory
11 | - Uploads the packaged sample application to an Object Storage Classic container
12 | - Launches the sample application instance on Application Container Cloud
13 |
14 | ### Steps
15 |
16 | Create a local `terraform.tfvars` file with your environment specific credentials
17 |
18 | ```
19 | domain="mydomain"
20 | user="user@example.com"
21 | password="Pa55_Word"
22 | storage_endpoint="https://mydomain.storage.oraclecloud.com"
23 | ```
24 |
25 | To create the application instance
26 |
27 | ```
28 | $ terraform init
29 | $ terraform apply
30 | ```
31 |
32 | To delete the application instance
33 |
34 | ```
35 | $ terraform destroy
36 | ```
37 |
--------------------------------------------------------------------------------
/examples/oraclepaas/accs-php-app/README.md:
--------------------------------------------------------------------------------
1 | Example PHP Application Deployment to Oracle Application Container Cloud Service
2 | ================================================================================
3 |
4 | This example demonstrates how to package and deploy a sample PHP Language application to Oracle Application Container Cloud Service using Terraform
5 |
6 | The sample application is based the example ["Deploy a PHP Application to Oracle Cloud"](http://www.oracle.com/webfolder/technetwork/tutorials/obe/cloud/apaas/php/getting-started-php-accs/getting-started-php-accs.html)
7 |
8 | The Terraform configuration:
9 |
10 | - Packages the PHP sample application in the `./php-app` directory
11 | - Uploads the packaged sample application to an Object Storage Classic container
12 | - Launches the sample application instance on Application Container Cloud
13 |
14 | ### Steps
15 |
16 | Create a local `terraform.tfvars` file with your environment specific credentials
17 |
18 | ```
19 | domain="mydomain"
20 | user="user@example.com"
21 | password="Pa55_Word"
22 | storage_endpoint="https://mydomain.storage.oraclecloud.com"
23 | ```
24 |
25 | To create the application instance
26 |
27 | ```
28 | $ terraform init
29 | $ terraform apply
30 | ```
31 |
32 | To delete the application instance
33 |
34 | ```
35 | $ terraform destroy
36 | ```
37 |
--------------------------------------------------------------------------------
/examples/oraclepaas/mysqlcs-instance-classic/README.md:
--------------------------------------------------------------------------------
1 | Example MySQL Cloud PaaS Service Configuration on Oracle Cloud Infrastructure Classic
2 | =====================================================================================
3 |
4 | This example creates an Oracle MySQL Cloud Service instance on Oracle Cloud Infrastructure Classic.
5 |
6 | - creates the IP Network the instance will be connected to
7 | - creates the MySQL Cloud Service instance
8 | - creates an Access Rule to allow access to the Database
9 | - creates an Access Rule to allow access to the EM Console
10 |
11 | Create a local `terraform.tfvars` with your account credentials, e.g.
12 |
13 | ```
14 | identity_domain="mydomain"
15 | service_id="590595900"
16 | identity_service_id="idcs-5bb188b5460045f3943c57b783db7ffa"
17 | user="user@example.com"
18 | password="Pa55_Word"
19 | endpoint="https://compute.uscom-central-1.oraclecloud.com/"
20 | region="uscom-central-1"
21 |
22 | source_ip="59.59.59.59"
23 | ```
24 |
25 | Set the `source_ip` to the IP address, or list of IP Addresses or CIDR ranges to allow access to the MySQL instance and EM console.
26 |
27 | To create the MySQL Cloud Service database instance
28 |
29 | ```
30 | $ terraform init
31 | $ terraform apply
32 | ```
33 |
34 | To delete the database instance
35 |
36 | ```
37 | $ terraform destroy
38 | ```
39 |
--------------------------------------------------------------------------------
/examples/oraclepaas/accs-python-app/README.md:
--------------------------------------------------------------------------------
1 | Example Python Application Deployment to Oracle Application Container Cloud Service
2 | ===================================================================================
3 |
4 | This example demonstrates how to package and deploy a sample Python application to Oracle Application Container Cloud Service using Terraform
5 |
6 | The sample application is based the example ["Deploy a Python Application to Oracle Cloud"](http://www.oracle.com/webfolder/technetwork/tutorials/obe/cloud/apaas/python/getting-started-python-accs/getting-started-python-accs.html)
7 |
8 | The Terraform configuration:
9 |
10 | - Packages the Python sample application in the `./python-app` directory
11 | - Uploads the packaged sample application to an Object Storage Classic container
12 | - Launches the sample application instance on Application Container Cloud
13 |
14 | ### Steps
15 |
16 | Create a local `terraform.tfvars` file with your environment specific credentials
17 |
18 | ```
19 | domain="mydomain"
20 | user="user@example.com"
21 | password="Pa55_Word"
22 | storage_endpoint="https://mydomain.storage.oraclecloud.com"
23 | ```
24 |
25 | To create the application instance
26 |
27 | ```
28 | $ terraform init
29 | $ terraform apply
30 | ```
31 |
32 | To delete the application instance
33 |
34 | ```
35 | $ terraform destroy
36 | ```
37 |
--------------------------------------------------------------------------------
/examples/oraclepaas/accs-nodejs-app/README.md:
--------------------------------------------------------------------------------
1 | Example Node.js Application Deployment to Oracle Application Container Cloud Service
2 | ====================================================================================
3 |
4 | This example demonstrates how to package and deploy a sample Node.js Language application to Oracle Application Container Cloud Service using Terraform
5 |
6 | The sample application is based the example ["Deploy a Node.js Application to Oracle Cloud"](http://www.oracle.com/webfolder/technetwork/tutorials/obe/cloud/apaas/node/getting-started-node-accs/getting-started-node-accs.html)
7 |
8 | The Terraform configuration:
9 |
10 | - Packages the Node.js sample application in the `./node-app` directory
11 | - Uploads the packaged sample application to an Object Storage Classic container
12 | - Launches the sample application instance on Application Container Cloud
13 |
14 | ### Steps
15 |
16 | Create a local `terraform.tfvars` file with your environment specific credentials
17 |
18 | ```
19 | domain="mydomain"
20 | user="user@example.com"
21 | password="Pa55_Word"
22 | storage_endpoint="https://mydomain.storage.oraclecloud.com"
23 | ```
24 |
25 | To create the application instance
26 |
27 | ```
28 | $ terraform init
29 | $ terraform apply
30 | ```
31 |
32 | To delete the application instance
33 |
34 | ```
35 | $ terraform destroy
36 | ```
37 |
--------------------------------------------------------------------------------
/examples/opc/instance-with-persistent-boot-volume/main.tf:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2017, 2019, Oracle and/or its affiliates. All rights reserved.
2 | // Licensed under the Universal Permissive License v 1.0 as shown at http://oss.oracle.com/licenses/upl.
3 |
4 | provider "opc" {
5 | user = "${var.user}"
6 | password = "${var.password}"
7 | identity_domain = "${var.domain}"
8 | endpoint = "${var.endpoint}"
9 | }
10 |
11 | resource "opc_compute_storage_volume" "volume1" {
12 | size = "12"
13 | description = "Example bootable storage volume"
14 | name = "boot-from-storage-example"
15 | bootable = true
16 | image_list = "/oracle/public/OL_6.8_UEKR3_x86_64"
17 | image_list_entry = 3
18 | }
19 |
20 | resource "opc_compute_storage_volume" "volume2" {
21 | size = "4"
22 | description = "Example persistent storage volume"
23 | name = "persistent-storage-example"
24 | }
25 |
26 | resource "opc_compute_instance" "instance1" {
27 | name = "boot-from-storage-instance1"
28 | label = "Example instance with bootable storage"
29 | shape = "oc3"
30 |
31 | storage {
32 | index = 1
33 | volume = "${opc_compute_storage_volume.volume1.name}"
34 | }
35 |
36 | storage {
37 | index = 2
38 | volume = "${opc_compute_storage_volume.volume2.name}"
39 | }
40 |
41 | boot_order = [1]
42 | }
43 |
--------------------------------------------------------------------------------
/examples/oraclepaas/accs-java-app/README.md:
--------------------------------------------------------------------------------
1 | Example Java Application Deployment to Oracle Application Container Cloud Service
2 | =================================================================================
3 |
4 | Deploys a Tomcat based Java application to the Java SE runtime on Oracle Application Container Cloud Service
5 |
6 | This example is based on the ["Getting Started with Oracle Application Container Cloud"](http://www.oracle.com/webfolder/technetwork/tutorials/obe/cloud/apaas/acc-getting-started/welcome.html) tutorial
7 |
8 | The Terraform configuration:
9 |
10 | - Uploads the `employees-web-app.zip` sample application to an Object Storage Classic container
11 | - Launches the sample application instance on Application Container Cloud
12 |
13 | ### Steps
14 |
15 | - Download the `employees-web-app.zip` from and save it to the local folder http://www.oracle.com/webfolder/technetwork/tutorials/obe/cloud/apaas/acc-getting-started/files/employees-web-app.zip
16 |
17 | Create a local `terraform.tfvars` file with your environment specific credentials
18 |
19 | ```
20 | domain="mydomain"
21 | user="user@example.com"
22 | password="Pa55_Word"
23 | storage_endpoint="https://mydomain.storage.oraclecloud.com"
24 | ```
25 |
26 | To create the application instance
27 |
28 | ```
29 | $ terraform init
30 | $ terraform apply
31 | ```
32 |
33 | To delete the application instance
34 |
35 | ```
36 | $ terraform destroy
37 | ```
38 |
--------------------------------------------------------------------------------
/examples/oraclepaas/accs-ruby-app/README.md:
--------------------------------------------------------------------------------
1 | Example Ruby Application Deployment to Oracle Application Container Cloud Service
2 | =================================================================================
3 |
4 | This example demonstrates how to package and deploy a sample Ruby Language application to Oracle Application Container Cloud Service using Terraform
5 |
6 | The sample application is based the example ["Deploy a Ruby Application to Oracle Cloud"](http://www.oracle.com/webfolder/technetwork/tutorials/obe/cloud/apaas/ruby/ruby-getting-started/ruby-getting-started.html)
7 |
8 | The Terraform configuration:
9 |
10 | - Uploads the sample `app.zip` Ruby application to an Object Storage Classic container
11 | - Launches the sample application instance on Application Container Cloud
12 |
13 | ### Steps
14 |
15 | Download the example Ruby application `app.zip` from http://www.oracle.com/webfolder/technetwork/tutorials/obe/cloud/apaas/ruby/ruby-getting-started/files/app.zip and place it in the local directory. The file contains the Ruby source code and `manifest.json` metadata file needed to launch a Ruby application.
16 |
17 | Create a local `terraform.tfvars` file with your environment specific credentials
18 |
19 | ```
20 | domain="mydomain"
21 | user="user@example.com"
22 | password="Pa55_Word"
23 | storage_endpoint="https://mydomain.storage.oraclecloud.com"
24 | ```
25 |
26 | To create the application instance
27 |
28 | ```
29 | $ terraform init
30 | $ terraform apply
31 | ```
32 |
33 | To delete the application instance
34 |
35 | ```
36 | $ terraform destroy
37 | ```
38 |
--------------------------------------------------------------------------------
/examples/oraclepaas/accs-python-app/python-app/app.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python
2 | # Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved.
3 | # Licensed under the Universal Permissive License v 1.0 as shown at http://oss.oracle.com/licenses/upl.
4 |
5 | import os
6 | from http.server import BaseHTTPRequestHandler, HTTPServer
7 |
8 | PORT_NUMBER = int(os.environ.get("PORT", 8084))
9 |
10 | # HTTPRequestHandler class
11 |
12 |
13 | class testHTTPServer_RequestHandler(BaseHTTPRequestHandler):
14 |
15 | # GET
16 | def do_HEAD(self):
17 | # Send response status code
18 | self.send_response(200)
19 | self.send_header("Content-type", "text/html")
20 | self.end_headers()
21 | return
22 |
23 | # GET
24 |
25 | def do_GET(self):
26 | # Send response status code
27 | self.send_response(200)
28 |
29 | # Send headers
30 | self.send_header("Content-type", "text/html")
31 | self.end_headers()
32 |
33 | # Send message back to client
34 | message = "Hello world!"
35 | # Write content as utf-8 data
36 | self.wfile.write(bytes(message, "utf8"))
37 | return
38 |
39 |
40 | def run():
41 | print("starting server...")
42 |
43 | # Server settings
44 | # Choose port 8080, for port 80, which is normally used for a http server, you need root access
45 | server_address = ("0.0.0.0", PORT_NUMBER)
46 | httpd = HTTPServer(server_address, testHTTPServer_RequestHandler)
47 | print("running server...")
48 | httpd.serve_forever()
49 |
50 |
51 | run()
52 |
--------------------------------------------------------------------------------
/examples/opc/bastion-host-provisioning/modules/bastion/bastion.tf:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2017, 2019, Oracle and/or its affiliates. All rights reserved.
2 | // Licensed under the Universal Permissive License v 1.0 as shown at http://oss.oracle.com/licenses/upl.
3 |
4 | resource "opc_compute_security_list" "bastion" {
5 | name = "bastion"
6 | policy = "DENY"
7 | outbound_cidr_policy = "PERMIT"
8 | }
9 |
10 | resource "opc_compute_sec_rule" "allow-bastion-ssh" {
11 | action = "permit"
12 | name = "allow-bastion-ssh"
13 | source_list = "seciplist:/oracle/public/public-internet"
14 | destination_list = "seclist:${opc_compute_security_list.bastion.name}"
15 | application = "/oracle/public/ssh"
16 | }
17 |
18 | resource "opc_compute_ip_reservation" "bastion" {
19 | name = "bastion"
20 | parent_pool = "/oracle/public/ippool"
21 | permanent = true
22 | }
23 |
24 | resource "opc_compute_instance" "bastion" {
25 | name = "${var.hostname}"
26 | hostname = "${var.hostname}"
27 | label = "${var.hostname}"
28 | shape = "oc3"
29 | image_list = "${var.image}"
30 | ssh_keys = ["${var.ssh_public_key}"]
31 | tags = ["bastion"]
32 |
33 | networking_info {
34 | index = 0
35 | shared_network = "true"
36 | nat = ["${opc_compute_ip_reservation.bastion.name}"]
37 | sec_lists = ["${opc_compute_security_list.bastion.name}"]
38 | }
39 |
40 | networking_info {
41 | index = 1
42 | shared_network = "false"
43 | ip_network = "${var.private_ip_network}"
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/examples/opc/instance-from-storage-snapshot/README.md:
--------------------------------------------------------------------------------
1 | Create instance from a storage snapshot
2 | =======================================
3 |
4 | This example demonstrates creation of an instance with a persistent (block storage) bootable storage volume created from a storage volume snapshot
5 |
6 | _See the [`instance-from-colocated-snapshot`](../instance-from-colocated-snapshot) example when using **colocated** snapshots._
7 |
8 | The `opc_compute_storage_volume_snapshot` data source is used to reference an existing storage volume snapshot already created in the domain. Note that the name of the snapshot is the composition of the storage volume name and snapshot name.
9 |
10 | ```hcl
11 | data "opc_compute_storage_volume_snapshot" "snapshot1" {
12 | name = "my-bootable-storage-volume/my-storage-volume-snapshot"
13 | }
14 | ```
15 |
16 | The new `opc_compute_storage_volume` resource is created from an existing snapshot by referencing the snapshot_id. The snapshot size attribute can be used to correctly set the size of the new volume.
17 |
18 | ```hcl
19 | resource "opc_compute_storage_volume" "volume1" {
20 | snapshot_id = "${data.opc_compute_storage_volume_snapshot.snapshot1.snapshot_id}"
21 | size = "${data.opc_compute_storage_volume_snapshot.snapshot1.size}"
22 | ...
23 | }
24 | ```
25 |
26 | The `opc_compute_instance resource` is attached to the bootable storage volume and the `bootOrder` identifies the index of the specific storage attachement to boot from.
27 |
28 | ```hcl
29 | resource "opc_compute_instance" "instance1" {
30 | ...
31 | storage {
32 | index = 1 volume = "${opc_compute_storage_volume.volume1.name}"
33 | }
34 | bootOrder = [ 1 ]
35 | }
36 | ```
37 |
--------------------------------------------------------------------------------
/examples/oraclepaas/accs-nodejs-app-from-git-repo/README.md:
--------------------------------------------------------------------------------
1 | Example Node.js Application Deployment to Oracle Application Container Cloud Service
2 | ====================================================================================
3 |
4 | This example demonstrates how to package and deploy a sample Node.js Language application to Oracle Application Container Cloud Service using Terraform
5 |
6 | The sample application is based the example ["Create a Node.js Application from a Git Repository"](http://www.oracle.com/webfolder/technetwork/tutorials/obe/cloud/apaas/node/node-github-accs/node-github-accs.html)
7 |
8 | The Terraform configuration:
9 |
10 | - Launches the sample application instance on Application Container Cloud using locally defined `manifest.json` and the application source from the git repository URL
11 |
12 | ### Steps
13 |
14 | This examples requires an existing Example application project within your own GitHub account. Follow the instructions to [Create a Git Repository](http://www.oracle.com/webfolder/technetwork/tutorials/obe/cloud/apaas/node/node-github-accs/node-github-accs.html) to prepare the application source code repository.
15 |
16 | Create a local `terraform.tfvars` file with your environment specific credentials
17 |
18 | ```
19 | domain="mydomain"
20 | user="user@example.com"
21 | password="Pa55_Word"
22 | storage_endpoint="https://mydomain.storage.oraclecloud.com"
23 |
24 | git_repository="https://github.com//myNodeApp.git"
25 | ```
26 |
27 | To create the application instance
28 |
29 | ```
30 | $ terraform init
31 | $ terraform apply
32 | ```
33 |
34 | To delete the application instance
35 |
36 | ```
37 | $ terraform destroy
38 | ```
39 |
--------------------------------------------------------------------------------
/examples/oraclepaas/dbcs-instance-classic/main.tf:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved.
2 | // Licensed under the Universal Permissive License v 1.0 as shown at http://oss.oracle.com/licenses/upl.
3 |
4 | variable user {}
5 | variable password {}
6 | variable domain {}
7 | variable endpoint {}
8 |
9 | provider "oraclepaas" {
10 | user = "${var.user}"
11 | password = "${var.password}"
12 | identity_domain = "${var.domain}"
13 | database_endpoint = "https://dbaas.oraclecloud.com"
14 | }
15 |
16 | resource "oraclepaas_database_service_instance" "database" {
17 | name = "my-terraformed-database"
18 | description = "Created by Terraform"
19 | shape = "oc1m"
20 | subscription_type = "HOURLY" // HOURLY MONTHLY
21 | ssh_public_key = "${file("~/.ssh/id_rsa.pub")}"
22 |
23 | notification_email = "${var.user}"
24 |
25 | edition = "EE" // SE EE EE_HP EE_EP
26 | version = "18.0.0.0" // 18.0.0.0 or 12.2.0.1 or 12.1.0.2 or 11.2.0.4
27 |
28 | bring_your_own_license = false // Bring Your Own License (BYOL) is supported only with Universal Credits account.
29 | high_performance_storage = false // High Performance Storage is only supported for CLOUD_CREDIT service entitlement
30 |
31 | database_configuration {
32 | admin_password = "Pa55_Word"
33 | backup_destination = "BOTH"
34 | sid = "ORCL"
35 | usable_storage = 25
36 | is_rac = false
37 | }
38 |
39 | backups {
40 | cloud_storage_container = "Storage-${var.domain}/my-terraformed-database-backup"
41 | create_if_missing = true
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/examples/oraclepaas/jcs-instance-classic/main.tf:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved.
2 | // Licensed under the Universal Permissive License v 1.0 as shown at http://oss.oracle.com/licenses/upl.
3 |
4 | variable user {}
5 | variable password {}
6 | variable domain {}
7 | variable endpoint {}
8 |
9 | provider "oraclepaas" {
10 | user = "${var.user}"
11 | password = "${var.password}"
12 | identity_domain = "${var.domain}"
13 | java_endpoint = "https://jaas.oraclecloud.com"
14 | }
15 |
16 | resource "oraclepaas_java_service_instance" "jcs" {
17 | # Java Service name cannot have more than 30 chars; must start with a letter and can contain only letters and numbers.
18 | # If the service name contains a hyphen; Oracle-managed load balancer will not be created.
19 | name = "tfjcsdemo"
20 |
21 | description = "Created by Terraform"
22 |
23 | edition = "EE" // SE EE SUITE
24 | service_version = "12cRelease213" // 12cRelease213, 12cRelease212, 12cR3, 11gR1
25 | metering_frequency = "HOURLY" // HOURLY MONTHLY
26 | ssh_public_key = "${file("~/.ssh/id_rsa.pub")}"
27 |
28 | notification_email = "${var.user}"
29 |
30 | weblogic_server {
31 | shape = "oc1m"
32 |
33 | database {
34 | name = "my-terraformed-database-with-backup"
35 | username = "sys"
36 | password = "Pa55_Word"
37 | }
38 |
39 | admin {
40 | username = "weblogic"
41 | password = "Weblogic_1"
42 | }
43 | }
44 |
45 | backups {
46 | cloud_storage_container = "Storage-${var.domain}/tfjcsdemo"
47 | auto_generate = true
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/examples/oraclepaas/accs-ruby-app/main.tf:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved.
2 | // Licensed under the Universal Permissive License v 1.0 as shown at http://oss.oracle.com/licenses/upl.
3 |
4 | variable user {}
5 | variable password {}
6 | variable domain {}
7 | variable compute_endpoint {}
8 | variable storage_endpoint {}
9 |
10 | provider "oraclepaas" {
11 | version = "~> 1.3"
12 | user = "${var.user}"
13 | password = "${var.password}"
14 | identity_domain = "${var.domain}"
15 | application_endpoint = "https://apaas.us.oraclecloud.com"
16 | }
17 |
18 | provider "opc" {
19 | version = "~> 1.2"
20 | user = "${var.user}"
21 | password = "${var.password}"
22 | identity_domain = "${var.domain}"
23 | storage_endpoint = "${var.storage_endpoint}"
24 | }
25 |
26 | resource "opc_storage_container" "accs-apps" {
27 | name = "my-accs-apps"
28 | }
29 |
30 | resource "opc_storage_object" "example-ruby-app" {
31 | name = "app.zip"
32 | container = "${opc_storage_container.accs-apps.name}"
33 | file = "./app.zip"
34 | etag = "${md5(file("./app.zip"))}"
35 | content_type = "application/zip;charset=UTF-8"
36 | }
37 |
38 | resource "oraclepaas_application_container" "example-ruby-app" {
39 | name = "rubyWebApp"
40 | runtime = "ruby"
41 | archive_url = "${opc_storage_container.accs-apps.name}/${opc_storage_object.example-ruby-app.name}"
42 | subscription_type = "HOURLY"
43 |
44 | deployment {
45 | memory = "1G"
46 | instances = 1
47 | }
48 | }
49 |
50 | output "web_url" {
51 | value = "${oraclepaas_application_container.example-ruby-app.web_url}"
52 | }
53 |
--------------------------------------------------------------------------------
/examples/opc/instance-from-colocated-snapshot/README.md:
--------------------------------------------------------------------------------
1 | Create instance from a colocated storage snapshot
2 | =================================================
3 |
4 | This example demonstrates creating an instance with a persistent (block storage) bootable storage volume created from a **colocated** storage volume snapshot.
5 |
6 | _See the [`instance-from-storage-snapshot`](../instance-from-storage-snapshot) example with using non-colocated snapshots._
7 |
8 | The `opc_compute_storage_volume_snapshot` data source is used to reference an existing storage volume snapshot already created in the domain. Note that the name of the snapshot is the composition of the storage volume name and snapshot name.
9 |
10 | ```hcl
11 | data "opc_compute_storage_volume_snapshot" "snapshot1" {
12 | name = "my-bootable-storage-volume/my-colocated-snapshot"
13 | }
14 | ```
15 |
16 | For colocated snapshots the source snapshot for the new `opc_compute_storage_volume` resource must be identified by the fully qualified snapshot name. The snapshot size attribute can be used to correctly set the size of the new volume.
17 |
18 | ```hcl
19 | resource "opc_compute_storage_volume" "volume1" {
20 | ...
21 | snapshot = "/Compute-${var.domain}/${var.user}/${data.opc_compute_storage_volume_snapshot.snapshot1.name}"
22 | size = "${data.opc_compute_storage_volume_snapshot.snapshot1.size}"
23 | }
24 | ```
25 |
26 | The `opc_compute_instance resource` is attached to the bootable storage volume and the `bootOrder` identifies the index of the specific storage attachment to boot from.
27 |
28 | ```hcl
29 | resource "opc_compute_instance" "instance1" {
30 | ...
31 | storage {
32 | index = 1 volume = "${opc_compute_storage_volume.volume1.name}"
33 | }
34 | bootOrder = [ 1 ]
35 | }
36 | ```
37 |
--------------------------------------------------------------------------------
/examples/oraclepaas/accs-java-app/main.tf:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved.
2 | // Licensed under the Universal Permissive License v 1.0 as shown at http://oss.oracle.com/licenses/upl.
3 |
4 | variable user {}
5 | variable password {}
6 | variable domain {}
7 | variable compute_endpoint {}
8 | variable storage_endpoint {}
9 |
10 | provider "oraclepaas" {
11 | version = "~> 1.3"
12 | user = "${var.user}"
13 | password = "${var.password}"
14 | identity_domain = "${var.domain}"
15 | application_endpoint = "https://apaas.us.oraclecloud.com"
16 | }
17 |
18 | provider "opc" {
19 | version = "~> 1.2"
20 | user = "${var.user}"
21 | password = "${var.password}"
22 | identity_domain = "${var.domain}"
23 | storage_endpoint = "${var.storage_endpoint}"
24 | }
25 |
26 | resource "opc_storage_container" "accs-apps" {
27 | name = "my-accs-apps"
28 | }
29 |
30 | resource "opc_storage_object" "example-java-app" {
31 | name = "employees-web-app.zip"
32 | container = "${opc_storage_container.accs-apps.name}"
33 | file = "./employees-web-app.zip"
34 | etag = "${md5(file("./employees-web-app.zip"))}"
35 | content_type = "application/zip;charset=UTF-8"
36 | }
37 |
38 | resource "oraclepaas_application_container" "example-java-app" {
39 | name = "EmployeeWebApp"
40 | runtime = "java"
41 | archive_url = "${opc_storage_container.accs-apps.name}/${opc_storage_object.example-java-app.name}"
42 | subscription_type = "HOURLY"
43 |
44 | deployment {
45 | memory = "1G"
46 | instances = 1
47 | }
48 | }
49 |
50 | output "web_url" {
51 | value = "${oraclepaas_application_container.example-java-app.web_url}"
52 | }
53 |
--------------------------------------------------------------------------------
/examples/opc/instance-with-ssh/main.tf:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2017, 2019, Oracle and/or its affiliates. All rights reserved.
2 | // Licensed under the Universal Permissive License v 1.0 as shown at http://oss.oracle.com/licenses/upl.
3 |
4 | provider "opc" {
5 | user = "${var.user}"
6 | password = "${var.password}"
7 | identity_domain = "${var.domain}"
8 | endpoint = "${var.endpoint}"
9 | }
10 |
11 | resource "opc_compute_instance" "instance1" {
12 | name = "example-instance1"
13 | label = "My Oracle Linux 7.2 UEK3 Server"
14 | shape = "oc3"
15 | image_list = "/oracle/public/OL_7.2_UEKR3_x86_64"
16 | ssh_keys = ["${opc_compute_ssh_key.sshkey1.name}"]
17 |
18 | networking_info {
19 | index = 0
20 | shared_network = true
21 | nat = ["${opc_compute_ip_reservation.ipreservation1.name}"]
22 | sec_lists = ["${opc_compute_security_list.seclist1.name}"]
23 | }
24 | }
25 |
26 | resource "opc_compute_ssh_key" "sshkey1" {
27 | name = "example-sshkey1"
28 | key = "${file(var.ssh_public_key_file)}"
29 | enabled = true
30 | }
31 |
32 | resource "opc_compute_ip_reservation" "ipreservation1" {
33 | parent_pool = "/oracle/public/ippool"
34 | permanent = true
35 | }
36 |
37 | resource "opc_compute_security_list" "seclist1" {
38 | name = "example-seclist1"
39 | policy = "DENY"
40 | outbound_cidr_policy = "PERMIT"
41 | }
42 |
43 | resource "opc_compute_sec_rule" "allow-ssh" {
44 | name = "Allow-ssh-access"
45 | source_list = "seciplist:/oracle/public/public-internet"
46 | destination_list = "seclist:${opc_compute_security_list.seclist1.name}"
47 | action = "permit"
48 | application = "/oracle/public/ssh"
49 | disabled = false
50 | }
51 |
--------------------------------------------------------------------------------
/examples/opc/loadbalancer-classic/certificates/main.tf:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved.
2 | // Licensed under the Universal Permissive License v 1.0 as shown at http://oss.oracle.com/licenses/upl.
3 |
4 | resource "tls_private_key" "example" {
5 | algorithm = "RSA"
6 | rsa_bits = 4096
7 | }
8 |
9 | resource "tls_self_signed_cert" "ca" {
10 | key_algorithm = "${tls_private_key.example.algorithm}"
11 | private_key_pem = "${tls_private_key.example.private_key_pem}"
12 |
13 | validity_period_hours = "${var.validity_period_hours}"
14 | early_renewal_hours = "${var.early_renewal_hours}"
15 |
16 | allowed_uses = [
17 | "cert_signing",
18 | ]
19 |
20 | dns_names = ["${var.dns_names}"]
21 |
22 | subject {
23 | common_name = "${var.common_name}"
24 | organization = "${var.organization}"
25 | }
26 |
27 | is_ca_certificate = true
28 | }
29 |
30 | resource "tls_cert_request" "example" {
31 | key_algorithm = "${tls_private_key.example.algorithm}"
32 | private_key_pem = "${tls_private_key.example.private_key_pem}"
33 |
34 | subject {
35 | common_name = "${var.common_name}"
36 | organization = "${var.organization}"
37 | province = "${var.province}"
38 | country = "${var.country}"
39 | }
40 |
41 | dns_names = ["${var.dns_names}"]
42 | }
43 |
44 | resource "tls_locally_signed_cert" "example" {
45 | cert_request_pem = "${tls_cert_request.example.cert_request_pem}"
46 | ca_key_algorithm = "${tls_private_key.example.algorithm}"
47 | ca_private_key_pem = "${tls_private_key.example.private_key_pem}"
48 | ca_cert_pem = "${tls_self_signed_cert.ca.cert_pem}"
49 |
50 | validity_period_hours = "${var.validity_period_hours}"
51 |
52 | allowed_uses = [
53 | "server_auth",
54 | ]
55 | }
56 |
--------------------------------------------------------------------------------
/examples/opc/orchestrated-instance/main.tf:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2017, 2019, Oracle and/or its affiliates. All rights reserved.
2 | // Licensed under the Universal Permissive License v 1.0 as shown at http://oss.oracle.com/licenses/upl.
3 |
4 | variable "user" {}
5 | variable "password" {}
6 | variable "domain" {}
7 | variable "endpoint" {}
8 |
9 | provider "opc" {
10 | version = "> 1.0.1"
11 | user = "${var.user}"
12 | password = "${var.password}"
13 | identity_domain = "${var.domain}"
14 | endpoint = "${var.endpoint}"
15 | }
16 |
17 | resource "opc_compute_ip_network" "ipnet1" {
18 | name = "ipnet1"
19 | ip_address_prefix = "192.168.4.0/24"
20 | }
21 |
22 | resource "opc_compute_storage_volume" "boot" {
23 | size = "12"
24 | name = "boot"
25 | bootable = true
26 | image_list = "/oracle/public/OL_7.2_UEKR4_x86_64"
27 | image_list_entry = 1
28 | }
29 |
30 | resource "opc_compute_ssh_key" "key1" {
31 | name = "key1"
32 | key = "${file("~/.ssh/id_rsa.pub")}"
33 | }
34 |
35 | resource "opc_compute_orchestrated_instance" "MyInstance" {
36 | name = "example-instance-orchestraion"
37 | description = "Example Instance Orchesrtation"
38 | desired_state = "active"
39 |
40 | instance {
41 | persistent = true
42 | name = "vm-1"
43 | hostname = "vm-1"
44 | shape = "oc3"
45 | ssh_keys = ["${opc_compute_ssh_key.key1.name}"]
46 |
47 | networking_info {
48 | index = 1
49 | ip_network = "${opc_compute_ip_network.ipnet1.name}"
50 | ip_address = "192.168.4.2"
51 | vnic = "eth1-ipnet1"
52 | }
53 |
54 | storage {
55 | index = 1
56 | volume = "${opc_compute_storage_volume.boot.name}"
57 | }
58 |
59 | boot_order = [1]
60 | }
61 | }
62 |
--------------------------------------------------------------------------------
/LICENSE.txt:
--------------------------------------------------------------------------------
1 | Copyright (c) 2017, 2019 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 software, associated documentation and/or data (collectively the "Software"), free of charge and under any and all copyright rights in the Software, and any and all patent rights owned or freely licensable by each licensor hereunder covering either (i) the unmodified Software as contributed to or provided by such licensor, or (ii) the Larger Works (as defined below), to deal in both
6 |
7 | (a) the Software, and
8 | (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if one is included with the Software (each a “Larger Work” to which the Software is contributed by such licensors),
9 |
10 | without restriction, including without limitation the rights to copy, create derivative works of, display, perform, and distribute the Software and make, use, sell, offer for sale, import, export, have made, and have sold the Software and the Larger Work(s), and to sublicense the foregoing rights on either these or other terms.
11 |
12 | This license is subject to the following condition:
13 | The above copyright notice and either this complete permission notice or at a minimum a reference to the UPL must be included in all copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
--------------------------------------------------------------------------------
/examples/oci/connect_vcns_using_multiple_vnics/variables.tf:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved
2 | // Licensed under the Universal Permissive License v 1.0 as shown at http://oss.oracle.com/licenses/upl.
3 | variable "tenancy_ocid" {}
4 |
5 | variable "user_ocid" {}
6 | variable "fingerprint" {}
7 | variable "private_key_path" {}
8 | variable "private_key_password" {}
9 | variable "compartment_ocid" {}
10 | variable "region" {}
11 | variable "ssh_public_key_path" {}
12 |
13 | variable "ssh_private_key_path" {}
14 |
15 | # Choose an Availability Domain
16 | variable "AD" {
17 | default = "1"
18 | }
19 |
20 | variable "InstanceShape" {
21 | default = "VM.Standard2.1"
22 | }
23 |
24 | variable "InstanceShape2" {
25 | default = "VM.Standard2.1"
26 | }
27 |
28 | variable "InstanceImageOCID" {
29 | type = "map"
30 |
31 | default = {
32 | // See https://docs.us-phoenix-1.oraclecloud.com/images/
33 | // Oracle-provided image "Oracle-Linux-7.4-2018.02.21-1"
34 | us-phoenix-1 = "ocid1.image.oc1.phx.aaaaaaaaupbfz5f5hdvejulmalhyb6goieolullgkpumorbvxlwkaowglslq"
35 |
36 | us-ashburn-1 = "ocid1.image.oc1.iad.aaaaaaaajlw3xfie2t5t52uegyhiq2npx7bqyu4uvi2zyu3w3mqayc2bxmaa"
37 | eu-frankfurt-1 = "ocid1.image.oc1.eu-frankfurt-1.aaaaaaaa7d3fsb6272srnftyi4dphdgfjf6gurxqhmv6ileds7ba3m2gltxq"
38 | uk-london-1 = "ocid1.image.oc1.uk-london-1.aaaaaaaaa6h6gj6v4n56mqrbgnosskq63blyv2752g36zerymy63cfkojiiq"
39 | }
40 | }
41 |
42 | # The First VCN
43 | variable "vcn_cidr" {
44 | default = "10.0.0.0/16"
45 | }
46 |
47 | variable "mgmt_subnet_cidr" {
48 | default = "10.0.0.0/24"
49 | }
50 |
51 | variable "private_subnet_cidr" {
52 | default = "10.0.1.0/24"
53 | }
54 |
55 | variable "vcn_cidr2" {
56 | default = "10.1.0.0/16"
57 | }
58 |
59 | variable "mgmt_subnet_cidr2" {
60 | default = "10.1.0.0/24"
61 | }
62 |
63 | variable "private_subnet_cidr2" {
64 | default = "10.1.1.0/24"
65 | }
66 |
--------------------------------------------------------------------------------
/examples/oraclepaas/accs-go-app/main.tf:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved.
2 | // Licensed under the Universal Permissive License v 1.0 as shown at http://oss.oracle.com/licenses/upl.
3 |
4 | variable user {}
5 | variable password {}
6 | variable domain {}
7 | variable compute_endpoint {}
8 | variable storage_endpoint {}
9 |
10 | provider "oraclepaas" {
11 | version = "~> 1.3"
12 | user = "${var.user}"
13 | password = "${var.password}"
14 | identity_domain = "${var.domain}"
15 | application_endpoint = "https://apaas.us.oraclecloud.com"
16 | }
17 |
18 | provider "opc" {
19 | version = "~> 1.2"
20 | user = "${var.user}"
21 | password = "${var.password}"
22 | identity_domain = "${var.domain}"
23 | storage_endpoint = "${var.storage_endpoint}"
24 | }
25 |
26 | data "archive_file" "example-go-app" {
27 | type = "zip"
28 | source_dir = "${path.module}/go-service/"
29 | output_path = "${path.module}/go-service.zip"
30 | }
31 |
32 | resource "opc_storage_container" "accs-apps" {
33 | name = "my-accs-apps"
34 | }
35 |
36 | resource "opc_storage_object" "example-go-app" {
37 | name = "go-service.zip"
38 | container = "${opc_storage_container.accs-apps.name}"
39 | file = "${data.archive_file.example-go-app.output_path}"
40 | etag = "${data.archive_file.example-go-app.output_md5}"
41 | content_type = "application/zip;charset=UTF-8"
42 | }
43 |
44 | resource "oraclepaas_application_container" "example-go-app" {
45 | name = "GoWebApp"
46 | runtime = "golang"
47 | archive_url = "${opc_storage_container.accs-apps.name}/${opc_storage_object.example-go-app.name}"
48 | subscription_type = "HOURLY"
49 |
50 | deployment {
51 | memory = "1G"
52 | instances = 1
53 | }
54 | }
55 |
56 | output "web_url" {
57 | value = "${oraclepaas_application_container.example-go-app.web_url}"
58 | }
59 |
--------------------------------------------------------------------------------
/examples/oraclepaas/accs-php-app/main.tf:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved.
2 | // Licensed under the Universal Permissive License v 1.0 as shown at http://oss.oracle.com/licenses/upl.
3 |
4 | variable user {}
5 | variable password {}
6 | variable domain {}
7 | variable compute_endpoint {}
8 | variable storage_endpoint {}
9 |
10 | provider "oraclepaas" {
11 | version = "> 1.3.0"
12 | user = "${var.user}"
13 | password = "${var.password}"
14 | identity_domain = "${var.domain}"
15 | application_endpoint = "https://apaas.us.oraclecloud.com"
16 | }
17 |
18 | provider "opc" {
19 | version = "> 1.1.0"
20 | user = "${var.user}"
21 | password = "${var.password}"
22 | identity_domain = "${var.domain}"
23 | storage_endpoint = "${var.storage_endpoint}"
24 | }
25 |
26 | data "archive_file" "example-php-app" {
27 | type = "zip"
28 | source_dir = "${path.module}/php-app/"
29 | output_path = "${path.module}/php-app.zip"
30 | }
31 |
32 | resource "opc_storage_container" "accs-apps" {
33 | name = "my-accs-apps"
34 | }
35 |
36 | resource "opc_storage_object" "example-php-app" {
37 | name = "php-app.zip"
38 | container = "${opc_storage_container.accs-apps.name}"
39 | file = "${data.archive_file.example-php-app.output_path}"
40 | etag = "${data.archive_file.example-php-app.output_md5}"
41 | content_type = "application/zip;charset=UTF-8"
42 | }
43 |
44 | resource "oraclepaas_application_container" "example-php-app" {
45 | name = "PhpWebApp"
46 | runtime = "php"
47 | archive_url = "${opc_storage_container.accs-apps.name}/${opc_storage_object.example-php-app.name}"
48 | subscription_type = "HOURLY"
49 |
50 | deployment {
51 | memory = "1G"
52 | instances = 1
53 | }
54 | }
55 |
56 | output "web_url" {
57 | value = "${oraclepaas_application_container.example-php-app.web_url}"
58 | }
59 |
--------------------------------------------------------------------------------
/examples/oraclepaas/mysqlcs-instance-oci/README.md:
--------------------------------------------------------------------------------
1 | Example MySQL Cloud PaaS Service Configuration on Oracle Cloud Infrastructure
2 | =============================================================================
3 |
4 | This example creates an Oracle MySQL Cloud Service instance on Oracle Cloud Infrastructure Classic.
5 |
6 | Before being able to create an instance that is configured for backups to OCI Object Storage you must first follow the steps to create an Object Storage Bucket for storing the Backups.
7 |
8 | - Create a Bucket in OCI Object Storage, e.g. `PaaSBucket`
9 | - Create a Swift Password for user (e.g. `api.user`)
10 |
11 | See [Prerequisites for Oracle Platform Services on Oracle Cloud Infrastructure](https://docs.us-phoenix-1.oraclecloud.com/Content/General/Reference/PaaSprereqs.htm) from more details.
12 |
13 | Create a local `terraform.tfvars` with your account credentials
14 |
15 | ```
16 | # Oracle PaaS Cloud Account
17 | identity_domain="mydomain"
18 | service_id="590595900"
19 | identity_service_id="idcs-5bb188b5460045f3943c57b783db7ffa"
20 | user="user@example.com"
21 | password="Pa55_Word"
22 |
23 | # Oracle Cloud Infrastructure Tenancy
24 | tenancy_ocid="ocid1.tenancy.oc1..aaaaaaaaw6ti6w2rgk2q3gwahgzha43gi4y4kxrrkkfptq3wloxx3aclb2zb"
25 | region="us-ashburn-1"
26 | compartment_ocid="ocid1.compartment.oc1..aaaaaaaaiqjpmzjood5c5357anrtwk2jfpm7rouzfnit7n4b5lwkl6w6gkab"
27 | user_ocid="ocid1.user.oc1..aaaaaaaawkc2uzswdifko4v4foytsrtrtqqlonavyora6sxwmbuski422xfb"
28 | private_key_path="/home/vagrant/.oci/oci_api_key.pem"
29 | fingerprint="ae:ea:b2:1a:7b:d3:d2:75:8d:50:4e:00:ca:59:17:ff"
30 |
31 | # Object Storage for PaaS
32 | object_storage_bucket="PaaSBucket"
33 | object_storage_namespace="mydomain"
34 | object_storage_user="api.user"
35 | swift_password="2imuh5re6+fx;ulJ60[Z"
36 | ```
37 |
38 | To create the database instance
39 |
40 | ```
41 | $ terraform init
42 | $ terraform apply
43 | ```
44 |
45 | To delete the database instance
46 |
47 | ```
48 | $ terraform destroy
49 | ```
50 |
--------------------------------------------------------------------------------
/examples/oraclepaas/accs-nodejs-app/main.tf:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved.
2 | // Licensed under the Universal Permissive License v 1.0 as shown at http://oss.oracle.com/licenses/upl.
3 |
4 | variable user {}
5 | variable password {}
6 | variable domain {}
7 | variable compute_endpoint {}
8 | variable storage_endpoint {}
9 |
10 | provider "oraclepaas" {
11 | version = "~> 1.3"
12 | user = "${var.user}"
13 | password = "${var.password}"
14 | identity_domain = "${var.domain}"
15 | application_endpoint = "https://apaas.us.oraclecloud.com"
16 | }
17 |
18 | provider "opc" {
19 | version = "~> 1.2"
20 | user = "${var.user}"
21 | password = "${var.password}"
22 | identity_domain = "${var.domain}"
23 | storage_endpoint = "${var.storage_endpoint}"
24 | }
25 |
26 | data "archive_file" "example-node-app" {
27 | type = "zip"
28 | source_dir = "${path.module}/node-app/"
29 | output_path = "${path.module}/node-app.zip"
30 | }
31 |
32 | resource "opc_storage_container" "accs-apps" {
33 | name = "my-accs-apps"
34 | }
35 |
36 | resource "opc_storage_object" "example-node-app" {
37 | name = "node-app.zip"
38 | container = "${opc_storage_container.accs-apps.name}"
39 | file = "${data.archive_file.example-node-app.output_path}"
40 | etag = "${data.archive_file.example-node-app.output_md5}"
41 | content_type = "application/zip;charset=UTF-8"
42 | }
43 |
44 | resource "oraclepaas_application_container" "example-node-app" {
45 | name = "nodeWebApp"
46 | runtime = "node"
47 | archive_url = "${opc_storage_container.accs-apps.name}/${opc_storage_object.example-node-app.name}"
48 | subscription_type = "HOURLY"
49 |
50 | deployment {
51 | memory = "1G"
52 | instances = 1
53 | }
54 | }
55 |
56 | output "web_url" {
57 | value = "${oraclepaas_application_container.example-node-app.web_url}"
58 | }
59 |
--------------------------------------------------------------------------------
/examples/oraclepaas/accs-python-app/main.tf:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved.
2 | // Licensed under the Universal Permissive License v 1.0 as shown at http://oss.oracle.com/licenses/upl.
3 |
4 | variable user {}
5 | variable password {}
6 | variable domain {}
7 | variable compute_endpoint {}
8 | variable storage_endpoint {}
9 |
10 | provider "oraclepaas" {
11 | version = "~> 1.3"
12 | user = "${var.user}"
13 | password = "${var.password}"
14 | identity_domain = "${var.domain}"
15 | application_endpoint = "https://apaas.us.oraclecloud.com"
16 | }
17 |
18 | provider "opc" {
19 | version = "~> 1.2"
20 | user = "${var.user}"
21 | password = "${var.password}"
22 | identity_domain = "${var.domain}"
23 | storage_endpoint = "${var.storage_endpoint}"
24 | }
25 |
26 | data "archive_file" "example-python-app" {
27 | type = "zip"
28 | source_dir = "${path.module}/python-app/"
29 | output_path = "${path.module}/python-app.zip"
30 | }
31 |
32 | resource "opc_storage_container" "accs-apps" {
33 | name = "my-accs-apps"
34 | }
35 |
36 | resource "opc_storage_object" "example-python-app" {
37 | name = "python-app.zip"
38 | container = "${opc_storage_container.accs-apps.name}"
39 | file = "${data.archive_file.example-python-app.output_path}"
40 | etag = "${data.archive_file.example-python-app.output_md5}"
41 | content_type = "application/zip;charset=UTF-8"
42 | }
43 |
44 | resource "oraclepaas_application_container" "example-python-app" {
45 | name = "PythonWebApp"
46 | runtime = "python"
47 | archive_url = "${opc_storage_container.accs-apps.name}/${opc_storage_object.example-python-app.name}"
48 | subscription_type = "HOURLY"
49 |
50 | deployment {
51 | memory = "1G"
52 | instances = 1
53 | }
54 | }
55 |
56 | output "web_url" {
57 | value = "${oraclepaas_application_container.example-python-app.web_url}"
58 | }
59 |
--------------------------------------------------------------------------------
/examples/opc/loadbalancer-classic/server_pool/main.tf:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved.
2 | // Licensed under the Universal Permissive License v 1.0 as shown at http://oss.oracle.com/licenses/upl.
3 |
4 | resource "opc_compute_ssh_key" "sshkey" {
5 | name = "${var.name}-ssh-key"
6 | key = "${var.public_ssh_key}"
7 | enabled = true
8 | }
9 |
10 | resource "opc_compute_ip_address_reservation" "ipres" {
11 | count = "${var.server_count}"
12 | name = "${var.name}${count.index}-ip-address"
13 | ip_address_pool = "public-ippool"
14 | }
15 |
16 | resource "opc_compute_acl" "acl" {
17 | name = "${var.name}"
18 | }
19 |
20 | module "security_all_egress" {
21 | source = "../security_rules/all_egress"
22 | name = "${var.name}"
23 | acl = "${opc_compute_acl.acl.name}"
24 | }
25 |
26 | module "security_ssh_ingress" {
27 | source = "../security_rules"
28 | name_prefix = "${var.name}"
29 | port = "22"
30 | protocol_name = "ssh"
31 | ip_protocol = "tcp"
32 | direction = "ingress"
33 | acl = "${opc_compute_acl.acl.name}"
34 | }
35 |
36 | resource "opc_compute_vnic_set" "vnicset" {
37 | name = "${var.name}"
38 | applied_acls = ["${opc_compute_acl.acl.name}"]
39 | }
40 |
41 | resource "opc_compute_instance" "server" {
42 | count = "${var.server_count}"
43 | name = "${var.name}${count.index}"
44 | hostname = "${var.name}${count.index}"
45 | shape = "${var.shape}"
46 | image_list = "${var.image_list}"
47 |
48 | networking_info {
49 | index = 0
50 | ip_network = "${var.ip_network}"
51 | is_default_gateway = true
52 | dns = ["${var.name}${count.index}"]
53 | vnic = "${var.name}${count.index}_eth0"
54 | vnic_sets = ["${opc_compute_vnic_set.vnicset.name}"]
55 | nat = ["${element(opc_compute_ip_address_reservation.ipres.*.name, count.index)}"]
56 | }
57 |
58 | ssh_keys = ["${opc_compute_ssh_key.sshkey.name}"]
59 | }
60 |
--------------------------------------------------------------------------------
/examples/opc/loadbalancer-classic/README.md:
--------------------------------------------------------------------------------
1 | Example Load Balancer Classic Terraform Configuration
2 | =====================================================
3 |
4 |
5 | This example demonstrates how to configure the Oracle Cloud Infrastructure Load Balancer Classic service using Terraform
6 |
7 | The example creates a complete application deployment including the backend servers, and load balances the traffic across the deployed web applications. The configuration is split into several sub modules:
8 |
9 | - `network` creates the IP Network for the server and load balancer deployment
10 | - `server_pool` creates a requested number of Oracle Cloud Infrastructure Classic compute instances on on the configured IP Network
11 | - `webapp` deploys an example web application to each of the provisioned server instances
12 | - `security_rules` creates the security rule resources used to configure the server SSH and web app port access rules.
13 | - `load_balancer` created the load balancer instances configured to balance the traffic between the servers in the server pool
14 |
15 | Note this example assumes the load balancer is being setup to load balance a site at the fictional address `mydomain.example.com`. To see the load balancer actually working this `dns_name` variable should be set to a domain you have access to in order to update the public DNS CNAME record so the host is redirected to the load balancers canonical host name.
16 |
17 | ### Steps
18 |
19 | - Generate an ssh key pair for use deploying this example (no passphrase)
20 |
21 | ```sh
22 | $ ssh-keygen -f ./id_rsa
23 | ```
24 |
25 | - Create a local `terraform.tfvars` file with your environment specific credentials
26 |
27 | ```
28 | domain="55500000"
29 | endpoint="https://compute.uscom-central-1.oraclecloud.com/"
30 | user="user@example.com"
31 | password="Pa55_Word"
32 | region="uscom-central-1"
33 | lbaas_endpoint= "https://lbaas-11111111.balancer.oraclecloud.com"
34 | ```
35 |
36 | - Adjust the `server_count` and `dns_names` local variables if required.
37 |
38 | - Deploy the configuration
39 |
40 | ```sh
41 | $ terraform apply
42 | ```
43 |
--------------------------------------------------------------------------------
/examples/opc/windows-instance-with-rdp/windows-server.tf:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2017, 2019, Oracle and/or its affiliates. All rights reserved.
2 | // Licensed under the Universal Permissive License v 1.0 as shown at http://oss.oracle.com/licenses/upl.
3 |
4 | provider "opc" {
5 | user = "${var.user}"
6 | password = "${var.password}"
7 | identity_domain = "${var.domain}"
8 | endpoint = "${var.endpoint}"
9 | }
10 |
11 | data "template_file" "userdata" {
12 | vars = {
13 | admin_password = "${var.administrator_password}"
14 | }
15 |
16 | template = <