A. Set up your tenancy
B. Create, deploy, and call your API on an API gateway
A. Set up your tenancy
1Create groups and users
Suitable users and groups to create and access API gateway and network resources might exist already. If so, skip forward to the next task. If not, log in to the Console as a tenancy administrator and under Governance and Administration, go to Identity, and then:
Create a new group by clicking Groups and then Create Group.
Create a new user by clicking Users and then Create User.
Add a user to a group by clicking Groups, then the name of the group, and then Add User to Group.
See documentation for more details.
2Create compartment
A suitable compartment in which to create API Gateway resources and network resources might already exist. If so, skip forward to the next task. If not, log in to the Console as a tenancy administrator and under Governance and Administration, go to Identity, and then:
Click Compartments and then Create Compartment.
Make a note of the name you give the compartment, as you'll need it later.
See documentation for more details.
3Create VCN and subnets
To ensure high availability, API gateways can only be created in regional subnets (not AD-specific subnets). A suitable VCN with a regional public subnet might already exist. If so, skip forward to the next task. If not, log in to the Console as a tenancy administrator and under Core Infrastructure, go to Networking, and then:
Click Virtual Cloud Networks and choose a compartment in which to create the VCN (either the same compartment that will contain API Gateway resources, or a different compartment).
Click Start VCN Wizard, then VCN with Internet Connectivity, then Start VCN Wizard. As well as the VCN, the workflow will create a public regional subnet and a private regional subnet, along with an internet gateway, a NAT gateway, and a service gateway.
Enter a name for the new VCN and specify CIDR blocks for the VCN, the public regional subnet (must provide a minimum of 32 free IP addresses), and the private regional subnet.
Click Next to review the details you entered for the new VCN, and click Create to create it. When the VCN has been created, click View Virtual Cloud Network to see the new VCN and the subnets that have been created.
The API Gateway communicates on port 443, which is not open by default. You have to add a new stateful ingress rule for the public regional subnet to allow traffic on port 443.
Click the name of the public regional subnet, then the name of the default security list, and then click Add Ingress Rules. Specify:
• Source Type: CIDR
• Source CIDR: 0.0.0.0/0
• IP Protocol: TCP
• Source Port Range: All
• Destination Port Range: 443
Click Add Ingress Rules to add the new rule to the default security list.
See documentation for more details.
4Create IAM policies
Log in to the Console as a tenancy administrator and under Governance and Administration, go to Identity and click Policies, and then:
Create policies to give API developers access:
• Select the compartment that will own API Gateway-related resources and create a policy with one policy statement to enable API developers to access all API Gateway-related resources in that compartment:
Allow group <group-name> to manage api-gateway-family in compartment <compartment-name>
• Select the compartment that owns the network resources to use with API Gateway and create a policy with one policy statement to enable API developers to access those network resources when creating API gateways:
Allow group <group-name> to manage virtual-network-family in compartment <compartment-name>
Note: The above policies are sufficient to enable you to create an API deployment with an HTTP back end, as suggested in this QuickStart. To enable API developers to create API deployments with Oracle Functions functions as back ends, you enter additional policies (as described in the documentation).
See documentation for more details.
B. Create, deploy, and call your API
1Create your first API gateway
Log in to the Console as an API Gateway developer and under Solutions and Platform, go to Developer Services and click API Gateway, and then:
Click Create Gateway and specify:
• a name for the new gateway, such as acme-api-gateway
• the type of the new gateway as Public
• the name of the compartment in which to create API Gateway resources
• the name of the VCN to use with API Gateway
• the name of the regional subnet in the VCN
Click Create.
When the new API gateway has been created, it is shown as Active in the list on the Gateways page.
See documentation for more details.
2Create your first API deployment
On the Gateways page in the Console, click the name of the API gateway you created earlier.
Under Resources, click Deployments, and then click Create Deployment.
Click From Scratch and in the Basic Information section, specify:
• a name for the new API deployment, such as acme-api-deployment
• a path prefix to add to the path of every route contained in the API deployment, such as /v1
• the compartment in which to create the new API deployment
Click Next and in the Route 1 section, specify:
• a path, such as /hello
• a method accepted by the back-end service, such as GET
• the type of the back-end service, and associated details. For convenience, specify the type as HTTP
and enter a public API as the back end's url (such as https://api.weather.gov
).
Click Next to review the details you entered for the new API deployment, and click Create to create it.
When the new API deployment has been created, it is shown as Active in the list of API deployments.
When the API deployment is active, go on to the next task.
See documentation for more details.
3Call your first API
In the list of API deployments, click Copy beside the endpoint of the new API deployment you just created to copy the endpoint.
Open a terminal window and call the API by entering:
$ curl -k -X GET <deployment-endpoint>
where <deployment-endpoint>
is the endpoint that you copied in the previous step. For example, https://lak...sjd.apigateway.us-phoenix-1.oci.customer-oci.com/v1/hello
Congratulations! You've just created your first API gateway and API deployment, and called your first API using the API Gateway service!
See documentation for more details.
4Next steps
Now that you've created, deployed, and called an API, read the documentation to find out more about:
• managing API gateways and API deployments (see Listing API Gateways and API Deployments, Updating..., Deleting...)
• limiting the number of requests (see Limiting the Number of Requests to API Gateway Back Ends)
• adding CORS support (see Adding CORS support to API Deployments)
• adding stock responses (see Adding Stock Responses to API Deployments)
• confirming API caller identity and permissions (see Adding Authentication and Authorization to API Deployments)
You're done!
Find out more about Oracle Cloud Infrastructure and API Gateway