Wednesday, January 3, 2024

#1000 OIC GCP Pub/Sub adapter

Multicloud support has been a focus of the latest releases of OIC3, which now includes adapters for  

  • Azure Active Directory
  • Azure Event Grid
  • Azure Service Bus
  • Azure Storage
  • GCP Pub/Sub
  • GCP Storage
This post will look at the GCP Pub/Sub adapter

Again, the usual caveat - I am not a GCP expert, but here I cover what you need to demo usage of the adapter in OIC. Part 1 will cover using the adapter to Invoke GCP Pub/Sub, i.e. to push a message to a topic. Part 2 will look at using this adapter as a Trigger, i.e. the subscriber.

First step is to create a Google Cloud account - you will need a credit card, but this is for identification purposes. Once created, you get $300 or €271 credit.


Next step is to create a topic in Pub/Sub.


Now to the security stuff - 




 



Add the OIC callback url for your instance - 























Copy the client id and secret for future use - 


Go to the OAuth Consent screen, here you will have to add your google user, as this is a project in "Test" status.






Now to OIC - 


I create this connection for Invoke - as you can see, I add the project id of My First Project and the client id and secret.


I then click Provide Consent - 
Apologies for the German, but you see I am using the google account I added to the OAuth consent screen.


 
























The reason you see "already has some access" is because I am doing this for the second time.

That's it! Back in OIC - click Test - 


Create an integration - app driven. This will push a message to the topic, in my case, a simple order.





I then do the mapping, activate and run -


Check in GCP - 
I created a subscriber in GCP to pull the data. This was very easy - 


Part 2

Create a service account in your GCP project - 


I note the client id.

Next step is to - Create a user in the Oracle Cloud Infrastructure identity domain that has the same user name as the service account's client ID and assign it at least the ServiceInvoker role.


Then I create a new GCP Pub/Sub connection - 

Provide Consent as above. Then use the newly created connection as a trigger in a new app driven integration.






The only processing logic is a Logger action, which logs the orderNr.

I now test the invoke and trigger by pushing a new order to the topic - 






I check out the activity stream of the subscriber - 



Monday, December 18, 2023

#999 23.12 - Publishing OIC endpoints to OCI API Gateway in detail



Welcome to this post, which will look at the publishing of OIC endpoints to OCI API Gateway.
I'm starting from scratch, with a new OIC3 instance -






This functionality is available only in domain enabled tenancies. I this demo, I will be provisioning the OCI API Gateway in the same compartment as OIC.

RPST is used for OIC to access api gateway, which is, in essence, just another Oracle Cloud Infrastructure resource. To this end, we will need the client id of the OIC instance I just created. 

So let's go to our domain - 



 



I save the Client ID for future use.

Create a Dynamic Group


Next step is to create a dynamic group, through which we will be able to grant gateway access to the api gateway. This group will only have 1 member to begin with, the OIC3 instance I just created. Naturally, I could have multiple entries i.e. many OIC3 instances publishing to the same gateway.

Here is my Dynamic Group definition - 



 - 

resource.id = 'client id'


Create a Policy


Now we need to create a policy which will enable this dynamic group to manage API Gateway in my compartment -

The Policy definition has the following format - 

allow dynamic-group yourGroup to manage api-gateway-family in compartment yourCompartment


Pre-requisites for Creating the API Gateway


Create a Virtual Cloud Network and Subnet


I create the VCN in my compartment NiallC-2312. As you can see, I set the CIDR Block value to 10.0.0.0/16

I accepted the defaults for all the other fields.

Create a Subnet


I set the CIDR Block to 10.0.0.0/24.
Subnet Type - Regional
Subnet Access : Public Subnet

Create an Internet Gateway

All you need here is a name.

Add Rules to the VCN Security List

Add the following Ingress rule - 





The following Egress rule should be present - 


Add a Route Rule to the VCN Route Table



Create a Network Security Group







That's it - pre-reqs completed!

Provision the OCI API Gateway

Give it a name and select the VCN and Subnet you just created. Accept defaults for the rest.


Create a test Deployment and route

This is a quick test to ensure our gateway is accessible. I create a deployment called Test and add a route. Note, I use a stock response here.




I will now test this from Postman - 
The deployment url can be found here - 



Publishing from OIC

Integrations need to be within a project, activated and also "public". 

For "public" just check the following box, when creating an integration -










































There's our TestDeployment. In this case, I'll create a new deployment - Netsuite. Ergo, we can select an existing deployment or create a new one. Whichever we choose the OIC endpoint will be created as a route within that deployment.





































I can, of course, view the deployment details -



Now to testing the invoke of the OIC endpoint via the api gateway. Again, I use Postman here.

First test is to invoke the OIC endpoint directly from Postman. This will leverage OAuth - the setup required is detailed in this other post


Looks good! Now to the route in the Netsuite deployment - 


The path, as you can see, is /netsuite/customer.

The Deployment url is - https://myGateway.apigateway.us-phoenix-1.oci.customer-oci.com/netsuite

So let's test this from Postman -