WSO2 API build and deployment - wso2-api-manager

I have created and published API's using API manager 2.6.0 now I need to push these changes to another environment like system & UAT testing environment.
Can someone help me on how I can configure any repository to push the APIs created using API manager and move from one environment to another. I checked few sites related to WSO2 migration and CI/CD implementation but I could not able to do that properly so I am looking for high level explanation to use repository and migration to different environments.

You can export and import APIs from different environments using the migration APIs or the CLI tool:
Export API as seen here: https://docs.wso2.com/display/AM210/Migrating+the+APIs+to+a+Different+Environment
Export CLI as seen here:
https://docs.wso2.com/display/AM260/Migrating+the+APIs+to+a+Different+Environment
The exported APIs are a set of json and xml files that can be templated, and unless your APIs endpoints in other environments are the same as your development one, you will have to modify the exported APIs jsons and xmls to fit the other enviroment's data.
The best way to set up a repository, will be then to:
Export from your development environment the API to a local machine
Create a template out of it to be used with your favorite template deployment engine
Upload this templates to a repository manager (nexus, artifactory...)
Write the script to fill the template for each environment,
Create another script to call the APIM import CLI or API to import the filled template to each enviroment.
This is all best done within some CI/CD pipeline.

Related

Firebase Deploy Error: 'Changing secrets is not supported' when using separate projects with Stripe 'Run Payments with Stripe' extension

I'm trying to setup multiple environments for my Vue / Firebase Project.
I have two Firebase Projects
1.) Dev
2.) Prod
The project utilizes Stripe Extension which pulls the API Key from an auto-generated file called:
firestore-stripe-payments.env
which contains:
STRIPE_API_KEY=projects/${param:PROJECT_NUMBER}/secrets/firestore-stripe-payments-STRIPE_API_KEY-xxxx/versions/latest
Where xxxx is a random 4 character string.
That line pulls the value of the key from Google Secret Manager.
Let's say Dev is 'dddd'
and Prod is: 'pppp'
The issue is that I can only define either:
firestore-stripe-payments-STRIPE_API_KEY-dddd
or
firestore-stripe-payments-STRIPE_API_KEY-pppp
At first I tried to create a new value within Google Secret Manager simply called:
firestore-stripe-payments-STRIPE_API_KEY
The thought was this should be a simple fix, and it would pull the associated API_KEY for the project currently being used.
but this causes the error:
Error: firestore-stripe-payments: Found 'projects/foo/secrets/firestore-stripe-payments-STRIPE_API_KEY/versions/latest' for secret param STRIPE_API_KEY, but this instance was previously using a different secret projects/fooo/secrets/firestore-stripe-payments-STRIPE_API_KEY-dddd.
Changing secrets is not supported. If you want to change the value of this secret, use a new version of projects/foo/secrets/firestore-stripe-payments-STRIPE_API_KEY-dddd.You can create a new version at https://console.cloud.google.com/security/secret-manager?project=fooo
Also, if there is a better place to ask this question please let me know, couldn't find the 'right' room
For this scenario, could you include a separate env (env.dev) file using the following guidelines
.env # loaded in all cases
.env.local # loaded in all cases, ignored by git
.env.[mode] # only loaded in specified mode
.env.[mode].local
For generating separate keys for each environment, I believe from your example you are using a single Stripe Extension on a single project.
Firebase Extensions can support multiple instances of an Extension per project, this will create a separate "dev" secret for you to use.
Additionally, a separate Firebase project with another "Stripe Extension" installation would be recommended to separate any concerns in development.

Secure storage of credentials from auth.json when using CI

We use CircleCI to build our PHP app prior to deployment. One of the requirements in composer is a module stored in a private repository on Bitbucket.
Currently we store the credentials inside composer.json which is far from ideal.
The problem is that I can find no better solution for managing these credentials for repo access during the build. I'm assuming I can use an environment variable or similar.
The environment variable COMPOSER_AUTH is available to pass any number of authentication methods to composer and allows any keys or secrets to be managed outside of the repo.
In my example, to authenticate with bitbucket, the var looked like this:
export COMPOSER_AUTH='{"bitbucket-oauth": {"bitbucket.org": {"consumer-key": "xxxxxx","consumer-secret": "xxxxxx"}}}' (see: documentation)
CircleCi (and I'd assume most CI apps) has an environment variable settings page. Add the variable and value there and then you can remove the entire "bitbucket-oauth" block from composer.json.

Can you have multiple endpoints/functions from a single .NET Core project in Google Cloud Run?

I have a single .NET Core .proj file and a single Google Cloud project. The .NET Core project is very simple with a single class implementing IHttpFunction and implementing HandleAsync which is the entrypoint. I have a Cloud Build trigger connected to this project's Git repository which is set to run whenever a commit is pushed into main.
I would like to have more functions-- and hoping to not duplicate common functionality between them -- add those functions to the same project. But when I have multiple classes implementing IHttpFunction, Cloud Build fails.
I think there are at least 2 other ways to do this:
Deploy manually and select a function - but can I do this with Cloud Build triggers too?
Have all functions go through a single "dispatcher" endpoint - which seems messy
What's a good way to do this?

Is it possible to generate models manually?

I have a JS project that uses aws services as a backend (Cognito, AppSync, S3, etc).
I use AWS Amplify to access these services but do not use the amplify CLI; all aws services are configuredd manually.
Regarding AppSync, I have a little script that reads the schema (downloaded manually from the appsync console) and then generates Typescript operations and operation types files (using amplify-graphql-docs-generator and amplify-graphql-types-generator).
Is it possible to do the same for models, ie generate a models file in typescript based on a local schema file ? Or in other words how can I replicate amplify codegen models inside a project that was not setup with the amplify-cli ?
You can probably check the implementation of the amplify codegen and find its inner workings
https://github.com/aws-amplify/amplify-cli/tree/master/packages/amplify-codegen
Or if you don't mind using the Amplify CLI, you can hook up an existing AppSync project running the following commands in sequence at the project root:
amplify init
amplify add codegen --apiId xxxx
amplify codegen

Database backup Azure Resource Manager

Is there a way in Azure Resource manager to take a copy of an existing database? Currently I know there is a database import option, which points to a bacpac file in Blob Storage and creates a new database from that file, but the process to create the file is a manual one at this point. With that, what is the current process to create bacpacs and put them in Blob storage in an automated way through ARM?
There is a way to specify the createMode of your database in the ARM template. This is very undocumented stuff but I found this in the REST api documentation and then just tried in the ARM template.
You can specify the properties "createMode" and "sourceDatabaseId".
I am not using this functionality because the sourceDatabaseId needs to be in the same subscription which was not the case with me. So i export the bacpac manually and then use an ARM template to import the bacpac (which also is undocumented but I commented the ARM template used here: https://azure.microsoft.com/en-us/documentation/articles/sql-database-import/)

Resources