IBM Cloud: How to rename Code Engine project? - ibm-cloud

I created an IBM Cloud Code Engine project. The name was not well-chosen and needs to change. We already have a lot of resources in the project. I don't see an option to rename the project. Would I need to recreate the project and all its resources?

An IBM Cloud Code Engine project is the same as an IBM Cloud service instance. Thus, you can also manage it as a regular IBM Cloud resource. Use the CLI command service-instance-update to rename the project.
Check for the projects:
$ ibmcloud ce proj list
Getting projects...
OK
Name ID Status Enabled Selected Tags Region Resource Group Age
toBeRenamed 0f36e9e0-2xyz-41bc-bxyz-2be32980e018 active true true eu-de default 10d
Rename the Code Engine project as resource instance:
ibmcloud resource service-instance-update toBeRenamed -n newCEproject
Check the project again:
$ ibmcloud ce proj list
Getting projects...
OK
Name ID Status Enabled Selected Tags Region Resource Group Age
newCEproject 0f36e9e0-2xyz-41bc-bxyz-2be32980e018 active true true eu-de default 87s

Related

IBM Cloud: How to bind Db2 Warehouse to Code Engine app?

I have an existing instance of Db2 Warehouse on Cloud which is deployed to an org and space. Now, I would like to bind that service to an app for deployment with IBM Cloud Code Engine.
ibmcloud ce application bind --name henriks-app --service-instance myDb2
myDb2 does not exist as IAM resource because it is a CF resource. How would I bind the two together? It seems that I would need to create some form of custom wrapper.
The best way to manually connect services to your Code Engine application is to add service credentials to a Code Engine secret, and then attach that secret to your application using environment variables or volume mounting.
While you're correct that Db2 Warehouse isn't a typical IAM-Enabled service type, based on the IBM Cloud Db2 Warehouse docs, it's possible to create a client connection with Db2 Warehouse using an IAM Service ID & API Key.
Here's how I'd "bind" the Db2 instance to a Code Engine app:
Create a new service ID from the IAM Service IDs page
Under "Assign Access" > "Access service ID additional access" > "IAM Service", you'll find "Db2 Warehouse" as an option, and you can configure exact permissions from there (e.g. which instance(s) to grant permissions to, which roles, etc)
Finish the configuration by clicking "Assign access"
Using the CLI, log in to your account and generate a new API Key, e.g. ibmcloud iam service-api-key-create mydb2key SERVICE_ID_NAME --output JSON > mydb2.json where SERVICE_ID_NAME is the name of the service ID created in Step 1
Target your Code Engine project, then create a new secret using the API Key JSON, e.g. ibmcloud ce secret create --name mydb2 --from-file MYDB2=mydb2.json
Attach the secret to your application as an environment variable, e.g. ibmcloud ce app update --name myapp --env-from-secret mydb2
After the app update goes through, your application will have access to an environment variable named MYDB2, which will have the value of a JSON object string containing your API Key.
You'll find more information about creating secrets and using secrets with applications in the Code Engine docs.

get-value project returns "unset"

I am trying to follow the tutorial on how to start up a gcloud cloud service.
https://cloud.google.com/cloud-build/docs/quickstart-build
In order to build a docker project I need to run this command.
gcloud config get-value project
This supposedly gives me the project-id which I am supposed to use in the next step.
However I get "(unset)" which I cannot use this in the next step :
How do I set my project-id? This tutorial seems to be wrong.
gcloud projects list will give you the list of projects. Find the project id from that list and use it in gcloud config set project <projectid>.
If you don't get the list of projects, use gcloud auth login to login to your GCP account and then execute above commands.

setting up Ibm-cloud organization

setting up Ibm-cloud organization
I was trying to do "ibmcloud cf push" for the simple project that I found in github but it shows me "No org targeted"! I tried to just set the organization that I can find in my account in IBM-cloud> cloud foundry orgs which is my email address so I tried to use "cf target -o ORG" but it shows "Could not get org"!
API endpoint: https://cloud.ibm.com
Region: us-east
User: XXX#yahoo.com
Account: sonia's Account (XXXX)
Resource group: Default
CF API endpoint: https://api.us-east.bluemix.net (API version: 2.128.0)
Org:
Space:
I solved it!!!
first I unset my region and set it to the south-us
after that, I could use those commands for setting the organization and space
ibmcloud target -o Myorg
If you want to be able to push Cloud Foundry applications in a different region, you can add a space to your org in that region. That way you are then able to target your default org in different regions.
Within the cloud.ibm.com UI navigate to "Manage->Account" and then on the menu on the left select "Cloud Foundry Orgs". You will see a list of Cloud Foundry organizations. If you select an org in the next screen you can add a Cloud Foundry space to that org and choose the region where you want to create the space.
After you have done that you are able to target the CF org and CF space in the new region.
I usually use:
ibmcloud target --cf
For a friendly menu.
Make sure you login to the same region as your account. Use the login passcode from the console UI profile menu to login and choose the right location. When i did so my org was populated correctly in the CLI.

How to get meaningful alias or name for provisioned service in IBM Cloud?

I am using the CLI command bx service create to provision a new service. Some of the services support resource groups. For them, I noticed that the service itself has a long generic name and is listed under "Services". The name I chose is only associated with an alias, listed under "Cloud Foundry Services".
How can I get those services to use the name I picked?
The trick is to use another IBM Cloud CLI command. It is part of the set of commands to manage resource groups and its objects:
bx resource service-instance-create
Using the above command, the name is used for the service and there is no alias created. The service is only listed under "Services". Here is a full example:
bx resource service-instance-create ghstatsDDE dynamic-dashboard-embedded lite us-south

Detect Google Cloud Project Id from a container in Google hosted Kubernetes cluster

Detect Google Cloud Project Id from a container in Google hosted Kubernetes cluster.
When connecting to BigTable; I need to provide the Google Project Id. Is there a way to detect this automatically from within K8s?
In Python, you can find the project id this way:
import google.auth
_, PROJECT_ID = google.auth.default()
The original question didn't mention what programming language was being used, and I had the same question for Python.
You can use the metadata service. Example:
curl -H "Metadata-Flavor: Google" -w '\n' http://metadata.google.internal/computeMetadata/v1/project/numeric-project-id
This will work from any VM running on Google Compute Engine or Container Engine.
See https://cloud.google.com/compute/docs/storing-retrieving-metadata:
Google Compute Engine defines a set of default metadata entries that provide information about your instance or project. Default metadata is always defined and set by the server.
...
numeric-project-id The numeric project ID of the instance, which is not the same as the project name visible in the Google Cloud Platform Console. This value is different from the project-id metadata entry value.
project-id The project ID.
Google has some libraries for this too: ServiceOptions.getDefaultProjectId
https://googleapis.github.io/google-cloud-java/google-cloud-clients/index.html
https://github.com/googleapis/google-cloud-java/blob/master/google-cloud-clients/google-cloud-core/src/main/java/com/google/cloud/ServiceOptions.java
https://github.com/googleapis/google-cloud-java/tree/master/google-cloud-clients/google-cloud-core