cancel
Showing results for 
Search instead for 
Did you mean: 

Create destination during deployment

0 Kudos

Hello experts

I am developing a CAP application, where I have defined in the default-env.json my destinations as follows

{
"destinations":[
{
"name":"ZSFA2",
"url":"https:/***.***.***.***:*****/",
"username":"***",
"password":"***",
"HTML5.Timeout":"300000"
},
{
"name":"DERGA_SOAP_API_X20",
"url":"https://***.***.***.***:*****",
"username":"***",
"password":"***",
"sapClient":"200",
"isTrustingAllCertificates":"true"
}
]
}

I should have it create the targets as specified in the file when I deploy to my BTP sub-account.

I don't want to enter clear username and password directly in the mta, I guess there are other more correct solutions.

If it helps, here is my mta.

_schema-version: '3.1'
ID: sfadb
version: 1.0.0
description: "Shared db for sfa applications."
parameters:
enable-parallel-deployments: true
build-parameters:
before-all:
- builder: custom
commands:
- npm install --production
- npx cds build --production
modules:
#Main Module
- name: sfadb-srv
type: nodejs
path: gen/srv
parameters:
buildpack: nodejs_buildpack
build-parameters:
builder: npm-ci
provides:
- name: srv-api # required by consumers of CAP services (e.g. approuter)
properties:
srv-url: ${default-url}
requires:
- name: authenticator_service
- name: db-sfadb
- name: destination
- name: Connectivity-srv
# Approuter
- name: sfadb-approuter
type: nodejs
path: app/ # from cds.env.folders. Consider also cds.env.build.target -> gen/app
parameters:
keep-existing-routes: true
disk-quota: 512MB
memory: 512MB
provides:
- name: approuter-api # required by consumers of CAP services (e.g. approuter)
properties:
srv-url: ${default-url}
requires:
- name: srv-api
group: destinations
properties:
name: srv-api # must be used in xs-app.json as well
url: ~{srv-url}
forwardAuthToken: true
- name: authenticator_service
# DB Deployer Module
- name: db-deployer
type: custom
path: gen/db
parameters:
buildpacks:
- https://github.com/cloudfoundry/apt-buildpack#v0.3.0
- nodejs_buildpack
no-route: true
no-start: true
disk-quota: 2GB
memory: 1024MB
tasks:
- name: deploy_to_postgresql
command: export JAVA_OPTS="-Xmx1g" && chmod 755 deploy.sh && ./deploy.sh
disk-quota: 2GB
memory: 1024MB
build-parameters:
ignore:
- "node_modules/"
requires:
- name: db-sfadb
#Content Deployer
- name: destination-content
type: com.sap.application.content
requires:
- name: authenticator_service
parameters:
service-key:
name: authenticator_key
- name: destination
parameters:
content-target: true
parameters:
content:
subaccount:
destinations:
- Authentication: OAuth2UserTokenExchange
Name: authenticator_service
ServiceInstanceName: authenticator_service
ServiceKeyName: authenticator_key
sap.cloud.service: sfa.service
existing_destinations_policy: update
build-parameters:
no-source: true
resources:
- name: authenticator_service
type: org.cloudfoundry.managed-service
parameters:
service-name: authenticator_service
service: xsuaa
service-plan: application
path: ./xs-security.json
config:
xsappname: auth-${space}
tenant-mode: dedicated
- name: destination
type: org.cloudfoundry.managed-service
requires:
- name: srv-api
- name: approuter-api
parameters:
service: destination
service-name: destination-service
service-plan: lite
config:
init_data:
subaccount:
existing_destinations_policy: update
destinations:
- Name: sfadb_srv_api
Description: CAP sample service
Authentication: NoAuthentication
ProxyType: Internet
Type: HTTP
URL: ~{srv-api/srv-url}
HTML5.DynamicDestination: true
HTML5.ForwardAuthToken: true
- name: db-sfadb
parameters:
path: ./pg-options.json
service: postgresql-db
#service-plan: trial # BTP trial
service-plan: free # BTP CPEA - free
#service-plan: standard # BTP CPEA - standard (not free)
service-tags:
- plain
skip-service-updates:
parameters: true
type: org.cloudfoundry.managed-service
- name: Connectivity-srv
type: org.cloudfoundry.managed-service
parameters:
service: connectivity
service-plan: lite

Thank you

Good day

Accepted Solutions (1)

Accepted Solutions (1)

Dinu
Contributor
0 Kudos

You may provide these additional destinations as subaccount destinations `templates` in the mta. Later you can fill in the details for these destinations in BTP cockpit. But, don't specify the existing_destinations_policy as update for these. You don't want to fill in the details every time you deploy.

But, you don't have to provide these destination templates. You can go ahead and directly create these destinations with correct names and credentials in the subaccount as well.

Answers (1)

Answers (1)

lothar_bender
Advisor
Advisor
0 Kudos

Hybrid Testing might be what you are looking for.

Use the cds bind command to connect your application to services on the cloud without storing user and password locally. Start your application with the hybrid profile to use these service bindings. You can switch between local mock configuration and cloud service configuration by simply setting or omitting the profile parameter...

0 Kudos

Thanks for the answer, I would like a clarification though: Hybrid Testing allows me to test the application with cloud service configuration, but my current goal is to be able to create destinations in my btp by deploying the application. Does Hybrid Testing give me this possibility?

lothar_bender
Advisor
Advisor
0 Kudos

Yes, hybrid testing only allows you to locally test your application with cloud service configuration. It does not create destinations. I missed that your question is about creating destinations, sorry for confusion.