Create a Serverless Website with Alibaba Cloud Function Compute

Regarding to Wikipedia, Serverless computing is a cloud computing execution model in which the cloud provider runs the server, and dynamically manages the allocation of machine resources. Pricing is based on the actual amount of resources consumed by an application, rather than on pre-purchased units of capacity

Today i will show you an example how to create serverless website but this time not using Amazon AWS, Azure or OCI but Alibaba Cloud Provider.

Create a Function Compute Service

Go to the console page and click through to Function Compute.

Click the add button beside Services.

In the Service slide out, give your service a name, an optional description, and then slide open the Advanced Settings.

In Advanced Settings you can grant access for Functions to the Internet, to VPC resources, and you can attach storage and a log service to a Function. You can also configure roles.

For our tutorial, we will need Internet access so make sure this configuration is on.

We will leave VPC and Log Configs as they are.

In the Role Config section, select Create New Role, and in the dropdown list pick AliyunOSSReadOnlyAccess as we will be accessing our static webpages from an Object Storage Service bucket.

Click Authorize.

You will see a summary of the Role you created.

Click Confirm Authorization Policy.

You have successfully added the Role to the Service.

Click OK.

ou will see the details of the Function Compute Service you just created.

Now let’s create a Function in the Service. Click the add button next to Functions.

You will see the Create Function process. The first part of the process is Function Template.

There are many Function Templates available, including an empty Function for writing your own bespoke Functions.

Alibaba Cloud-supplied Template Functions are very useful as they have relevant method invocation and demo code for getting started quickly with Function Compute.

let’s choose the flask-web Function written in Python2.7.

Click Select.

We are now at the Configure Triggers section of creating a Function.

Select HTTP Trigger from the dropdown list. Give the Trigger a name and choose Authorization details (anonymous does not require authorization).

Choose your HTTP methods and click Next. We are going to build a simple web-form application so we will need both the GET and POST HTTP methods.

Now we arrive at the Configure Function Settings.

Give the Function a name then scroll down to Code details.

We’ll leave the supplied code for now. Scroll down to below the code sample.

You will see Environment Variable input options and Runtime Environment details.

Click Next.

Click Next at Configure Function Permissions.

Verify the Configuration details and click Create.

You will arrive at the Function’s IDE. Here you can enter new code, edit the code directly, upload code folders, run, test, and fix your code.

Scroll down.

Copy the URL as we will need to add this to our static webpages so they can connect to our Function Compute Service and Function.

Set Up and Configure an OSS Bucket

Click through to Object Storage Service on the Products page.

If you haven’t yet activated Object Storage Service, go ahead and activate it. In the OSS console, click Create Bucket.

Choose a name for the OSS Bucket and pick the region – you cannot change the region later. Select the Storage Class – you also cannot change this later.

We have selected Public Read for the Access Control List.

When you’re ready, click OK.

You will see the Overview page for your bucket. Make a note of the public Internet URL.

In the Files tab, upload your static web files.

I uploaded a simple index.html homepage and a background picture.

<script type="text/javascript">
        const functionURL = '<<Function URL>>';
        const doHome = new XMLHttpRequest();'GET', functionURL, true);
doHome.onload = function () {    
document.getElementById('home_message').innerHTML = doHome.responseText;

In Basic Settings, click Configure to configure your Static Pages.

Add the homepage details and click Save.

Now go to a new browser window and access the OSS URL you saved earlier.

Back in the Function Compute console, you can now test the flask-app paths directly from the code.

We already tested index.html with no Path variable. Next, we test the app route signin with GET and check the Headers and status code.

The signin page code is working correctly. You can also check the Body to make sure the correct HTML will render on the page. Notice that because I entered the path variable, signin is appended to the URL.

Of course, any errors you encounter will show up in the Logs section for easy debugging.

Now, let’s test this page on the Internet.

If you get an error here, implement a soft link for the page in OSS. Go to the OSS bucket and click More dropdown for the HTML file in question and choose Set soft link.

Give the link a name and click OK.

A link file will appear in the list of static files and you will now be able to access the page online with the relevant soft link and it will render as above.

Back in Function Compute, we can test the POST method in the console with the correct username and password details in the same way.

Add the POST variables to the form upload section in the Body tab.

Now you can test this function online.



Terraform for Oracle Cloud infrastructure

This post provide steps for downloading and installing both Terraform and the Oracle Cloud Infrastructure Terraform provider.

Terraform Overview

Terraform is “infrastructure-as-code” software that allows you to define your infrastructure resources in files that you can persist, version, and share. These files describe the steps required to provision your infrastructure and maintain its desired state; it then executes these steps and builds out the described infrastructure.

Infrastructure as Code is becoming very popular. It allows you to describe a complete blueprint of a datacentre using a high-level configuration syntax, that can be versioned and script-automated, Terraform can seamlessly work with major cloud vendors, including Oracle, AWS, MS Azure, Google, etc

Download and Install Terraform

In this section, i will show and explain how to download and install Terraform on  your laptop/PC Host Operating System, you can download using the below link :-

Terraform Download
  • After you download the terraform, Unzip the Terraform to whatever location you want to run it from. Then, add that location to your OS PATH.
    • Windows : By adding to Path –> environment variables
    • Linux : Profile –> export Path

You can check by run the CMD and check the version:-

Check Terraform commands

Download the OCI  Terraform Provider


  • OCI User credentials that has  sufficient permission to  execute a Terraform plan.
  • Required keys and Oracle Cloud Infrastructure IDs (OCIDs).
  • The correct Terraform binary file for your operating system

Installing and Configuring the Terraform Provider

In my personal opioion about this section (The title of the section same as Oracle Documentation) I found it wrong, i worked with Terraform in different cloud vendor, AWS, Azure and OCI so Terraform will recognize it and automatically install the provider for you.

to do that, all of you have to do is create folder , then create file “” that only contains

provider "oci" {<br>}

and run terraform command

terraform init

Now Let’s Talk small examples about OCI and Terraform, First you have to read “Creating Module” to understand the rest of this post here.

I will upload to my Github here Small Sample for OCI Terraform to allow you underatand how we can use it instead of the GUI and make it easy for you.

I upload to my github example of Terraform for OCI Proiver, In the this example i will create autonomous database but not using the GUI,

to work with Terraform, you have to understand what is the OCI Provider and the parameters of it.

The Terraform configuration resides in two files: (which defines the provider oci) and (which defines the resource).

For more terraform examples here

Configuration File Requirements

Terraform configuration (.tf) files have specific requirements, depending on the components that are defined in the file. For example, you might have your Terraform provider defined in one file (, your variables defined in another (, your data sources defined in yet another.

Some of the examples for Terraform files here

Provider Definitions

The provider definition relies on variables so that the configuration file itself does not contain sensitive data. Including sensitive data creates a security risk when exchanging or sharing configuration files.

To understand more about provider read here

provider "oci" {
   tenancy_ocid = "${var.tenancy_ocid}"
   user_ocid = "${var.user_ocid}"
   fingerprint = "${var.fingerprint}"
   private_key_path = "${var.private_key_path}"
   region = "${var.region}"

Variable Definitions

Variables in Terraform represent parameters for Terraform modules. In variable definitions, each block configures a single input variable, and each definition can take any or all of three optional arguments:

  • Type (Optional): Defines the variable type as one of three allowed values: string, list, and map. If this argument is not used, the variable type is inferred based on default. If no default is provided, the type is assumed to be string
  • Default (Optional) : Sets the default value for the variable. If no default value is provided, the caller must provide a value or Terraform throws an error.
  • Description (Optional) : A human-readable description of the variable.

More information here

For example

variable "AD" {
    default     = "1"
    description = "Availability Domain"

Output Configuration

Output variables provide a means to support Terraform end-user queries. This allows users to extract meaningful data from among the potentially massive amount of data associated with a complex infrastructure.

More information here


output "InstancePublicIPs" {
value = ["${oci_core_instance.TFInstance.*.public_ip}"]

Resource Configuration

Resources are components of your Oracle Cloud Infrastructure. These resources include everything from low-level components such as physical and virtual servers, to higher-level components such as email and database providers, your DNS record.

For more information here

One of the example :-

resource "oci_core_virtual_network" "vcn1" {
   cidr_block = ""
   dns_label = "vcn1"
   compartment_id = "${var.compartment_ocid}"
   display_name = "vcn1"

Data Source Configuration

Data sources represent read-only views of existing infrastructure intended for semantic use in Terraform configurations, for example Get DB node list

data "oci_database_db_nodes" "DBNodeList" {
  compartment_id = "${var.compartment_ocid}"
  db_system_id = "${}"

Another example, Gets the OCID of the first (default) vNIC

data "oci_core_vnic" "DBNodeVnic" {
  vnic_id = "${data.oci_database_db_node.DBNodeDetails.vnic_id}"

Follow me on GitHub here



How to study for Oracle Cloud Infrastructure Developer 2020 Associate

Many of you knows that Oracle annouced before one month, the six track from Oracle university included the exams for free, so far i completed four of them and looking for the other two.

in this post i will discuss how to preapre for exam 1z0-1084-20, in my opioion, this exam it’s more DevOps exam, so if you know the knowledge with Docker and Kubernetes and worked on them, working with OCI (Oracle Cloud Infrastrcuture) before, go ahead and apply for this exam.

The funny thing when you pass one exam and post about it on the social media directly i start recieving multiple messages from different people i don’t know, asking “could you please provide us with the dumps ?” first of all, how did you assume i am using dump, i failed mulitple times in different Oracle exam, second, i am aganist the dumps for various reasons, the exam is prove that you are ready to go thru this track and work on it, imagine you put this on your resume and someone asked you question about it, it will not be professional for you.

However, i would like to discuss 1z0-1084-20 specially this one, because i didn’t feel it’s only related to Oracle, you should have knowledge with different criteria,

  • Docker
  • Kubernetes
  • Microservices
  • software architect patterns
  • Testing patterns
  • For sure OCI

When you are study for this exam, you should follow Lucas Jellema Blog here and you can follow him on twitter also.

This blog saved me alot of time and explained everything you need to know in details.

Exam TitleOracle Cloud Infrastructure Developer
2020 Associate
FormatMultiple Choice
Duration105 Minutes
Number of
Passing Score:70%
Exam Details

Exam Preparation

you need to focus on the following topics if you want to pass this exam :-

  • Develop application using OCI Developer tools, such as, APIs, SDKs and CLI
  • Develop a serverless application
  • Develop high performing applications & API
  • Manage & store the application code runtimes
  • Oracle Function
  • OCI container engine for kubernetes.
  • OCIR – Oracle Cloud Infrastructure Registry.

Wish you all the best