Info |
---|
Since Cloudaware is built on force.com, address Salesforce CLI which is a powerful command line interface that simplifies development and build automation when working with your Salesforce instance. |
...
Install Salesforce CLI application
1. Download and install the Salesforce CLI application for your OS using this link.
2. Open Terminal (or Windows Command Prompt) and run the command sfdx
to make sure the application was successfully installed.
...
The JWT-based authorization flow requires a digital certificate and the a private key used to sign the certificate. You upload the digital certificate to the custom connected app that is also required for JWT-based authorization. This process produces two files:
...
1. If necessary, install OpenSSL on your computer. To check whether OpenSSL is installed on your computer, run this command:
which openssl
2. In Terminal or Windows Command Prompt, create a directory to store the generated files , and change to the directory.:
mkdir /Users/jdoe/JWT
cd /Users/jdoe/JWT
3. Generate a private key , and store it in a file called server.key.:
openssl genrsa -des3 -passout pass:xxxx -out server.pass.key 2048
openssl rsa -passin pass:xxxx -in server.pass.key -out server.key
WHERE
xxxx - a password containing 4 characters minimum. Newer versions of Linux Open SSL are more demanding in terms of password requirements.
You can delete the file server.pass.key file as you will no longer need it.
...
Create a Connected App in Your Salesforce Org
1. Log in to your Cloudaware account.
2. Open the main menu under your username. Go to Setup → Build: Create → section ‘Build' on the left → under 'Create' select Apps → ' Connected Apps ' → New.
...
3. Enter a meaningful connected app name and your email address.
4. In 'API (Enable OAuth Settings)' check the box Enable OAuth Settings.
5. For the Callback URL enter paste http://localhost:1717/OauthRedirect.
6. Check the box Use digital signatures. Click Choose File and upload the server.crt file that contains your digital certificate.
...
9. Review Connected App details. Click Manage.
...
10. Click Edit Policies. In the Under 'OAuth Policies' section, select 'Admin approved users are pre-authorized for ' in Permitted Users. Click OK in the popup message.
...
11. Click Save.
12. Go back to Setup → Build: Create → the section 'Build' on the left → under 'Create' select Apps → select the created app. Under 'Profiles' click Manage Profiles to select profiles of those users who will have access to the app. CloudAware Collector Only and CloudAware Administrator should be selected by default. Click Save.
13. Optional: if you would like to allow all users access the app using their credentials in CLI, select the app → Edit policies → select 'All users may self-authorize' in the section 'OAuth Policies' section.
Authorize a Salesforce Org for Use with Salesforce CLI
...
-u - authentication username (Setup → under the section 'Administer' on the left select Manage Users → Users → click the user → copy username)
...
-i - consumer key of the Salesforce connected app created earlier (Setup → Build: Create → the section 'Build' on the left → under 'Create' select Apps → select the app → copy the value from 'Consumer Key')
...
Note that you must use API names to run SOQL queries against Cloudaware objects and fields. To locate API names, go to Setup → Create → under the section 'Create' select Objects → select an object in question.
...
Let's execute a sample SOQL query that will return AWS EC2 instances that are not deleted from AWS with Accounts, Private IPs and Public IPs:. Use the sample query below replacing the value of -u parameter by -a value.
sfdx force:data:soql:query -q "Select CA10__account__r.Name, CA10__instanceId__c, CA10__privateIpAddress__c, CA10__publicIpAddress__c from CA10__CaAwsInstance__c where CA10__disappearanceTime__c =null" -u ‘text’
...