cf-mta-examples icon indicating copy to clipboard operation
cf-mta-examples copied to clipboard

Example: SAP CP Destinations

Open ddonchev opened this issue 5 years ago • 5 comments

Create an example showing the modelling & creation of SAP CP "destinations" with an mta deploy. The example should cover both:

  • instance level destinations and sub-account level destinations
  • destinations to service instances (keys) & destinations to a route of an app within the same MTA

ddonchev avatar Jun 19 '20 09:06 ddonchev

Any timeline on this? I am really struggling with it atm!

psteinroe avatar Aug 10 '20 15:08 psteinroe

I hope those snippets & links to documentation help, until a suitable scenario covering all aspects is defined, and the documentation is done & reviewed:

resources:
- name: destination-service
  type: org.cloudfoundry.managed-service
  parameters:
    service: destination
    service-name: my-destination-service
    service-plan: lite
      config:  {
    "init_data" {
        "subaccount" : {
            "existing_destinations_policy": "update|fail|ignore",
            "existing_certificates_policy": "fail|ignore",
            "destinations" : [
                {
                    ...
                }
            ],
            "certificates" : [
                {
                    ...
                }
            ]
        },
        "instance" : {
            "destinations" : [
                {
                    ...
                }
            ],
            "certificates" : [
                {
                    ...
                } 
            ]
        }
    }
}

Here yaml and json are mixed (ugly but works). Have in mind that you can convert any json to yaml in the mta(d).yaml or can extract the config json to an external file and reference/overwrite it in the mta(d).yaml.

ddonchev avatar Aug 12 '20 10:08 ddonchev

  • sub-account level destinations - those are created not where the service instance is defined, but in a content module as this:
module:
- name: destination-content
  type: com.sap.application.content
  requires:
  - name: xsuaa_service
    parameters:
      service-key:
        name: xsuaa_service-key
  - name: destination-service
    parameters:
      content-target: true
  - name: myapp-route # required, in order to reference the app url from the module above
  parameters:
    content:
      subaccount:
        existing_destinations_policy: update
        destinations:
        - Name: myappOauth
           ServiceInstanceName: myApp-xsuaa-service 
            ServiceKeyName: xsuaa_service-key
           < ... destination definition here ... >

To create the special kind of service instance destination, you should pass some extra properties in the definition of the destination which reference the service instance for which the destination would be created/updated as the example above

ddonchev avatar Aug 12 '20 10:08 ddonchev

@steinroe, can you tell what kind of destinations/scenarios do you aim to use? This could help us making the example/tutorial more useful for others having your case.

ddonchev avatar Aug 12 '20 10:08 ddonchev

@ddonchev Thanks for providing the examples!

Essentially, I am trying to set up a really basic scenario: A Node.js Backend, an Approuter, and a React Frontend. However, although fairly basic, this is rather complex to set up due to the decision to run the Approuter as a separate application and deploy the react frontend to the html5 repositories. After several days of try and error I now finally got it all deployed and working. However, to develop offline, I somehow have to redirect to a locally running Webpack server instead of the HTML5 repo in CF. My idea was to use a custom destination pointing to a localhost endpoint for local development, and that is why I needed that information. However, with my current setup, this throws some really weird errors. Any help is greatly appreciated! Best Philipp

psteinroe avatar Aug 12 '20 13:08 psteinroe