Skip to Content
0
Jul 31, 2023 at 07:44 AM

Create destination during deployment

309 Views Last edit Jul 31, 2023 at 07:47 AM 3 rev

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