How to deploy two grails app to cloudfoundry in separate databases - mysql

Deploying a grails app to cloudfoundry was quite easy. Now I would like to push another app to cloudfoundry. However, the 2nd app create tables in the exact same database as my first app. I understand it will run side by side, however, I do want to treat them as separate entity and would like to run the two apps in two database. Please tell me how it can be done so.

I'm not sure what method/plugin/CLI tools you are using for deployment to Cloud Foundry, but if you're using the Cloud Foundry Integration plugin, this may help.
I was able to deploy 2 separate apps bound to 2 different instances of MySQL services. The key info here is the "binding" of the services to your deployed app. It's possible that you've bound both your apps to one service. If you're using the CFI plugin, issue a cf-apps and it will list your apps and what services they are bound to
+-------------+----+---------+--------------------------+--------------------+
| Application | # | Health | URLs | Services |
+-------------+----+---------+--------------------------+--------------------+
| app1 | 1 | RUNNING | app1.cloudfoundry.com | mysql-3xxxxxx |
+-------------+----+---------+--------------------------+--------------------+
| app2 | 1 | RUNNING | app2.cloudfoundry.com | mysql-exxxxxx |
+-------------+----+---------+--------------------------+--------------------+
If your apps are indeed bound to the same service, just do the following with the CFI plugin
remove the incorrectly bound app
issue a cf-create-service service-you-want
take note of the service name of the newly created app
re-deploy your second app and bind to the new service you just created
grails prod cf-push --services=your-new-service-name-xxxx
NOTE: when you deploy, the CLI tool may ask you to optionally bind to the other service (the first app's service), which you don't want, so you'll need to answer appropriately. I'm not sure why it does that even when you've explicitly passed in the --services argument with the service you want.
Anyway, it's all in the docs and if you're not using the CFI plugin - IMHO you should - it's pretty awesome plugin.

Related

Using Gen 2 CF instead of Gen 1 CF in Google Cloud

I'm new to this and I need some help with Google Cloud.
Basically, I was trying to create a project which uses many different CF and even works with DialogFlow CX.
The problem is that if I try to use a Gen 2 CF it gives me authentication problems if I set it 'Private'.
Is it possible to use the CF without setting that public or using a Gen 1 CF?🙏🏻
You can find good references at the Securing Cloud Functions documentation.
Basically, the default deployment is private which will require some sort of authentication (user account based or service account based -- more details on the doc aforementioned).
So, if I understood the scenario correctly, you just need to properly setup the authentication configuration and then your scenario of Dialogflow interacting with a Google Cloud Function service will work as expected.

Running two Azure Web Apps on different subdomains of the same domain

I have a multi-tenant web app where each tenant has their own subdomain -- tenant.thing.co.uk.
Can I set up two Azure Web Apps on different subdomains and move the tenant to a sub-sub domain like this:
tenant.app1.thing.co.uk and
tenant.app2.thing.co.uk?
In the Azure Web App under Custom domains I can enter *.app1.thing.co.uk and add TXT and CNAME records to my DNS to get the validation to pass: there is one TXT record and two CNAME records:
| Name | Data |
| -----| -------------- |
| app1 | thing-app.azurewebites.net |
| app2 | thing-app2.azurewebsites.net |
But it doesn't work! (Firefox says: Server not found.)
However, if I add one CNAME for *.thing.co.uk and add *.app1.thing.co.uk to one Azure Web App (and delete the other Azure Web App) then the website appears and the tenant subdomains work.
So: what's going wrong with two apps?
Add an A Record for each subdomain pointing to the IP address of each App Service.
The answer appears to be:
In DNS:
add a TXT record with name asuid.subdomain for each subdomain, and
add a CNAME record with name *.subdomain and value the azure web app domain name.
In Custom domains for the Azure web app:
add a custom domain *.subdomain.domain.tld, and
add a custom domain subdomain.domain.tld.
So the fix for me was to add two -- not one -- custom domains in the Azure website.

Generate list of IPs used by AWS Lamba

I have an IoT Enterprise button that (when pressed) triggers a Lambda function. The Lambda function sends an API "put" request to my Philips HUE bridge, which turns on (or off) my Living Room lights.
That much is 100% done. Life is good.
My question:
Is there a specific AWS service that is used to "send" the API request?
I'm assuming that the AWS Lambda service performs this action. But maybe not...
I need to create a firewall rule that (only) allows "Lambda servers" to pass-through my firewall.
If the destination IP = my WAN IP.
If the destination port = ##.
I found the following resource, that explains how to list all IPs owned by AWS.
https://docs.aws.amazon.com/general/latest/gr/aws-ip-ranges.html
Here is a quote from the reference guide:
service
The subset of IP address ranges. The addresses listed for API_GATEWAY are egress only.
Specify AMAZON to get all IP address ranges (meaning that every subset is also
in the AMAZON subset). However, some IP address ranges are only in the AMAZON subset
(meaning that they are not also available in another subset).
Type: String
Valid values:
AMAZON | AMAZON_CONNECT | API_GATEWAY | CLOUD9 | CLOUDFRONT |
CODEBUILD | DYNAMODB | EC2 | EC2_INSTANCE_CONNECT | GLOBALACCELERATOR |
ROUTE53 | ROUTE53_HEALTHCHECKS | S3 | WORKSPACES_GATEWAYS
As you can see, "Labda" isn't a valid (service) string value. I suppose I could allow any IP from the "us-east-1" AWS region. However this is (still) too permissive for my liking. (225 subnets) By comparison, if you specify "EC2" as the service, that narrows the list down to 82 subnets.
Thanks (in advance) for your helpful insight!
If you want to limit to a specific set of IPs (outside the AWS Public Zone) you will need to run your Lambda inside your VPC in a private subnet and then assign a NAT Gateway with an EIP.
See more: https://aws.amazon.com/premiumsupport/knowledge-center/internet-access-lambda-function/

how to get number of pcf instances running in java code?

I have an app that uses spring rest and deployed on PCF. Now inside the code I have to get the number of PCF instances running currently. Can anyone help?
Before I answer this - why do you want to know? It's an anti-pattern for cloud native apps to know about their peers; they should each be working in total isolation.
You can discover this by looking up application details by GUID in the CloudController. You can get your current app's GUID in the VCAP_APPLICATION environment variable.
https://apidocs.cloudfoundry.org/245/apps/get_app_summary.html
In order to hit the CloudController your app will need to know the system domain of your Cloud Foundry (eg api.mycf.com) and credentials that allow it to make that request.

Transform service types when using Bluemix Cloud Integration Service

I have been doing some research about the IBM Bluemix Cloud Integration Service and found the following links:
ftp://public.dhe.ibm.com/cloud/bluemix/cloudintegration/Cloud_Integration_for_Bluemix_User_Guide.pdf
https://www.ng.bluemix.net/docs/services/CloudIntegration/index.html
From what I have read, I have not been able to understand whether it is able to run some kind of "protocol transformation" or if it just publishes a REST or SOAP API.
I mean, imagine for example that I have a full backend publishing everything as SOAP services, but for some reason my apps only can get information through REST APIs. Does the basic connector o maybe the standard one make that kind of integration? Or do I need to put a third party product (or maybe even DataPower) to make that transformation?
Using the Cloud Integration service you can also create a REST API that links to an existing on-premises API (both SOAP and REST). Please take a look here: Creating a REST API that links to an existing on-premises API. You can upload a file that defines the on-premises API (WSDL or Swagger definition).
Please note that currently Cloud Integration cannot retrieve automatically that definition from your on-premises system. It has to be uploaded manually by the user.